Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/iptux/UiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ void pop_info(GtkWidget* parent, const gchar* format, ...) {
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), msg);
g_free(msg);
gtk_window_set_title(GTK_WINDOW(dialog), _("Information"));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The response handler signature no longer matches gtk_widget_destroy.

"response" handlers receive (GtkDialog*, gint), but gtk_widget_destroy takes only a GtkWidget*. With this direct connection the gint will be treated as a pointer, causing undefined behavior or crashes. Instead, either use g_signal_connect_swapped with the dialog as user data, or create a wrapper callback matching the response signature that calls gtk_widget_destroy(dialog).

gtk_widget_show(dialog);
Comment on lines +189 to +190
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "response" signal has the signature (GtkDialog*, gint response_id, gpointer), but gtk_widget_destroy takes only a single GtkWidget*. Connecting it directly relies on undefined behavior/calling convention quirks. Use g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog) or a small wrapper callback with the proper signature that destroys the dialog.

Copilot uses AI. Check for mistakes.
}

/**
Expand Down Expand Up @@ -216,8 +216,8 @@ void pop_warning(GtkWidget* parent, const gchar* format, ...) {
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dialog), msg);
g_free(msg);
gtk_window_set_title(GTK_WINDOW(dialog), _("Warning"));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_widget_show(dialog);
Comment on lines +219 to +220
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing gtk_dialog_run makes this dialog non-blocking; any callers that expect the warning to be shown/acknowledged before continuing will break. For example, Application::onActivate (src/iptux/Application.cpp:221-226) calls pop_warning() and then immediately quits the application, so the warning dialog may never be presented. Either keep pop_warning synchronous (e.g., run a local main loop until response) or refactor callers to perform follow-up actions (like quitting) from the dialog's response handler.

Suggested change
g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_widget_show(dialog);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);

Copilot uses AI. Check for mistakes.
}

/**
Expand Down
Loading