From 04e01711b1db232e443cada7b154cf6ae53db620 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 15 Sep 2014 13:59:40 +0200 Subject: [PATCH] Fix a compatibility issue on wxGTK 2.8, on Linux ( Bug #1369290 ) --- .../dialog_edit_component_in_schematic.cpp | 19 ++++++++++++++--- ...dialog_edit_component_in_schematic_fbp.cpp | 2 ++ ...dialog_edit_component_in_schematic_fbp.fbp | 2 +- .../dialog_edit_component_in_schematic_fbp.h | 1 + .../dialog_edit_libentry_fields_in_lib.cpp | 21 ++++++++++++++----- ...ialog_edit_libentry_fields_in_lib_base.cpp | 4 +++- ...ialog_edit_libentry_fields_in_lib_base.fbp | 2 +- .../dialog_edit_libentry_fields_in_lib_base.h | 3 ++- 8 files changed, 42 insertions(+), 12 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index f939ca179a..558a1f531c 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -106,6 +106,7 @@ private: void setRowItem( int aFieldNdx, const SCH_FIELD& aField ); // event handlers + void OnCloseDialog( wxCloseEvent& event ); void OnListItemDeselected( wxListEvent& event ); void OnListItemSelected( wxListEvent& event ); void OnCancelButtonClick( wxCommandEvent& event ); @@ -216,9 +217,21 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event } +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCloseDialog( wxCloseEvent& event ) +{wxMessageBox("DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCloseDialog"); + // On wxWidgets 2.8, and on Linux, calling EndQuasiModal here is mandatory + // Otherwise, the main event loop is never restored, and Eeschema does not + // respond to any event, because the DIALOG_SHIM destructor is never called. + // on wxWidgets 3.0, or on Windows, the DIALOG_SHIM destructor is called, + // and calls EndQuasiModal. + // therefore calling EndQuasiModal here is not mandatory but it creates no issues + EndQuasiModal( wxID_CANCEL ); +} + + void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event ) { - EndQuasiModal( 1 ); + EndQuasiModal( wxID_CANCEL ); } @@ -402,7 +415,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event m_Parent->GetScreen()->TestDanglingEnds(); m_Parent->GetCanvas()->Refresh( true ); - EndQuasiModal( 0 ); + EndQuasiModal( wxID_OK ); } @@ -1026,6 +1039,6 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - EndQuasiModal( 1 ); + EndQuasiModal( wxID_OK ); } } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp index fa3398448e..a1e8f219ae 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp @@ -280,6 +280,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( mainSizer->Fit( this ); // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnCloseDialog ) ); defaultsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this ); @@ -294,6 +295,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP() { // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnCloseDialog ) ); defaultsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this ); fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this ); fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp index ccd8b6d803..35b3857d29 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp @@ -61,7 +61,7 @@ - + OnCloseDialog diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h index 92fb092691..86bdd61a07 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h @@ -81,6 +81,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public DIALOG_SHIM wxButton* stdDialogButtonSizerCancel; // Virtual event handlers, overide them in your derived class + virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); } virtual void SetInitCmp( wxCommandEvent& event ) { event.Skip(); } virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); } virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index 9e93a66326..10c91b952c 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -60,6 +60,7 @@ public: private: // Events handlers: void OnInitDialog( wxInitDialogEvent& event ); + void OnCloseDialog( wxCloseEvent& event ); void OnListItemDeselected( wxListEvent& event ); void OnListItemSelected( wxListEvent& event ); @@ -146,9 +147,7 @@ void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event ) // frame. Therefore this dialog as a modal frame parent, MUST be run under // quasimodal mode for the quasimodal frame support to work. So don't use // the QUASIMODAL macros here. - int abort = dlg.ShowQuasiModal(); - - if( abort ) + if( dlg.ShowQuasiModal() != wxID_OK ) return; UpdateAliasSelectList(); @@ -216,7 +215,19 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnListItemSelected( wxListEvent& event void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCancelButtonClick( wxCommandEvent& event ) { - EndQuasiModal( 1 ); + EndQuasiModal( wxID_CANCEL ); +} + + +void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCloseDialog( wxCloseEvent& event ) +{ + // On wxWidgets 2.8, and on Linux, call EndQuasiModal here is mandatory + // Otherwise, the main event loop is never restored, and Eeschema does not + // respond to any event, because the DIALOG_SHIM destructor is never called. + // on wxWidgets 3.0, or on Windows, the DIALOG_SHIM destructor is called, + // and calls EndQuasiModal. + // Therefore calling EndQuasiModal here is not mandatory but it creates no issues. + EndQuasiModal( wxID_CANCEL ); } @@ -287,7 +298,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event m_parent->OnModify(); - EndQuasiModal( 0 ); + EndQuasiModal( wxID_OK ); } diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp index 956e092640..e01286ed02 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 5 2013) +// C++ code generated with wxFormBuilder (version Nov 6 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -202,6 +202,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE mainSizer->Fit( this ); // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCloseDialog ) ); this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this ); @@ -216,6 +217,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE() { // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCloseDialog ) ); this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) ); fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this ); fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this ); diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp index 94ef7e29cf..647cfd8e2f 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp @@ -61,7 +61,7 @@ - + OnCloseDialog diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h index fdd0464897..5d90a82f6d 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 5 2013) +// C++ code generated with wxFormBuilder (version Nov 6 2013) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -70,6 +70,7 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public DIALOG_SHIM wxButton* stdDialogButtonSizerCancel; // Virtual event handlers, overide them in your derived class + virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); } virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); } virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); } virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); }