Commit 6debb62d authored by Murray Cumming's avatar Murray Cumming
Browse files

Replace use of NULL with 0, because this is C++.

Replace use of != NULL with nothing.
parent 75eb02e9
2009-10-13 Murray Cumming <murrayc@murrayc.com>
* *.cc: Replace use of NULL with 0, because this is C++.
Replace use of != NULL with nothing.
2009-10-12 Murray Cumming <murrayc@murrayc.com>
 
* glom/utility_widgets/db_adddel/db_adddel.cc:
......
......@@ -65,10 +65,10 @@
namespace Glom
{
static const int GLOM_RESPONSE_BROWSE_NETWORK = 1;
//static const int GLOM_RESPONSE_BROWSE_NETWORK = 1;
// Global application variable
App_Glom* global_application = NULL;
App_Glom* global_application = 0;
App_Glom::App_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder)
: type_base(cobject, "Glom"),
......@@ -702,7 +702,7 @@ void App_Glom::open_browsed_document(const EpcServiceInfo* server, const Glib::u
epc_consumer_set_username(consumer, username.c_str());
epc_consumer_set_password(consumer, password.c_str());
GError *error = NULL;
GError *error = 0;
document_contents = (gchar*)epc_consumer_lookup(consumer, "document", &length, &error);
if(error)
{
......@@ -731,7 +731,7 @@ void App_Glom::open_browsed_document(const EpcServiceInfo* server, const Glib::u
}
delete dialog_connection;
dialog_connection = NULL;
dialog_connection = 0;
}
......@@ -1544,7 +1544,7 @@ bool App_Glom::recreate_database(bool& user_cancelled)
sharedptr<SharedConnection> sharedconnection = connection_pool->connect();
#else
sharedptr<SharedConnection> sharedconnection = connection_pool->connect(error);
if(error.get() == NULL)
if(!error.get())
{
#endif // GLIBMM_EXCEPTIONS_ENABLED
g_warning("App_Glom::recreate_database(): Failed because database exists already.");
......@@ -1558,7 +1558,7 @@ bool App_Glom::recreate_database(bool& user_cancelled)
catch(const ExceptionConnection& ex)
{
#else
if(error.get() != NULL)
if(error.get())
{
const ExceptionConnection* exptr = dynamic_cast<ExceptionConnection*>(error.get());
if(exptr)
......@@ -1625,7 +1625,7 @@ bool App_Glom::recreate_database(bool& user_cancelled)
sharedconnection = connection_pool->connect();
#else
sharedconnection = connection_pool->connect(error);
if(error.get() == NULL)
if(!error.get())
#endif // GLIBMM_EXCEPTIONS_ENABLED
connection_pool->set_database(db_name); //The database was successfully created, so specify it when connecting from now on.
}
......@@ -1633,7 +1633,7 @@ bool App_Glom::recreate_database(bool& user_cancelled)
catch(const ExceptionConnection& ex)
{
#else
if(error.get() != NULL)
if(error.get())
{
const std::exception& ex = *error.get();
#endif // GLIBMM_EXCEPTIONS_ENABLED
......@@ -1821,7 +1821,7 @@ void App_Glom::fill_menu_tables()
catch(const Glib::Error& ex)
{
#else
if(error.get() != NULL)
if(error.get())
{
const Glib::Error& ex = *error.get();
#endif // GLIBMM_EXCEPTIONS_ENABLED
......@@ -1920,7 +1920,7 @@ void App_Glom::fill_menu_reports(const Glib::ustring& table_name)
catch(const Glib::Error& ex)
{
#else
if(error.get() != NULL)
if(error.get())
{
const Glib::Error& ex = *error.get();
#endif // GLIBMM_EXCEPTIONS_ENABLED
......@@ -2032,7 +2032,7 @@ void App_Glom::fill_menu_print_layouts(const Glib::ustring& table_name)
catch(const Glib::Error& ex)
{
#else
if(error.get() != NULL)
if(error.get())
{
const Glib::Error& ex = *error.get();
#endif // GLIBMM_EXCEPTIONS_ENABLED
......
......@@ -160,7 +160,7 @@ void App_WithDoc_Gtk::add_ui_from_string(const Glib::ustring& ui_description)
#else
std::auto_ptr<Glib::Error> error;
m_refUIManager->add_ui_from_string(ui_description, error);
if(error.get() != NULL) std::cerr << "building menus failed: " << error->what();
if(error.get()) std::cerr << "building menus failed: " << error->what();
#endif
}
......@@ -668,15 +668,14 @@ Glib::ustring App_WithDoc_Gtk::ui_file_select_save(const Glib::ustring& old_file
void App_WithDoc_Gtk::ui_show_modification_status()
{
bool modified = m_pDocument->get_modified();
const bool modified = m_pDocument->get_modified();
//Enable Save and SaveAs menu items:
if(m_action_save)
g_object_set(G_OBJECT(m_action_save->gobj()), "sensitive", modified, NULL); // TODO: Use a set_sensitive(modified)?
m_action_save->set_sensitive(modified);
if(m_action_saveas)
g_object_set(G_OBJECT(m_action_saveas->gobj()), "sensitive", modified, NULL); // TODO: Use a set_sensitive(modified)?
m_action_saveas->set_sensitive(modified);
}
App_WithDoc_Gtk::enumSaveChanges App_WithDoc_Gtk::ui_offer_to_save_changes()
......
......@@ -568,7 +568,7 @@ static bool meta_table_column_is_primary_key(GdaMetaTable* meta_table, const Gli
if(!meta_table)
return false;
for(GSList* item = meta_table->columns; item != NULL; item = item->next)
for(GSList* item = meta_table->columns; item != 0; item = item->next)
{
GdaMetaTableColumn* column = GDA_META_TABLE_COLUMN(item->data);
if(!column)
......
......@@ -122,7 +122,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
#else
std::auto_ptr<ExceptionConnection> error;
sharedptr<SharedConnection> sharedconnection = connect_to_server(App_Glom::get_application(), error);
if(error.get() == NULL)
if(!error.get())
{
// Don't evaluate function on error
#endif // GLIBMM_EXCEPTIONS_ENABLED
......
......@@ -174,7 +174,7 @@ Dialog_ExistingOrNew::Dialog_ExistingOrNew(BaseObjectType* cobject, const Glib::
// Browse local network
#ifndef G_OS_WIN32
gchar* service_type = epc_service_type_new(EPC_PROTOCOL_HTTPS, "glom");
m_service_monitor = epc_service_monitor_new_for_types(NULL, service_type, NULL);
m_service_monitor = epc_service_monitor_new_for_types(0, service_type, 0);
g_signal_connect(m_service_monitor, "service-found", G_CALLBACK(on_service_found_static), this);
g_signal_connect(m_service_monitor, "service-removed", G_CALLBACK(on_service_removed_static), this);
g_free(service_type);
......@@ -288,7 +288,7 @@ Dialog_ExistingOrNew::~Dialog_ExistingOrNew()
if(m_service_monitor)
{
g_object_unref(m_service_monitor);
m_service_monitor = NULL;
m_service_monitor = 0;
}
// Release the service infos in the treestore
......@@ -876,7 +876,7 @@ void Dialog_ExistingOrNew::on_service_found(const Glib::ustring& name, EpcServic
gchar* title = g_strdup_printf(_("%s on %s (via %s)"), name.c_str(), epc_service_info_get_host(info), epc_service_info_get_interface(info));
Gtk::TreeModel::iterator iter = m_existing_model->prepend(m_iter_existing_network->children());
(*iter)[m_existing_columns.m_col_title] = title;
(*iter)[m_existing_columns.m_col_time] = std::time(NULL); /* sort more recently discovered items above */
(*iter)[m_existing_columns.m_col_time] = std::time(0); /* sort more recently discovered items above */
(*iter)[m_existing_columns.m_col_service_name] = name;
(*iter)[m_existing_columns.m_col_service_info] = info;
......
......@@ -2361,7 +2361,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
ConnectionPoolBackends::PostgresCentralHosted* central = dynamic_cast<ConnectionPoolBackends::PostgresCentralHosted*>(backend);
g_assert(central != NULL);
g_assert(central);
document->set_connection_server(central->get_host());
document->set_connection_port(central->get_port());
......@@ -2378,7 +2378,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
{
ConnectionPool::Backend* backend = connection_pool->get_backend();
ConnectionPoolBackends::PostgresSelfHosted* self = dynamic_cast<ConnectionPoolBackends::PostgresSelfHosted*>(backend);
g_assert(self != NULL);
g_assert(self);
document->set_connection_port(self->get_port());
document->set_connection_try_other_ports(false);
......@@ -2740,7 +2740,7 @@ void Frame_Glom::on_menu_print_layout_selected(const Glib::ustring& print_layout
Glib::KeyFile key_file;
key_file.load_from_data(key_file_text);
//TODO: Use this when gtkmm and GTK+ have been fixed: page_setup = Gtk::PageSetup::create(key_file);
page_setup = Glib::wrap(gtk_page_setup_new_from_key_file(key_file.gobj(), NULL, NULL));
page_setup = Glib::wrap(gtk_page_setup_new_from_key_file(key_file.gobj(), 0, 0));
}
print->set_default_page_setup(page_setup);
......
......@@ -34,7 +34,7 @@ namespace Utils
inline std::string get_glade_file_path(const std::string& filename)
{
#ifdef G_OS_WIN32
gchar* directory = g_win32_get_package_installation_directory_of_module(NULL);
gchar* directory = g_win32_get_package_installation_directory_of_module(0);
const std::string result = Glib::build_filename(directory, Glib::build_filename("share/glom/glade", filename));
g_free(directory);
return result;
......
......@@ -52,7 +52,7 @@ pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class_,
{
DWORD InfoBufferSize;
if(GetTokenInformation(token, class_, NULL, 0, &InfoBufferSize))
if(GetTokenInformation(token, class_, 0, 0, &InfoBufferSize))
{
snprintf(errbuf, errsize, "could not get token information: got zero size\n");
return FALSE;
......@@ -66,7 +66,7 @@ pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class_,
}
*InfoBuffer = static_cast<char*>(malloc(InfoBufferSize));
if(*InfoBuffer == NULL)
if(*InfoBuffer == 0)
{
snprintf(errbuf, errsize, "could not allocate %d bytes for token information\n",
(int) InfoBufferSize);
......@@ -88,7 +88,7 @@ int
pgwin32_is_admin(void)
{
HANDLE AccessToken;
char *InfoBuffer = NULL;
char *InfoBuffer = 0;
char errbuf[256];
PTOKEN_GROUPS Groups;
PSID AdministratorsSid;
......@@ -942,22 +942,22 @@ void ConnectionPool::avahi_start_publishing()
if(!document)
return;
m_epc_publisher = epc_publisher_new(document->get_database_title().c_str(), "glom", NULL);
m_epc_publisher = epc_publisher_new(document->get_database_title().c_str(), "glom", 0);
epc_publisher_set_protocol(m_epc_publisher, publish_protocol);
epc_publisher_add_handler(m_epc_publisher, "document", on_publisher_document_requested, this /* user_data */, NULL);
epc_publisher_add_handler(m_epc_publisher, "document", on_publisher_document_requested, this /* user_data */, 0);
//Password-protect the document,
//because the document's structure could be considered as a business secret:
epc_publisher_set_auth_flags(m_epc_publisher, EPC_AUTH_PASSWORD_TEXT_NEEDED);
epc_publisher_set_auth_handler(m_epc_publisher, "document", on_publisher_document_authentication, this /* user_data */, NULL);
epc_publisher_set_auth_handler(m_epc_publisher, "document", on_publisher_document_authentication, this /* user_data */, 0);
//Install progress callback, so we can keep the UI responsive while libepc is generating certificates for the first time:
EpcShellProgressHooks callbacks;
callbacks.begin = &ConnectionPool::on_epc_progress_begin;
callbacks.update = &ConnectionPool::on_epc_progress_update;
callbacks.end = &ConnectionPool::on_epc_progress_end;
epc_shell_set_progress_hooks(&callbacks, this, NULL);
epc_shell_set_progress_hooks(&callbacks, this, 0);
//Prevent the consumer from seeing duplicates,
//if multiple client computers advertize the same document:
......
......@@ -196,7 +196,7 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
Glib::ustring trans_fields;
for(GSList* item = table->columns; item != NULL; item = item->next)
for(GSList* item = table->columns; item != 0; item = item->next)
{
GdaMetaTableColumn* column = GDA_META_TABLE_COLUMN(item->data);
......
......@@ -145,7 +145,7 @@ void Field::set_field_info(const Glib::RefPtr<Gnome::Gda::Column>& fieldinfo)
{
cur_type = get_gda_type_for_glom_type(get_glom_type());
const FieldTypes* pFieldTypes = NULL;
const FieldTypes* pFieldTypes = 0;
ConnectionPool* pConnectionPool = ConnectionPool::get_instance();
if(pConnectionPool)
......@@ -168,7 +168,7 @@ void Field::set_field_info(const Glib::RefPtr<Gnome::Gda::Column>& fieldinfo)
// TODO: Basically copied from set_default_value(). Maybe this check should
// be moved into an extra function.
GType cur_type = get_gda_type_for_glom_type(get_glom_type());
const FieldTypes* pFieldTypes = NULL;
const FieldTypes* pFieldTypes = 0;
ConnectionPool* pConnectionPool = ConnectionPool::get_instance();
if(pConnectionPool)
......@@ -477,7 +477,7 @@ void Field::set_default_value(const Gnome::Gda::Value& value)
// Verify that the value matches the type of the field.
GType cur_type = get_gda_type_for_glom_type(get_glom_type());
const FieldTypes* pFieldTypes = NULL;
const FieldTypes* pFieldTypes = 0;
ConnectionPool* pConnectionPool = ConnectionPool::get_instance();
if(pConnectionPool)
......
......@@ -204,7 +204,7 @@ Glib::ustring TranslatableItem::get_current_locale()
{
if(m_current_locale.empty())
{
const char* cLocale = setlocale(LC_ALL, NULL); //Passing NULL means query, instead of set.
const char* cLocale = setlocale(LC_ALL, 0); //Passing NULL means query, instead of set.
if(cLocale)
{
//std::cout << "TranslatableItem::get_current_locale(): locale=" << cLocale << std::endl;
......
......@@ -217,7 +217,7 @@ bool Document::read_from_disk()
#else
std::auto_ptr<Glib::Error> error;
stream = file->read(error);
if(error.get() != NULL)
if(error.get())
return false; //print_error(ex, input_uri_string);
#endif
......@@ -238,7 +238,7 @@ bool Document::read_from_disk()
#else
std::auto_ptr<Glib::Error> gerror;
bytes_read = stream->read(buffer, BYTES_TO_PROCESS, gerror);
if(gerror.get() != NULL) break;
if(gerror.get()) break;
#endif
if(bytes_read == 0)
......@@ -254,7 +254,7 @@ bool Document::read_from_disk()
catch(const Gio::Error& ex)
{
#else
if(error.get() != NULL)
if(error.get())
{
std::cerr << "Error: " << error->what() << std::endl;
#endif
......@@ -297,7 +297,7 @@ bool Document::write_to_disk()
#else
std::auto_ptr<Glib::Error> error;
stream = file->replace(std::string(), false, Gio::FILE_CREATE_NONE, error);
if(error.get() != NULL)
if(error.get())
{
std::cout << "Error: " << error->what() << std::endl;
#endif
......@@ -326,7 +326,7 @@ bool Document::write_to_disk()
#else
std::auto_ptr<Glib::Error> gerror;
stream->write(m_strContents.data(), m_strContents.bytes(), gerror);
if(gerror.get() != NULL)
if(gerror.get())
{
std::cerr << "Error: "<< gerror.get() << std::endl;
#endif
......@@ -410,7 +410,7 @@ bool Document::get_read_only() const
#else
std::auto_ptr<Glib::Error> error;
info = file->query_info(G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, Gio::FILE_QUERY_INFO_NONE, error);
if(error.get() != NULL)
if(error.get())
return false;
#endif
......
......@@ -56,7 +56,7 @@ Record_init(PyObject *self, PyObject * /* args */, PyObject * /* kwds */)
{
PyGlomRecord *self_record = (PyGlomRecord*)self;
//static char *kwlist[] = {"test", NULL};
//static char *kwlist[] = {"test", 0};
//if(!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist,
// &self->m_test))
......@@ -175,7 +175,7 @@ static PyGetSetDef Record_getseters[] = {
{(char*)"table_name",
(getter)Record__get_table_name, (setter)0, 0, 0
},
{NULL, 0, 0, 0, 0, } // Sentinel
{0, 0, 0, 0, 0, } // Sentinel
};
//Adapt to API changes in Python 2.5:
......@@ -236,7 +236,7 @@ Record_tp_as_mapping_getitem(PyObject *self, PyObject *item)
g_warning("Record_tp_as_mapping_getitem(): return null.");
PyErr_SetString(PyExc_IndexError, "field not found");
return NULL;
return 0;
}
/*
......@@ -256,7 +256,7 @@ static PyMappingMethods Record_tp_as_mapping = {
static PyTypeObject pyglom_RecordType = {
PyObject_HEAD_INIT(NULL)
PyObject_HEAD_INIT(0)
0, /*ob_size*/
(char*)"glom.Record", /*tp_name*/
sizeof(PyGlomRecord), /*tp_basicsize*/
......
......@@ -192,7 +192,7 @@ Related_tp_as_mapping_getitem(PyObject *self, PyObject *item)
}
PyErr_SetString(PyExc_IndexError, "relationship not found");
return NULL;
return 0;
}
/*
......@@ -212,7 +212,7 @@ static PyMappingMethods Related_tp_as_mapping = {
static PyTypeObject pyglom_RelatedType = {
PyObject_HEAD_INIT(NULL)
PyObject_HEAD_INIT(0)
0, /*ob_size*/
(char*)"glom.Related", /*tp_name*/
sizeof(PyGlomRelated), /*tp_basicsize*/
......
......@@ -62,7 +62,7 @@ RelatedRecord_new(PyTypeObject *type, PyObject * /* args */, PyObject * /* kwds
static int
RelatedRecord_init(PyGlomRelatedRecord *self, PyObject * /* args */, PyObject * /* kwds */)
{
//static char *kwlist[] = {"test", NULL};
//static char *kwlist[] = {"test", 0};
//if(!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist,
// &self->m_test))
......@@ -136,7 +136,7 @@ static PyGetSetDef RelatedRecord_getseters[] = {
{"fields",
(getter)RelatedRecord__get_fields, (setter)0, 0, 0
},
{NULL, 0, 0, 0, 0, } // Sentinel
{0, 0, 0, 0, 0, } // Sentinel
};
*/
......@@ -267,7 +267,7 @@ RelatedRecord_tp_as_mapping_getitem(PyObject *self, PyObject *item)
g_warning("RelatedRecord_tp_as_mapping_getitem(): return null.");
PyErr_SetString(PyExc_IndexError, "field not found");
return NULL;
return 0;
}
/*
......@@ -293,10 +293,10 @@ RelatedRecord_generic_aggregate(PyGlomRelatedRecord* self, PyObject *args, PyObj
PyObject* py_field_name = 0;
if(!PyArg_ParseTupleAndKeywords(args, kwargs, (char*)"O:RelatedRecord.sum", (char**)kwlist, &py_field_name))
return NULL;
return 0;
if(!(PyString_Check(py_field_name)))
return NULL;
return 0;
const char* pchKey = PyString_AsString(py_field_name);
if(pchKey)
......@@ -416,14 +416,14 @@ static PyMethodDef RelatedRecord_methods[] = {
{(char*)"max", (PyCFunction)RelatedRecord_max, METH_VARARGS | METH_KEYWORDS,
(char*)"Maximum of all values of the field in the related records."
},
{NULL, 0, 0, 0} /* Sentinel */
{0, 0, 0, 0} /* Sentinel */
};
static PyTypeObject pyglom_RelatedRecordType = {
PyObject_HEAD_INIT(NULL)
PyObject_HEAD_INIT(0)
0, /*ob_size*/
(char*)"glom.RelatedRecord", /*tp_name*/
sizeof(PyGlomRelatedRecord), /*tp_basicsize*/
......
......@@ -33,7 +33,7 @@ main(int argc, char* argv[])
{
std::string stdout_output;
int return_status = 0;
Glib::spawn_command_line_sync(command, &stdout_output, NULL, &return_status);
Glib::spawn_command_line_sync(command, &stdout_output, 0, &return_status);
std::cout << " debug: output=" << stdout_output << std::endl;
}
catch(const Glib::Error& ex)
......
......@@ -271,7 +271,7 @@ main(int argc, char* argv[])
return -1;
}
gchar* installation_dir_c = g_win32_get_package_installation_directory_of_module(NULL);
gchar* installation_dir_c = g_win32_get_package_installation_directory_of_module(0);
const std::string installation_dir(installation_dir_c);
g_free(installation_dir_c);
#endif
......@@ -362,7 +362,7 @@ main(int argc, char* argv[])
#ifdef GLIBMM_EXCEPTIONS_ENABLED
catch(const Glib::OptionError& ex)
#else
if(error.get() != NULL)
if(error.get())
#endif
{
#ifndef GLIBMM_EXCEPTIONS_ENABLED
......
......@@ -360,7 +360,7 @@ void Box_Data::execute_button_script(const sharedptr<const LayoutItem_Button>& l
#else
std::auto_ptr<ExceptionConnection> error;
sharedptr<SharedConnection> sharedconnection = connect_to_server(0 /* parent window */, error);
if(error.get() == NULL)
if(!error.get())
{
#endif // GLIBMM_EXCEPTIONS_ENABLED
......
......@@ -331,7 +331,7 @@ Box_Data_Calendar_Related::type_vecLayoutFields Box_Data_Calendar_Related::get_f
void Box_Data_Calendar_Related::on_dialog_layout_hide()
{
Dialog_Layout_Calendar_Related* dialog_related = dynamic_cast<Dialog_Layout_Calendar_Related*>(m_pDialogLayout);
g_assert(dialog_related != NULL);
g_assert(dialog_related);
m_portal = dialog_related->get_portal_layout();
......@@ -366,13 +366,13 @@ Dialog_Layout* Box_Data_Calendar_Related::create_layout_dialog() const
return dialog;
}
return NULL;
return 0;
}
void Box_Data_Calendar_Related::prepare_layout_dialog(Dialog_Layout* dialog)
{
Dialog_Layout_Calendar_Related* related_dialog = dynamic_cast<Dialog_Layout_Calendar_Related*>(dialog);
g_assert(related_dialog != NULL);
g_assert(related_dialog);
sharedptr<LayoutItem_CalendarPortal> derived_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(m_portal);
if(derived_portal && derived_portal->get_has_relationship_name())
......@@ -541,7 +541,7 @@ void Box_Data_Calendar_Related::setup_menu()
#else
std::auto_ptr<Glib::Error> error;
m_refUIManager->add_ui_from_string(ui_info, error);
if(error.get() != NULL)
if(error.get())
{
std::cerr << "building menus failed: " << error->what();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment