Prevent dialog widget from being destroyed during ShowModal()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76226 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2014-03-30 19:23:07 +00:00
parent fa10b28e50
commit 0dd37e577a
3 changed files with 7 additions and 17 deletions

View File

@@ -169,12 +169,19 @@ int wxDialog::ShowModal()
wxOpenModalDialogLocker modalLock; 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. // Run modal dialog event loop.
{ {
wxGUIEventLoopTiedPtr modal(&m_modalLoop, new wxGUIEventLoop()); wxGUIEventLoopTiedPtr modal(&m_modalLoop, new wxGUIEventLoop());
m_modalLoop->Run(); m_modalLoop->Run();
} }
g_signal_handler_disconnect(m_widget, handler_id);
#if GTK_CHECK_VERSION(2,10,0) #if GTK_CHECK_VERSION(2,10,0)
if (sigId) if (sigId)
g_signal_remove_emission_hook(sigId, hookId); g_signal_remove_emission_hook(sigId, hookId);

View File

@@ -103,14 +103,6 @@ bool wxDirDialog::Create(wxWindow* parent,
} }
#endif #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. // 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 // 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, // and the GtkFileChooserDialog should probably also be created with a backend,

View File

@@ -237,15 +237,6 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
if ( style & wxFD_MULTIPLE ) if ( style & wxFD_MULTIPLE )
gtk_file_chooser_set_select_multiple(file_chooser, true); 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 // 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 // loaded. In that case get/set_uri(s) should be used instead of
// get/set_filename(s) everywhere and the GtkFileChooserDialog should // get/set_filename(s) everywhere and the GtkFileChooserDialog should