Re-initialize conversion settings on failure

When the conversion fails, it may be the result of the settings values,
so reset them to their original values afterward

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17886
This commit is contained in:
Seth Hillbrand 2024-05-05 07:41:32 -07:00
parent 0476b6c72d
commit 4c0fd6e791
2 changed files with 19 additions and 4 deletions

View File

@ -235,10 +235,7 @@ CONVERT_TOOL::CONVERT_TOOL() :
m_menu( nullptr ),
m_frame( nullptr )
{
m_userSettings.m_Strategy = CENTERLINE;
m_userSettings.m_Gap = 0;
m_userSettings.m_LineWidth = 0;
m_userSettings.m_DeleteOriginals = true;
initUserSettings();
}
@ -319,6 +316,15 @@ bool CONVERT_TOOL::Init()
}
void CONVERT_TOOL::initUserSettings()
{
m_userSettings.m_Strategy = CENTERLINE;
m_userSettings.m_Gap = 0;
m_userSettings.m_LineWidth = 0;
m_userSettings.m_DeleteOriginals = true;
}
int CONVERT_TOOL::CreatePolys( const TOOL_EVENT& aEvent )
{
BOARD_DESIGN_SETTINGS& bds = m_frame->GetBoard()->GetDesignSettings();
@ -400,6 +406,8 @@ int CONVERT_TOOL::CreatePolys( const TOOL_EVENT& aEvent )
showCopyLineWidth = false;
}
CONVERT_SETTINGS previousSettings = m_userSettings;
CONVERT_SETTINGS_DIALOG dlg( m_frame, &m_userSettings, showCopyLineWidth, true, true );
if( dlg.ShowModal() != wxID_OK )
@ -429,6 +437,8 @@ int CONVERT_TOOL::CreatePolys( const TOOL_EVENT& aEvent )
msg = _( "Objects must form a closed shape" );
DisplayErrorMessage( m_frame, _( "Could not convert selection" ), msg );
m_userSettings = previousSettings;
return 0;
}

View File

@ -96,6 +96,11 @@ private:
SHAPE_POLY_SET makePolysFromClosedGraphics( const std::deque<EDA_ITEM*>& aItems,
CONVERT_STRATEGY aStrategy );
/**
* Initialize the user settings for the tool.
*/
void initUserSettings();
private:
PCB_SELECTION_TOOL* m_selectionTool;
CONDITIONAL_MENU* m_menu;