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
This commit is contained in:
jean-pierre charras 2021-02-20 14:06:12 +01:00
parent 5a0a2a8366
commit be25b7a132
5 changed files with 15 additions and 11 deletions

View File

@ -98,7 +98,7 @@ int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
{ {
DIALOG_COPPER_ZONE dlg( aCaller, aSettings ); DIALOG_COPPER_ZONE dlg( aCaller, aSettings );
return dlg.ShowModal(); return dlg.ShowQuasiModal();
} }
#define MIN_THICKNESS ZONE_THICKNESS_MIN_VALUE_MIL*IU_PER_MILS #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 ) 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();
} }

View File

@ -146,7 +146,7 @@ void PCB_BASE_EDIT_FRAME::ShowGraphicItemPropertiesDialog( BOARD_ITEM* aItem )
wxCHECK_RET( aItem != NULL, wxT( "ShowGraphicItemPropertiesDialog() error: NULL item" ) ); wxCHECK_RET( aItem != NULL, wxT( "ShowGraphicItemPropertiesDialog() error: NULL item" ) );
DIALOG_GRAPHIC_ITEM_PROPERTIES dlg( this, aItem ); DIALOG_GRAPHIC_ITEM_PROPERTIES dlg( this, aItem );
dlg.ShowModal(); dlg.ShowQuasiModal();
} }

View File

@ -65,7 +65,7 @@ int InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSetting
{ {
DIALOG_NON_COPPER_ZONES_EDITOR dlg( aParent, aSettings ); DIALOG_NON_COPPER_ZONES_EDITOR dlg( aParent, aSettings );
return dlg.ShowModal(); return dlg.ShowQuasiModal();
} }
#define MIN_THICKNESS 10*IU_PER_MILS #define MIN_THICKNESS 10*IU_PER_MILS

View File

@ -172,13 +172,11 @@ DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES()
} }
/** // Launch the text properties dialog in quasi modal mode.
* Routine for main window class to launch text properties dialog.
*/
void PCB_BASE_EDIT_FRAME::ShowTextPropertiesDialog( BOARD_ITEM* aText ) void PCB_BASE_EDIT_FRAME::ShowTextPropertiesDialog( BOARD_ITEM* aText )
{ {
DIALOG_TEXT_PROPERTIES dlg( this, 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( aEvent.GetKeyCode() == WXK_RETURN && aEvent.ShiftDown() )
{ {
if( TransferDataFromWindow() ) 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() ) else if( m_MultiLineText->IsShown() && m_MultiLineText->HasFocus() )
{ {

View File

@ -170,10 +170,10 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
void PCB_EDIT_FRAME::ShowDimensionPropertiesDialog( DIMENSION_BASE* aDimension ) void PCB_EDIT_FRAME::ShowDimensionPropertiesDialog( DIMENSION_BASE* aDimension )
{ {
if( aDimension == NULL ) if( aDimension == nullptr )
return; return;
DIALOG_DIMENSION_PROPERTIES dlg( this, aDimension ); DIALOG_DIMENSION_PROPERTIES dlg( this, aDimension );
dlg.ShowModal(); dlg.ShowQuasiModal();
} }