Commit bdf9efc6 authored by Murray Cumming's avatar Murray Cumming
Browse files

C++11: More use of nullptr.

With help from clang-tidy.
parent 5d292018
......@@ -694,7 +694,7 @@ void AppWindow::open_browsed_document(const EpcServiceInfo* server, const Glib::
}
g_free(document_contents);
document_contents = 0;
document_contents = nullptr;
//TODO_Performance: Horribly inefficient, but happens rarely:
const auto temp_document_contents = document_temp.build_and_get_contents();
......@@ -2692,7 +2692,7 @@ Glib::ustring AppWindow::get_current_locale()
return m_current_locale;
//Get the user's current locale:
const auto cLocale = setlocale(LC_ALL, 0); //Passing NULL means query, instead of set.
const auto cLocale = setlocale(LC_ALL, nullptr); //Passing NULL means query, instead of set.
if(cLocale)
{
//std::cout << "debug1: " << G_STRFUNC << ": locale=" << cLocale << std::endl;
......
......@@ -649,7 +649,7 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
if(field)
{
//We need the connection when we run the script, so that the script may use it.
auto sharedconnection = connect_to_server(0 /* parent window */);
auto sharedconnection = connect_to_server(nullptr /* parent window */);
g_assert(sharedconnection);
......
......@@ -161,7 +161,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(0, service_type, (void*)0);
m_service_monitor = epc_service_monitor_new_for_types(nullptr, service_type, (void*)nullptr);
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);
......@@ -718,7 +718,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));
auto 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(0); /* sort more recently discovered items above */
(*iter)[m_existing_columns.m_col_time] = std::time(nullptr); /* sort more recently discovered items above */
(*iter)[m_existing_columns.m_col_service_name] = name;
(*iter)[m_existing_columns.m_col_service_info] = info;
......
......@@ -106,7 +106,7 @@ void Dialog_Import_CSV_Progress::clear()
m_progress_connection.disconnect();
m_ready_connection.disconnect();
m_data_source = 0;
m_data_source = nullptr;
m_current_row = 0;
}
......
......@@ -73,7 +73,7 @@ type_list_encodings get_list_of_encodings()
add_encoding(_("Unicode"), "UTF-7");
add_encoding(_("Unicode"), "UCS-2");
add_encoding(_("Unicode"), "UCS-4");
add_encoding(0, 0); // This just adds a separator in the combo box
add_encoding(nullptr, nullptr); // This just adds a separator in the combo box
add_encoding(_("Western"), "ISO-8859-1");
add_encoding(_("Central European"), "ISO-8859-2");
add_encoding(_("South European"), "ISO-8859-3");
......@@ -89,7 +89,7 @@ type_list_encodings get_list_of_encodings()
add_encoding(_("Celtic"), "ISO-8859-14");
add_encoding(_("Western"), "ISO-8859-15");
add_encoding(_("Romanian"), "ISO-8859-16");
add_encoding(0, 0); // This just adds a separator in the combo box
add_encoding(nullptr, nullptr); // This just adds a separator in the combo box
add_encoding(_("Central European"), "WINDOWS-1250");
add_encoding(_("Cyrillic"), "WINDOWS-1251");
add_encoding(_("Western"), "WINDOWS-1252");
......
......@@ -901,22 +901,22 @@ void ConnectionPool::avahi_start_publishing()
if(!document)
return;
m_epc_publisher = epc_publisher_new(document->get_database_title_original().c_str(), "glom", 0);
m_epc_publisher = epc_publisher_new(document->get_database_title_original().c_str(), "glom", nullptr);
epc_publisher_set_protocol(m_epc_publisher, publish_protocol);
epc_publisher_add_handler(m_epc_publisher, "document", on_publisher_document_requested, this /* user_data */, 0);
epc_publisher_add_handler(m_epc_publisher, "document", on_publisher_document_requested, this /* user_data */, nullptr);
//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 */, 0);
epc_publisher_set_auth_handler(m_epc_publisher, "document", on_publisher_document_authentication, this /* user_data */, nullptr);
//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, 0);
epc_shell_set_progress_hooks(&callbacks, this, nullptr);
//Prevent the consumer from seeing duplicates,
//if multiple client computers advertize the same document:
......
......@@ -202,7 +202,7 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
Glib::ustring trans_fields;
for(GSList* item = table->columns; item != 0; item = item->next)
for(GSList* item = table->columns; item != nullptr; item = item->next)
{
GdaMetaTableColumn* column = GDA_META_TABLE_COLUMN(item->data);
......
......@@ -103,7 +103,7 @@ static inline const char* glom_get_locale_date_format()
//each time.
//Even when the LC_TIME environment variable is not set, we still seem
//to get a useful value here, based on LC_ALL, for instance.
char* lc_time = setlocale(LC_TIME, NULL);
char* lc_time = setlocale(LC_TIME, nullptr);
if(lc_time)
lc_time = g_strdup(lc_time);
......@@ -121,7 +121,7 @@ static inline const char* glom_get_locale_date_format()
//(which uses 2 digits when using %x).
//Get the current LC_MESSAGES value:
old_lc_messages = g_strdup(setlocale(LC_MESSAGES, NULL));
old_lc_messages = g_strdup(setlocale(LC_MESSAGES, nullptr));
if(old_lc_messages)
old_lc_messages = g_strdup(old_lc_messages);
......
......@@ -758,7 +758,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 != 0; item = item->next)
for(GSList* item = meta_table->columns; item != nullptr; item = item->next)
{
GdaMetaTableColumn* column = GDA_META_TABLE_COLUMN(item->data);
if(!column)
......@@ -1313,7 +1313,7 @@ bool create_table_add_missing_fields(const std::shared_ptr<const TableInfo>& tab
{
if(!get_field_exists_in_database(table_name, field->get_name()))
{
const auto test = add_column(table_name, field, 0); /* TODO: parent_window */
const auto test = add_column(table_name, field, nullptr); /* TODO: parent_window */
if(!test)
return test;
}
......
......@@ -224,7 +224,7 @@ void PyGlomRecord::set_fields(const PyGlomRecord::type_map_field_values& field_v
m_key_field = key_field;
m_key_field_value = key_field_value;
if(m_document == 0)
if(m_document == nullptr)
m_document = document;
m_connection = opened_connection;
......
......@@ -188,7 +188,7 @@ public:
std::vector<std::string> arguments = Glib::shell_parse_argv(command_line);
int child_stdout = 0;
int child_stderr = 0;
Glib::spawn_async_with_pipes(Glib::get_current_dir(), arguments, Glib::SPAWN_DO_NOT_REAP_CHILD, sigc::slot<void()>(), &pid, 0, (redirect & REDIRECT_STDOUT) ? &child_stdout : 0, (redirect & REDIRECT_STDERR) ? &child_stderr : 0);
Glib::spawn_async_with_pipes(Glib::get_current_dir(), arguments, Glib::SPAWN_DO_NOT_REAP_CHILD, sigc::slot<void()>(), &pid, nullptr, (redirect & REDIRECT_STDOUT) ? &child_stdout : nullptr, (redirect & REDIRECT_STDERR) ? &child_stderr : nullptr);
if(redirect & REDIRECT_STDOUT)
redirect_to_string(child_stdout, stdout_text);
if(redirect & REDIRECT_STDERR)
......@@ -297,7 +297,7 @@ static std::shared_ptr<const SpawnInfo> spawn_async(const Glib::ustring& command
* @param return_status: The return value of the command.
* @result Whether we successfully ended the async spawn.
*/
static bool spawn_async_end(std::shared_ptr<const SpawnInfo> info, std::string* stdout_text = 0, std::string* stderr_text = 0, int* return_status = 0)
static bool spawn_async_end(std::shared_ptr<const SpawnInfo> info, std::string* stdout_text = nullptr, std::string* stderr_text = nullptr, int* return_status = nullptr)
{
if(stdout_text)
info->get_stdout(*stdout_text);
......@@ -371,7 +371,7 @@ bool execute_command_line_and_wait(const std::string& command, const SlotProgres
timeout_connection.disconnect();
int return_status = false;
const auto returned = Impl::spawn_async_end(info, 0, 0, &return_status);
const auto returned = Impl::spawn_async_end(info, nullptr, nullptr, &return_status);
if(!returned)
return false; // User closed the dialog prematurely?
......@@ -472,7 +472,7 @@ namespace
std::string stdout_output;
try
{
return_status = Impl::spawn_sync(second_command, &stdout_output, 0);
return_status = Impl::spawn_sync(second_command, &stdout_output, nullptr);
}
catch(const Impl::SpawnError& ex)
{
......@@ -585,7 +585,7 @@ bool execute_command_line_and_wait_until_second_command_returns_success(const st
std::string stderr_text;
int return_status = 0;
const auto success = Impl::spawn_async_end(info, 0, &stderr_text, &return_status);
const auto success = Impl::spawn_async_end(info, nullptr, &stderr_text, &return_status);
if(success && (return_status == EXIT_SUCCESS))
{
......
......@@ -434,7 +434,7 @@ std::string sqlbuilder_get_full_query(
result.raw().data(), result.raw().size(),
"ISO-8859-1", "UTF-8",
(char*)"?",
0, 0, 0));
nullptr, nullptr, nullptr));
const Glib::ustring str = std::string(buf.get());
if(str.empty())
......
......@@ -285,7 +285,7 @@ bool import_translations_from_po_file(const std::shared_ptr<Document>& document,
//Look at each domain (could there be more than one?):
const char* const* domains = po_file_domains(po_file);
for (int i = 0; domains[i] != 0; ++i)
for (int i = 0; domains[i] != nullptr; ++i)
{
//Look at each message:
auto iter = po_message_iterator(po_file, domains[i]);
......
......@@ -73,7 +73,7 @@ static Glib::ustring xslt_process(const xmlpp::Document& xml_document, const std
Glib::ustring result;
//Use libxslt to transform the XML:
xmlDocPtr style = xmlReadDoc((xmlChar*)xslt_data, 0, 0, 0);
xmlDocPtr style = xmlReadDoc((xmlChar*)xslt_data, nullptr, nullptr, 0);
if(style)
{
//We need this to be able to use the exsl: functions, even if we declare the namespace at the start of the xsl.
......@@ -85,14 +85,14 @@ static Glib::ustring xslt_process(const xmlpp::Document& xml_document, const std
if(cur)
{
//Use the parsed stylesheet on the XML:
xmlDocPtr pDocOutput = xsltApplyStylesheet(cur, const_cast<xmlDoc*>(xml_document.cobj()), 0);
xmlDocPtr pDocOutput = xsltApplyStylesheet(cur, const_cast<xmlDoc*>(xml_document.cobj()), nullptr);
xsltFreeStylesheet(cur);
//Get the output text:
xmlChar* buffer = nullptr;
int length = 0;
xmlIndentTreeOutput = 1; //Format the output with extra white space. TODO: Is there a better way than this global variable?
xmlDocDumpFormatMemoryEnc(pDocOutput, &buffer, &length, 0, 0);
xmlDocDumpFormatMemoryEnc(pDocOutput, &buffer, &length, nullptr, 0);
if(buffer)
{
......
......@@ -361,7 +361,7 @@ void Box_Data::execute_button_script(const std::shared_ptr<const LayoutItem_Butt
const auto field_values = get_record_field_values_for_calculation(m_table_name, field_primary_key, primary_key_value);
//We need the connection when we run the script, so that the script may use it.
auto sharedconnection = connect_to_server(0 /* parent window */);
auto sharedconnection = connect_to_server(nullptr /* parent window */);
//Allow this UI to respond to UI change requests from the Python code:
AppPythonUICallbacks callbacks;
......
......@@ -517,7 +517,7 @@ void Box_Data_Calendar_Related::on_calendar_button_press_event(GdkEventButton *b
#endif
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window(Gtk::Widget::gobj()), button_event->device, 0, 0, &mods );
gdk_window_get_device_position( gtk_widget_get_window(Gtk::Widget::gobj()), button_event->device, nullptr, nullptr, &mods );
if(mods & GDK_BUTTON3_MASK)
{
//Give user choices of actions on this item:
......
......@@ -83,7 +83,7 @@ bool ButtonGlom::on_button_press_event(GdkEventButton *button_event)
if(pApp && pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0, 0, &mods );
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, nullptr, nullptr, &mods );
if(mods & GDK_BUTTON3_MASK)
{
//Give user choices of actions on this item:
......
......@@ -57,7 +57,7 @@ bool CheckButton::on_button_press_event(GdkEventButton *button_event)
if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0, 0, &mods );
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, nullptr, nullptr, &mods );
if(mods & GDK_BUTTON3_MASK)
{
//Give user choices of actions on this item:
......
......@@ -320,7 +320,7 @@ g_warning("ComboGlom::on_button_press_event()");
if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0, 0, &mods );
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, nullptr, nullptr, &mods );
if(mods & GDK_BUTTON3_MASK)
{
//Give user choices of actions on this item:
......
......@@ -268,7 +268,7 @@ void ComboAsRadioButtons::show_context_menu(GdkEventButton *button_event)
if(pApp->get_userlevel() == AppState::userlevels::DEVELOPER)
{
GdkModifierType mods;
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, 0, 0, &mods );
gdk_window_get_device_position( gtk_widget_get_window (Gtk::Widget::gobj()), button_event->device, nullptr, nullptr, &mods );
if(mods & GDK_BUTTON3_MASK)
{
//Give user choices of actions on this item:
......
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