From 8ccb2e5525fbf4681e5695c6b62aef092c978c66 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 10 Feb 2015 23:14:35 +0000 Subject: [PATCH] Don't validate and transfer data from hidden dialogs when closing. This is unexpected and resulted e.g. in calling the user-defined TransferDataFromWindow() multiple times for wxPreferencesPages used in wxPreferencesEditor under wxGTK (where it is modeless). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78467 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dlgcmn.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index f08e19d175..dcc2cb09c9 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -561,7 +561,13 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) closing.Append(this); - if ( !SendCloseButtonClickEvent() ) + // When a previously hidden (necessarily modeless) dialog is being closed, + // we must not perform the usual validation and data transfer steps as they + // had been already done when it was hidden and doing it again now would be + // unexpected and could result in e.g. the dialog asking for confirmation + // before discarding the changes being shown again, which doesn't make + // sense as the dialog is not being closed in response to any user action. + if ( !IsShown() || !SendCloseButtonClickEvent() ) { // If the handler didn't close the dialog (e.g. because there is no // button with matching id) we still want to close it when the user