Project

General

Profile

Bug #2371 » 0037-gtk4-Fix-diplodlg-closing-memory-handling.patch

S3_3, S3_2 - Marko Lindqvist, 10/14/2026 07:32 PM

View differences:

client/gui-gtk-4.0/diplodlg.c
/* We have to raise the diplomacy meeting tab as well as the selected
* meeting. */
fc_assert_ret(dipl_main != NULL);
gui_dialog_raise(dipl_main->dialog);
gui_dialog_raise(pdialog->dialog);
......
}
/************************************************************************//**
Remove diplomacy dialog from use.
Destroy diplomacy dialog
****************************************************************************/
static void diplomacy_remove(struct Diplomacy_dialog *pdialog)
static void diplomacy_destroy(struct Diplomacy_dialog *pdialog)
{
/* Dialog destroy callbacks will take care of freeing everything
* related to the pdialog->dialog.
* Here we just take the dialog out of use. */
if (NULL != pdialog->dialog) {
/* pdialog->dialog may be NULL if the tab has been destroyed
* by an other way. */
gui_dialog_destroy(pdialog->dialog);
pdialog->dialog = NULL;
}
dialog_list_remove(dialog_list, pdialog);
if (dialog_list) {
......
struct Diplomacy_dialog *pdialog = NULL;
fc_assert_ret(data);
pdialog = (struct Diplomacy_dialog *)data;
switch (response) {
......
****************************************************************************/
void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
{
diplomacy_remove(pdialog);
diplomacy_destroy(pdialog);
}
/************************************************************************//**
client/gui-gtk-4.0/gui_stuff.c
**************************************************************************/
static void gui_dialog_destroy_handler(GtkWidget *w, struct gui_dialog *dlg)
{
if (dlg->type == GUI_DIALOG_TAB) {
GtkWidget *notebook = dlg->v.tab.notebook;
gulong handler_id = dlg->v.tab.handler_id;
g_signal_handler_disconnect(notebook, handler_id);
}
g_object_unref(dlg->gui_button);
if (*(dlg->source)) {
*(dlg->source) = NULL;
}
dialog_list = g_list_remove(dialog_list, dlg);
/* Raise the return dialog set by gui_dialog_set_return_dialog() */
......
n = gtk_notebook_page_num(GTK_NOTEBOOK(dlg->v.tab.notebook), dlg->grid);
gtk_notebook_remove_page(GTK_NOTEBOOK(dlg->v.tab.notebook), n);
g_signal_handler_disconnect(GTK_NOTEBOOK(dlg->v.tab.notebook),
dlg->v.tab.handler_id);
}
break;
}
if (*(dlg->source)) {
*(dlg->source) = NULL;
}
}
/**********************************************************************//**
(2-2/2)