diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 2cdf18098f..c30d349e3f 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -169,12 +169,19 @@ int wxDialog::ShowModal() wxOpenModalDialogLocker modalLock; + // Prevent the widget from being destroyed if the user closes the window. + // Needed for derived classes which bypass wxTLW::Create(), and therefore + // the wxTLW "delete-event" handler is not connected + gulong handler_id = g_signal_connect( + m_widget, "delete-event", G_CALLBACK(gtk_true), this); + // Run modal dialog event loop. { wxGUIEventLoopTiedPtr modal(&m_modalLoop, new wxGUIEventLoop()); m_modalLoop->Run(); } + g_signal_handler_disconnect(m_widget, handler_id); #if GTK_CHECK_VERSION(2,10,0) if (sigId) g_signal_remove_emission_hook(sigId, hookId); diff --git a/src/gtk/dirdlg.cpp b/src/gtk/dirdlg.cpp index 3ae28c4815..dc88826163 100644 --- a/src/gtk/dirdlg.cpp +++ b/src/gtk/dirdlg.cpp @@ -103,14 +103,6 @@ bool wxDirDialog::Create(wxWindow* parent, } #endif - // gtk_widget_hide_on_delete is used here to avoid that Gtk automatically destroys - // the dialog when the user press ESC on the dialog: in that case a second call to - // ShowModal() would result in a bunch of Gtk-CRITICAL errors... - g_signal_connect (m_widget, - "delete_event", - G_CALLBACK (gtk_widget_hide_on_delete), - (gpointer)this); - // local-only property could be set to false to allow non-local files to be loaded. // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere // and the GtkFileChooserDialog should probably also be created with a backend, diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index ce41843b03..e6f6320b86 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -237,15 +237,6 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message, if ( style & wxFD_MULTIPLE ) gtk_file_chooser_set_select_multiple(file_chooser, true); - // gtk_widget_hide_on_delete is used here to avoid that Gtk automatically - // destroys the dialog when the user press ESC on the dialog: in that case - // a second call to ShowModal() would result in a bunch of Gtk-CRITICAL - // errors... - g_signal_connect(m_widget, - "delete_event", - G_CALLBACK (gtk_widget_hide_on_delete), - this); - // local-only property could be set to false to allow non-local files to be // loaded. In that case get/set_uri(s) should be used instead of // get/set_filename(s) everywhere and the GtkFileChooserDialog should