diff --git a/pcbnew/dialogs/dialog_footprint_properties.cpp b/pcbnew/dialogs/dialog_footprint_properties.cpp index 064e23c685..e6cd70a61b 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties.cpp @@ -64,6 +64,7 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen { m_frame = aParent; m_footprint = aFootprint; + m_returnValue = FP_PROPS_CANCEL; // Configure display origin transforms m_posX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD ); @@ -202,25 +203,29 @@ DIALOG_FOOTPRINT_PROPERTIES::~DIALOG_FOOTPRINT_PROPERTIES() void DIALOG_FOOTPRINT_PROPERTIES::EditFootprint( wxCommandEvent& ) { - EndModal( FP_PROPS_EDIT_BOARD_FP ); + m_returnValue = FP_PROPS_EDIT_BOARD_FP; + Close(); } void DIALOG_FOOTPRINT_PROPERTIES::EditLibraryFootprint( wxCommandEvent& ) { - EndModal( FP_PROPS_EDIT_LIBRARY_FP ); + m_returnValue = FP_PROPS_EDIT_LIBRARY_FP; + Close(); } void DIALOG_FOOTPRINT_PROPERTIES::UpdateFootprint( wxCommandEvent& ) { - EndModal( FP_PROPS_UPDATE_FP ); + m_returnValue = FP_PROPS_UPDATE_FP; + Close(); } void DIALOG_FOOTPRINT_PROPERTIES::ChangeFootprint( wxCommandEvent& ) { - EndModal( FP_PROPS_CHANGE_FP ); + m_returnValue = FP_PROPS_CHANGE_FP; + Close(); } @@ -754,7 +759,7 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow() if( m_footprint->GetEditFlags() == 0 ) // i.e. not edited, or moved commit.Push( _( "Modify footprint properties" ) ); - SetReturnCode( FP_PROPS_OK ); + m_returnValue = FP_PROPS_OK; return true; } diff --git a/pcbnew/dialogs/dialog_footprint_properties.h b/pcbnew/dialogs/dialog_footprint_properties.h index 77b379e18f..8e383db96b 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.h +++ b/pcbnew/dialogs/dialog_footprint_properties.h @@ -40,6 +40,18 @@ class PANEL_PREV_3D; class DIALOG_FOOTPRINT_PROPERTIES: public DIALOG_FOOTPRINT_PROPERTIES_BASE { +public: + // The dialog can be closed for several reasons. + enum FP_PROPS_RETVALUE + { + FP_PROPS_CANCEL, + FP_PROPS_UPDATE_FP, + FP_PROPS_CHANGE_FP, + FP_PROPS_OK, + FP_PROPS_EDIT_BOARD_FP, + FP_PROPS_EDIT_LIBRARY_FP + }; + private: PCB_EDIT_FRAME* m_frame; FOOTPRINT* m_footprint; @@ -67,17 +79,7 @@ private: bool m_inSelect; std::vector m_macHack; - -public: - // The dialog can be closed for several reasons. - enum FP_PROPS_RETVALUE - { - FP_PROPS_UPDATE_FP, - FP_PROPS_CHANGE_FP, - FP_PROPS_OK, - FP_PROPS_EDIT_BOARD_FP, - FP_PROPS_EDIT_LIBRARY_FP - }; + enum FP_PROPS_RETVALUE m_returnValue; // the option that closed the dialog public: // Constructor and destructor @@ -89,6 +91,9 @@ public: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + /// @return the value depending on the way the dialog was closed: + enum FP_PROPS_RETVALUE GetReturnValue() { return m_returnValue; } + private: // virtual event functions void On3DModelSelected( wxGridEvent& ) override; diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 9c4b97b0f2..9afda10be7 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1536,22 +1536,21 @@ void PCB_EDIT_FRAME::ShowFootprintPropertiesDialog( FOOTPRINT* aFootprint ) if( aFootprint == NULL ) return; - DIALOG_FOOTPRINT_PROPERTIES* dlg = new DIALOG_FOOTPRINT_PROPERTIES( this, aFootprint ); + DIALOG_FOOTPRINT_PROPERTIES dlg( this, aFootprint ); - // Must be modal because we destroy the dialog on return. - int retvalue = dlg->ShowModal(); + // We use quasi modal to allow displaying help dialogs. + dlg.ShowQuasiModal(); + DIALOG_FOOTPRINT_PROPERTIES::FP_PROPS_RETVALUE retvalue = dlg.GetReturnValue(); /* * retvalue = * FP_PROPS_UPDATE_FP to show Update Footprints dialog * FP_PROPS_CHANGE_FP to show Chanage Footprints dialog * FP_PROPS_OK for normal edit + * FP_PROPS_CANCEL if aborted * FP_PROPS_EDIT_BOARD_FP to load board footprint into Footprint Editor * FP_PROPS_EDIT_LIBRARY_FP to load library footprint into Footprint Editor */ - dlg->Close(); - dlg->Destroy(); - if( retvalue == DIALOG_FOOTPRINT_PROPERTIES::FP_PROPS_OK ) { // If something edited, push a refresh request