From be25b7a132869812c2fef31223afa76f628462f8 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 20 Feb 2021 14:06:12 +0100 Subject: [PATCH] Use ShowQuasiModal to show a few dialogs. This change is mainly due to the fact Modal dialogs do not work when our current tool is the tool used to create new item (text, zone, graphic). If when this tool is active, one try to edit the properties of the new item being created (or being placed) the modal dialog does not capture the event tool and hangs (cannot be dismissed) Our quasi modal dialogs have their own event loop and work. Fixes #7585 https://gitlab.com/kicad/code/kicad/issues/7585 --- pcbnew/dialogs/dialog_copper_zones.cpp | 5 +++-- pcbnew/dialogs/dialog_graphic_item_properties.cpp | 2 +- .../dialogs/dialog_non_copper_zones_properties.cpp | 2 +- pcbnew/dialogs/dialog_text_properties.cpp | 13 ++++++++----- pcbnew/edit.cpp | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index f1a4858fd5..2a0a27742f 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -98,7 +98,7 @@ int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings ) { DIALOG_COPPER_ZONE dlg( aCaller, aSettings ); - return dlg.ShowModal(); + return dlg.ShowQuasiModal(); } #define MIN_THICKNESS ZONE_THICKNESS_MIN_VALUE_MIL*IU_PER_MILS @@ -321,7 +321,8 @@ bool DIALOG_COPPER_ZONE::TransferDataFromWindow() void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event ) { - EndModal( m_settingsExported ? ZONE_EXPORT_VALUES : wxID_CANCEL ); + SetReturnCode( m_settingsExported ? ZONE_EXPORT_VALUES : wxID_CANCEL ); + event.Skip(); } diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index 3b7db19055..e9e905b8a6 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -146,7 +146,7 @@ void PCB_BASE_EDIT_FRAME::ShowGraphicItemPropertiesDialog( BOARD_ITEM* aItem ) wxCHECK_RET( aItem != NULL, wxT( "ShowGraphicItemPropertiesDialog() error: NULL item" ) ); DIALOG_GRAPHIC_ITEM_PROPERTIES dlg( this, aItem ); - dlg.ShowModal(); + dlg.ShowQuasiModal(); } diff --git a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp index 2b7c8cb5ef..b864759262 100644 --- a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp +++ b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp @@ -65,7 +65,7 @@ int InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSetting { DIALOG_NON_COPPER_ZONES_EDITOR dlg( aParent, aSettings ); - return dlg.ShowModal(); + return dlg.ShowQuasiModal(); } #define MIN_THICKNESS 10*IU_PER_MILS diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index eac4fea4b4..14f6d9539a 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -172,13 +172,11 @@ DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES() } -/** - * Routine for main window class to launch text properties dialog. - */ +// Launch the text properties dialog in quasi modal mode. void PCB_BASE_EDIT_FRAME::ShowTextPropertiesDialog( BOARD_ITEM* aText ) { DIALOG_TEXT_PROPERTIES dlg( this, aText ); - dlg.ShowModal(); + dlg.ShowQuasiModal(); } @@ -187,7 +185,12 @@ void DIALOG_TEXT_PROPERTIES::OnCharHook( wxKeyEvent& aEvent ) if( aEvent.GetKeyCode() == WXK_RETURN && aEvent.ShiftDown() ) { if( TransferDataFromWindow() ) - EndModal( wxID_OK ); + { + // Do not use EndModal to close the dialog that can be opened + // in quasi modal mode + SetReturnCode( wxID_OK ); + Close(); + } } else if( m_MultiLineText->IsShown() && m_MultiLineText->HasFocus() ) { diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 75c8d0b8c4..8f17cfbb5c 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -170,10 +170,10 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) void PCB_EDIT_FRAME::ShowDimensionPropertiesDialog( DIMENSION_BASE* aDimension ) { - if( aDimension == NULL ) + if( aDimension == nullptr ) return; DIALOG_DIMENSION_PROPERTIES dlg( this, aDimension ); - dlg.ShowModal(); + dlg.ShowQuasiModal(); }