Better fix than 86b631b3

This commit is contained in:
jean-pierre charras 2020-12-07 18:28:06 +01:00
parent c7bd8fc987
commit 588fd5e267
3 changed files with 31 additions and 22 deletions

View File

@ -64,6 +64,7 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen
{ {
m_frame = aParent; m_frame = aParent;
m_footprint = aFootprint; m_footprint = aFootprint;
m_returnValue = FP_PROPS_CANCEL;
// Configure display origin transforms // Configure display origin transforms
m_posX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD ); m_posX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD );
@ -202,25 +203,29 @@ DIALOG_FOOTPRINT_PROPERTIES::~DIALOG_FOOTPRINT_PROPERTIES()
void DIALOG_FOOTPRINT_PROPERTIES::EditFootprint( wxCommandEvent& ) 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& ) 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& ) void DIALOG_FOOTPRINT_PROPERTIES::UpdateFootprint( wxCommandEvent& )
{ {
EndModal( FP_PROPS_UPDATE_FP ); m_returnValue = FP_PROPS_UPDATE_FP;
Close();
} }
void DIALOG_FOOTPRINT_PROPERTIES::ChangeFootprint( wxCommandEvent& ) 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 if( m_footprint->GetEditFlags() == 0 ) // i.e. not edited, or moved
commit.Push( _( "Modify footprint properties" ) ); commit.Push( _( "Modify footprint properties" ) );
SetReturnCode( FP_PROPS_OK ); m_returnValue = FP_PROPS_OK;
return true; return true;
} }

View File

@ -40,6 +40,18 @@ class PANEL_PREV_3D;
class DIALOG_FOOTPRINT_PROPERTIES: public DIALOG_FOOTPRINT_PROPERTIES_BASE 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: private:
PCB_EDIT_FRAME* m_frame; PCB_EDIT_FRAME* m_frame;
FOOTPRINT* m_footprint; FOOTPRINT* m_footprint;
@ -67,17 +79,7 @@ private:
bool m_inSelect; bool m_inSelect;
std::vector<bool> m_macHack; std::vector<bool> m_macHack;
enum FP_PROPS_RETVALUE m_returnValue; // the option that closed the dialog
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
};
public: public:
// Constructor and destructor // Constructor and destructor
@ -89,6 +91,9 @@ public:
bool TransferDataToWindow() override; bool TransferDataToWindow() override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
/// @return the value depending on the way the dialog was closed:
enum FP_PROPS_RETVALUE GetReturnValue() { return m_returnValue; }
private: private:
// virtual event functions // virtual event functions
void On3DModelSelected( wxGridEvent& ) override; void On3DModelSelected( wxGridEvent& ) override;

View File

@ -1536,22 +1536,21 @@ void PCB_EDIT_FRAME::ShowFootprintPropertiesDialog( FOOTPRINT* aFootprint )
if( aFootprint == NULL ) if( aFootprint == NULL )
return; 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. // We use quasi modal to allow displaying help dialogs.
int retvalue = dlg->ShowModal(); dlg.ShowQuasiModal();
DIALOG_FOOTPRINT_PROPERTIES::FP_PROPS_RETVALUE retvalue = dlg.GetReturnValue();
/* /*
* retvalue = * retvalue =
* FP_PROPS_UPDATE_FP to show Update Footprints dialog * FP_PROPS_UPDATE_FP to show Update Footprints dialog
* FP_PROPS_CHANGE_FP to show Chanage Footprints dialog * FP_PROPS_CHANGE_FP to show Chanage Footprints dialog
* FP_PROPS_OK for normal edit * 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_BOARD_FP to load board footprint into Footprint Editor
* FP_PROPS_EDIT_LIBRARY_FP to load library 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( retvalue == DIALOG_FOOTPRINT_PROPERTIES::FP_PROPS_OK )
{ {
// If something edited, push a refresh request // If something edited, push a refresh request