Don't allow quit while zone filler is running.
Fixes https://gitlab.com/kicad/code/kicad/issues/13551
This commit is contained in:
parent
2f0dee40ea
commit
f0b2902b8c
|
@ -1006,6 +1006,18 @@ bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZONE_FILLER_TOOL* zoneFillerTool = m_toolManager->GetTool<ZONE_FILLER_TOOL>();
|
||||||
|
|
||||||
|
if( zoneFillerTool->IsBusy() )
|
||||||
|
{
|
||||||
|
wxBell();
|
||||||
|
|
||||||
|
if( wxWindow* reporter = dynamic_cast<wxWindow*>( zoneFillerTool->GetProgressReporter() ) )
|
||||||
|
reporter->ShowWithEffect( wxSHOW_EFFECT_EXPAND );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( Kiface().IsSingle() )
|
if( Kiface().IsSingle() )
|
||||||
{
|
{
|
||||||
auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
|
auto* fpEditor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, false );
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2017 CERN
|
* Copyright (C) 2014-2017 CERN
|
||||||
* Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -75,19 +75,20 @@ void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRep
|
||||||
|
|
||||||
BOARD_COMMIT commit( this );
|
BOARD_COMMIT commit( this );
|
||||||
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
||||||
ZONE_FILLER filler( frame()->GetBoard(), &commit );
|
|
||||||
|
m_filler = std::make_unique<ZONE_FILLER>( frame()->GetBoard(), &commit );
|
||||||
|
|
||||||
if( aReporter )
|
if( aReporter )
|
||||||
{
|
{
|
||||||
filler.SetProgressReporter( aReporter );
|
m_filler->SetProgressReporter( aReporter );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reporter = std::make_unique<WX_PROGRESS_REPORTER>( aCaller, _( "Checking Zones" ), 4 );
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( aCaller, _( "Checking Zones" ), 4 );
|
||||||
filler.SetProgressReporter( reporter.get() );
|
m_filler->SetProgressReporter( reporter.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( filler.Fill( toFill, true, aCaller ) )
|
if( m_filler->Fill( toFill, true, aCaller ) )
|
||||||
{
|
{
|
||||||
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
||||||
getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty = false;
|
getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty = false;
|
||||||
|
@ -101,6 +102,7 @@ void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRep
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
m_fillInProgress = false;
|
m_fillInProgress = false;
|
||||||
|
m_filler.reset( nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +130,8 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
|
||||||
|
|
||||||
BOARD_COMMIT commit( this );
|
BOARD_COMMIT commit( this );
|
||||||
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
||||||
ZONE_FILLER filler( board(), &commit );
|
|
||||||
|
m_filler = std::make_unique<ZONE_FILLER>( board(), &commit );
|
||||||
|
|
||||||
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
||||||
{
|
{
|
||||||
|
@ -152,17 +155,17 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
|
||||||
|
|
||||||
if( aReporter )
|
if( aReporter )
|
||||||
{
|
{
|
||||||
filler.SetProgressReporter( aReporter );
|
m_filler->SetProgressReporter( aReporter );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reporter = std::make_unique<WX_PROGRESS_REPORTER>( aCaller, _( "Fill All Zones" ), 5 );
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( aCaller, _( "Fill All Zones" ), 5 );
|
||||||
filler.SetProgressReporter( reporter.get() );
|
m_filler->SetProgressReporter( reporter.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( filler.Fill( toFill ) )
|
if( m_filler->Fill( toFill ) )
|
||||||
{
|
{
|
||||||
filler.GetProgressReporter()->AdvancePhase();
|
m_filler->GetProgressReporter()->AdvancePhase();
|
||||||
|
|
||||||
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
||||||
frame->m_ZoneFillsDirty = false;
|
frame->m_ZoneFillsDirty = false;
|
||||||
|
@ -175,10 +178,11 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
|
||||||
rebuildConnectivity();
|
rebuildConnectivity();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
if( filler.IsDebug() )
|
if( m_filler->IsDebug() )
|
||||||
frame->UpdateUserInterface();
|
frame->UpdateUserInterface();
|
||||||
|
|
||||||
m_fillInProgress = false;
|
m_fillInProgress = false;
|
||||||
|
m_filler.reset( nullptr );
|
||||||
|
|
||||||
// wxWidgets has keyboard focus issues after the progress reporter. Re-setting the focus
|
// wxWidgets has keyboard focus issues after the progress reporter. Re-setting the focus
|
||||||
// here doesn't work, so we delay it to an idle event.
|
// here doesn't work, so we delay it to an idle event.
|
||||||
|
@ -212,9 +216,10 @@ int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
BOARD_COMMIT commit( this );
|
BOARD_COMMIT commit( this );
|
||||||
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
||||||
ZONE_FILLER filler( board(), &commit );
|
|
||||||
int pts = 0;
|
int pts = 0;
|
||||||
|
|
||||||
|
m_filler = std::make_unique<ZONE_FILLER>( board(), &commit );
|
||||||
|
|
||||||
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
||||||
{
|
{
|
||||||
WX_INFOBAR* infobar = frame->GetInfoBar();
|
WX_INFOBAR* infobar = frame->GetInfoBar();
|
||||||
|
@ -245,12 +250,12 @@ int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent )
|
||||||
wxString title = wxString::Format( _( "Refill %d Zones" ), (int) toFill.size() );
|
wxString title = wxString::Format( _( "Refill %d Zones" ), (int) toFill.size() );
|
||||||
|
|
||||||
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame, title, 5 );
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame, title, 5 );
|
||||||
filler.SetProgressReporter( reporter.get() );
|
m_filler->SetProgressReporter( reporter.get() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( filler.Fill( toFill ) )
|
if( m_filler->Fill( toFill ) )
|
||||||
commit.Push( _( "Auto-fill Zone(s)" ), APPEND_UNDO | SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
commit.Push( _( "Auto-fill Zone(s)" ), APPEND_UNDO | SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
||||||
else
|
else
|
||||||
commit.Revert();
|
commit.Revert();
|
||||||
|
@ -279,10 +284,11 @@ int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent )
|
||||||
10000, wxICON_INFORMATION, WX_INFOBAR::MESSAGE_TYPE::GENERIC );
|
10000, wxICON_INFORMATION, WX_INFOBAR::MESSAGE_TYPE::GENERIC );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( filler.IsDebug() )
|
if( m_filler->IsDebug() )
|
||||||
frame->UpdateUserInterface();
|
frame->UpdateUserInterface();
|
||||||
|
|
||||||
m_fillInProgress = false;
|
m_fillInProgress = false;
|
||||||
|
m_filler.reset( nullptr );
|
||||||
|
|
||||||
// wxWidgets has keyboard focus issues after the progress reporter. Re-setting the focus
|
// wxWidgets has keyboard focus issues after the progress reporter. Re-setting the focus
|
||||||
// here doesn't work, so we delay it to an idle event.
|
// here doesn't work, so we delay it to an idle event.
|
||||||
|
@ -319,12 +325,13 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
BOARD_COMMIT commit( this );
|
BOARD_COMMIT commit( this );
|
||||||
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
||||||
ZONE_FILLER filler( board(), &commit );
|
|
||||||
|
m_filler = std::make_unique<ZONE_FILLER>( board(), &commit );
|
||||||
|
|
||||||
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill Zone" ), 5 );
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill Zone" ), 5 );
|
||||||
filler.SetProgressReporter( reporter.get() );
|
m_filler->SetProgressReporter( reporter.get() );
|
||||||
|
|
||||||
if( filler.Fill( toFill ) )
|
if( m_filler->Fill( toFill ) )
|
||||||
{
|
{
|
||||||
reporter->AdvancePhase();
|
reporter->AdvancePhase();
|
||||||
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
||||||
|
@ -338,6 +345,7 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
m_fillInProgress = false;
|
m_fillInProgress = false;
|
||||||
|
m_filler.reset( nullptr );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,6 +399,15 @@ int ZONE_FILLER_TOOL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PROGRESS_REPORTER* ZONE_FILLER_TOOL::GetProgressReporter()
|
||||||
|
{
|
||||||
|
if( m_fillInProgress && m_filler )
|
||||||
|
return m_filler->GetProgressReporter();
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ZONE_FILLER_TOOL::rebuildConnectivity()
|
void ZONE_FILLER_TOOL::rebuildConnectivity()
|
||||||
{
|
{
|
||||||
board()->BuildConnectivity();
|
board()->BuildConnectivity();
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
class PCB_EDIT_FRAME;
|
class PCB_EDIT_FRAME;
|
||||||
class PROGRESS_REPORTER;
|
class PROGRESS_REPORTER;
|
||||||
class WX_PROGRESS_REPORTER;
|
class WX_PROGRESS_REPORTER;
|
||||||
|
class ZONE_FILLER;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,6 +60,8 @@ public:
|
||||||
|
|
||||||
bool IsBusy() { return m_fillInProgress; }
|
bool IsBusy() { return m_fillInProgress; }
|
||||||
|
|
||||||
|
PROGRESS_REPORTER* GetProgressReporter();
|
||||||
|
|
||||||
void DirtyZone( ZONE* aZone )
|
void DirtyZone( ZONE* aZone )
|
||||||
{
|
{
|
||||||
m_dirtyZoneIDs.insert( aZone->m_Uuid );
|
m_dirtyZoneIDs.insert( aZone->m_Uuid );
|
||||||
|
@ -77,9 +80,10 @@ private:
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_fillInProgress;
|
std::unique_ptr<ZONE_FILLER> m_filler;
|
||||||
|
bool m_fillInProgress;
|
||||||
|
|
||||||
std::set<KIID> m_dirtyZoneIDs;
|
std::set<KIID> m_dirtyZoneIDs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue