Move ERC dialog to EE_INSPECTION_TOOL and kill when resetting.

Fixes https://gitlab.com/kicad/code/kicad/issues/6111
This commit is contained in:
Jeff Young 2020-11-03 19:24:05 +00:00
parent 4be6a27a39
commit 5507575d64
6 changed files with 36 additions and 24 deletions

View File

@ -52,7 +52,7 @@
#include <kiplatform/ui.h>
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
DIALOG_ERC_BASE( parent, ID_DIALOG_ERC ), // parent looks for this ID explicitly
DIALOG_ERC_BASE( parent ),
PROGRESS_REPORTER( 1 ),
m_parent( parent ),
m_running( false ),
@ -745,12 +745,3 @@ bool DIALOG_ERC::writeReport( const wxString& aFullFileName )
}
wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller )
{
// This is a modeless dialog, so new it rather than instantiating on stack.
DIALOG_ERC* dlg = new DIALOG_ERC( aCaller );
dlg->Show( true );
return dlg; // wxDialog is information hiding about DIALOG_ERC.
}

View File

@ -58,6 +58,7 @@
#include <wildcards_and_files_ext.h>
#include <page_layout/ws_data_model.h>
#include <wx/stdpaths.h>
#include <tools/ee_inspection_tool.h>
bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName )
{
@ -278,6 +279,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
// unload current project file before loading new
{
SetScreen( nullptr );
m_toolManager->GetTool<EE_INSPECTION_TOOL>()->Reset( TOOL_BASE::MODEL_RELOAD );
CreateScreens();
}

View File

@ -70,10 +70,6 @@ class SCH_EDIT_FRAME;
int InvokeDialogRescueEach( wxWindow* aParent, RESCUER& aRescuer, SCH_SHEET_PATH* aCurrentSheet,
EDA_DRAW_PANEL_GAL::GAL_TYPE aGalBackEndType, bool aAskShowAgain );
/// Create the modeless DIALOG_ERC and show it, return something to
/// destroy or close it. The dialog will have ID_DIALOG_ERC from id.h
wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller );
/// Create and show DIALOG_PRINT_USING_PRINTER and return whatever
/// DIALOG_PRINT_USING_PRINTER::ShowModal() returns.
int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller );

View File

@ -41,11 +41,13 @@
#include <invoke_sch_dialog.h>
#include <project.h>
#include <dialogs/dialog_display_info_HTML_base.h>
#include <dialogs/dialog_erc.h>
#include <math/util.h> // for KiROUND
EE_INSPECTION_TOOL::EE_INSPECTION_TOOL()
: EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.InspectionTool" )
EE_INSPECTION_TOOL::EE_INSPECTION_TOOL() :
EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.InspectionTool" ),
m_ercDialog( nullptr )
{
}
@ -67,6 +69,20 @@ bool EE_INSPECTION_TOOL::Init()
}
void EE_INSPECTION_TOOL::Reset( RESET_REASON aReason )
{
EE_TOOL_BASE::Reset( aReason );
if( aReason == MODEL_RELOAD )
{
if( m_ercDialog )
m_ercDialog->Destroy();
m_ercDialog = nullptr;
}
}
int EE_INSPECTION_TOOL::RunERC( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
@ -75,17 +91,20 @@ int EE_INSPECTION_TOOL::RunERC( const TOOL_EVENT& aEvent )
}
else if( m_frame->IsType( FRAME_SCH ) )
{
wxWindow* erc = wxWindow::FindWindowById( ID_DIALOG_ERC, m_frame );
if( erc )
if( m_ercDialog )
{
// Needed at least on Windows. Raise() is not enough
erc->Show( true );
m_ercDialog->Show( true );
// Bring it to the top if already open. Dual monitor users need this.
erc->Raise();
m_ercDialog->Raise();
}
else
InvokeDialogERC( static_cast<SCH_EDIT_FRAME*>( m_frame ) );
{
// This is a modeless dialog, so new it rather than instantiating on stack.
m_ercDialog = new DIALOG_ERC( static_cast<SCH_EDIT_FRAME*>( m_frame ) );
m_ercDialog->Show( true );
}
}
return 0;

View File

@ -32,6 +32,7 @@
class EE_SELECTION_TOOL;
class SCH_BASE_FRAME;
class DIALOG_ERC;
class EE_INSPECTION_TOOL : public EE_TOOL_BASE<SCH_BASE_FRAME>
@ -43,6 +44,8 @@ public:
/// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override;
void Reset( RESET_REASON aReason ) override;
int RunERC( const TOOL_EVENT& aEvent );
int RunSimulation( const TOOL_EVENT& aEvent );
@ -55,6 +58,9 @@ private:
///> @copydoc TOOL_INTERACTIVE::setTransitions();
void setTransitions() override;
private:
DIALOG_ERC* m_ercDialog;
};
#endif /* EE_INSPECTION_TOOL_H */

View File

@ -181,8 +181,6 @@ enum main_id
ID_EDA_SOCKET_EVENT_SERV,
ID_EDA_SOCKET_EVENT,
ID_DIALOG_ERC, ///< eeschema ERC modeless dialog ID
// IDs specifics to a sub-application (Eeschema, Kicad manager....) start here
//
// We reserve here Ids for each sub-application, to avoid duplicate IDs