Handle quit uniformly in COMMON_CONTROL.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22659

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22660
This commit is contained in:
Jeff Young
2026-01-06 17:00:32 +00:00
parent 46f9b822f1
commit 1f2caa041d
12 changed files with 19 additions and 153 deletions
-8
View File
@@ -48,15 +48,7 @@ int BITMAP2CMP_CONTROL::Open( const TOOL_EVENT& aEvent )
}
int BITMAP2CMP_CONTROL::Close( const TOOL_EVENT& aEvent )
{
m_frame->Close();
return 0;
}
void BITMAP2CMP_CONTROL::setTransitions()
{
Go( &BITMAP2CMP_CONTROL::Open, ACTIONS::open.MakeEvent() );
Go( &BITMAP2CMP_CONTROL::Close, ACTIONS::quit.MakeEvent() );
}
+14
View File
@@ -190,6 +190,18 @@ int COMMON_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
}
int COMMON_CONTROL::Quit( const TOOL_EVENT& aEvent )
{
m_frame->CallAfter(
[this]()
{
m_frame->Kiway().OnKiCadExit();
} );
return 0;
}
class TERMINATE_HANDLER : public wxProcess
{
public:
@@ -414,6 +426,8 @@ int COMMON_CONTROL::ReportBug( const TOOL_EVENT& aEvent )
void COMMON_CONTROL::setTransitions()
{
Go( &COMMON_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
Go( &COMMON_CONTROL::OpenPreferences, ACTIONS::openPreferences.MakeEvent() );
Go( &COMMON_CONTROL::ConfigurePaths, ACTIONS::configurePaths.MakeEvent() );
Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showSymbolLibTable.MakeEvent() );
-8
View File
@@ -648,13 +648,6 @@ int SCH_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent )
}
int SCH_EDITOR_CONTROL::Quit( const TOOL_EVENT& aEvent )
{
m_frame->Close( false );
return 0;
}
int SCH_EDITOR_CONTROL::CrossProbeToPcb( const TOOL_EVENT& aEvent )
{
doCrossProbeSchToPcb( aEvent, false );
@@ -3514,7 +3507,6 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::PageSetup, ACTIONS::pageSettings.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::RescueSymbols, SCH_ACTIONS::rescueSymbols.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::RemapSymbols, SCH_ACTIONS::remapSymbols.MakeEvent() );
-2
View File
@@ -651,8 +651,6 @@ void SIMULATOR_CONTROL::setTransitions()
Go( &SIMULATOR_CONTROL::ExportPlotToClipboard, SCH_ACTIONS::exportPlotToClipboard.MakeEvent() );
Go( &SIMULATOR_CONTROL::ExportPlotToSchematic, SCH_ACTIONS::exportPlotToSchematic.MakeEvent() );
Go( &SIMULATOR_CONTROL::Close, ACTIONS::quit.MakeEvent() );
Go( &SIMULATOR_CONTROL::ToggleSimConsolePanel, SCH_ACTIONS::toggleSimConsole.MakeEvent() );
Go( &SIMULATOR_CONTROL::ToggleSimSidePanel, SCH_ACTIONS::toggleSimSidePanel.MakeEvent() );
-2
View File
@@ -987,7 +987,6 @@ int SYMBOL_EDITOR_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
void SYMBOL_EDITOR_CONTROL::setTransitions()
{
// clang-format off
Go( &SYMBOL_EDITOR_CONTROL::AddLibrary, ACTIONS::newLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::AddLibrary, ACTIONS::addLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::AddSymbol, SCH_ACTIONS::newSymbol.MakeEvent() );
@@ -1036,5 +1035,4 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
Go( &SYMBOL_EDITOR_CONTROL::ChangeUnit, SCH_ACTIONS::previousUnit.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ChangeUnit, SCH_ACTIONS::nextUnit.MakeEvent() );
// clang-format on
}
+1
View File
@@ -50,6 +50,7 @@ public:
int ShowLibraryTable( const TOOL_EVENT& aEvent );
int ShowPlayer( const TOOL_EVENT& aEvent );
int Quit( const TOOL_EVENT& aEvent );
int Execute( const TOOL_EVENT& aEvent );
int ShowProjectManager( const TOOL_EVENT& aEvent );
-1
View File
@@ -11,7 +11,6 @@ set( PCB_CALCULATOR_SRCS
common_data.cpp
eseries.cpp
params_read_write.cpp
pcb_calculator_control.cpp
pcb_calculator_frame.cpp
pcb_calculator_settings.cpp
datafile_read_write.cpp
-54
View File
@@ -1,54 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <kiway.h>
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <pcb_calculator_frame.h>
#include <pcb_calculator_control.h>
bool PCB_CALCULATOR_CONTROL::Init()
{
Reset( MODEL_RELOAD );
return true;
}
void PCB_CALCULATOR_CONTROL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<PCB_CALCULATOR_FRAME>();
}
int PCB_CALCULATOR_CONTROL::Close( const TOOL_EVENT& aEvent )
{
m_frame->Close();
return 0;
}
void PCB_CALCULATOR_CONTROL::setTransitions()
{
Go( &PCB_CALCULATOR_CONTROL::Close, ACTIONS::quit.MakeEvent() );
}
-63
View File
@@ -1,63 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef PCB_CALCULATOR_CONTROL_H
#define PCB_CALCULATOR_CONTROL_H
#include "tool/tool_interactive.h"
class PCB_CALCULATOR_FRAME;
/**
* Handle actions for the various symbol editor and viewers.
*/
class PCB_CALCULATOR_CONTROL : public wxEvtHandler, public TOOL_INTERACTIVE
{
public:
PCB_CALCULATOR_CONTROL() :
TOOL_INTERACTIVE( "pcb_calculator.Control" ),
m_frame( nullptr )
{ }
virtual ~PCB_CALCULATOR_CONTROL() { }
/// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override;
/// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override;
int Close( const TOOL_EVENT& aEvent );
private:
///< Set up handlers for various events.
void setTransitions() override;
private:
PCB_CALCULATOR_FRAME* m_frame;
};
#endif // PCB_CALCULATOR_CONTROL_H
+1 -7
View File
@@ -34,7 +34,6 @@
#include <attenuators/attenuator_classes.h>
#include <pcb_calculator_frame.h>
#include <pcb_calculator_settings.h>
#include <pcb_calculator_control.h>
#include <calculator_panels/panel_rf_attenuators.h>
#include <calculator_panels/panel_board_class.h>
@@ -109,7 +108,6 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Register tools
m_toolManager->RegisterTool( new COMMON_CONTROL );
m_toolManager->RegisterTool( new PCB_CALCULATOR_CONTROL );
m_toolManager->InitTools();
ReCreateMenuBar();
@@ -155,11 +153,7 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
void PCB_CALCULATOR_FRAME::OnExit( wxCommandEvent& aEvent )
{
if( aEvent.GetId() == wxID_EXIT )
Kiway().OnKiCadExit();
if( aEvent.GetId() == wxID_CLOSE || Kiface().IsSingle() )
Close( false );
Close( false );
}
+2
View File
@@ -51,6 +51,7 @@
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
#include <tool/common_tools.h>
#include <tool/common_control.h>
#include <tools/pcb_selection_tool.h>
#include <tools/pcb_control.h>
#include <tools/pcb_actions.h>
@@ -146,6 +147,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
m_toolManager->RegisterTool( new PCB_SELECTION_TOOL ); // for std context menus (zoom & grid)
m_toolManager->RegisterTool( new SCRIPTING_TOOL );
m_toolManager->RegisterTool( new COMMON_TOOLS );
m_toolManager->RegisterTool( new COMMON_CONTROL );
m_toolManager->RegisterTool( new FOOTPRINT_WIZARD_TOOLS );
m_toolManager->InitTools();
+1 -8
View File
@@ -27,6 +27,7 @@
#include "convert_basic_shapes_to_polygon.h"
#include <kiplatform/ui.h>
#include <kiway.h>
#include <tools/edit_tool.h>
#include <tools/board_inspection_tool.h>
#include <router/router_tool.h>
@@ -201,13 +202,6 @@ int PCB_CONTROL::IterateFootprint( const TOOL_EVENT& aEvent )
}
int PCB_CONTROL::Quit( const TOOL_EVENT& aEvent )
{
m_frame->Close( false );
return 0;
}
template<class T>
void Flip( T& aValue )
{
@@ -2833,7 +2827,6 @@ void PCB_CONTROL::setTransitions()
Go( &PCB_CONTROL::AddLibrary, ACTIONS::newLibrary.MakeEvent() );
Go( &PCB_CONTROL::AddLibrary, ACTIONS::addLibrary.MakeEvent() );
Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
// Footprint library actions
Go( &PCB_CONTROL::SaveFpToBoard, PCB_ACTIONS::saveFpToBoard.MakeEvent() );