Upgrade ShowPlayer re-entrancy guard (KICAD-XAC).

This commit is contained in:
Jeff Young 2025-07-10 16:49:04 +01:00
parent fa00626512
commit 53c90b0469
16 changed files with 71 additions and 71 deletions

View File

@ -209,7 +209,7 @@ void DIALOG_DESIGN_BLOCK_PROPERTIES::OnMoveFieldDown( wxCommandEvent& event )
bool DIALOG_DESIGN_BLOCK_PROPERTIES::TransferDataToGrid()
{
m_fieldsGrid->Freeze();
WINDOW_FREEZER raiiFreezer( m_fieldsGrid );
m_fieldsGrid->ClearRows();
m_fieldsGrid->AppendRows( m_fields.size() );
@ -228,8 +228,6 @@ bool DIALOG_DESIGN_BLOCK_PROPERTIES::TransferDataToGrid()
row++;
}
m_fieldsGrid->Thaw();
return true;
}

View File

@ -25,6 +25,7 @@
#include <dialogs/panel_embedded_files.h>
#include <embedded_files.h>
#include <font/outline_font.h>
#include <core/raii.h>
#include <kidialog.h>
#include <widgets/std_bitmap_button.h>
#include <widgets/wx_grid.h>
@ -213,7 +214,8 @@ bool PANEL_EMBEDDED_FILES::TransferDataFromWindow()
void PANEL_EMBEDDED_FILES::onFontEmbedClick( wxCommandEvent& event )
{
Freeze();
WINDOW_FREEZER raiiFreezer( this );
int row_pos = m_files_grid->GetGridCursorRow();
int col_pos = m_files_grid->GetGridCursorCol();
wxString row_name;
@ -272,8 +274,6 @@ void PANEL_EMBEDDED_FILES::onFontEmbedClick( wxCommandEvent& event )
}
}
}
Thaw();
}

View File

@ -118,7 +118,8 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA
m_membershipPane->SetBorders( true, false, false, false );
// Prevent Size events from firing before we are ready
Freeze();
WINDOW_FREEZER raiiFreezer( this );
m_netclassGrid->BeginBatch();
m_netclassGrid->SetUseNativeColLabels();
m_assignmentGrid->BeginBatch();
@ -236,7 +237,6 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA
m_netclassGrid->EndBatch();
m_assignmentGrid->EndBatch();
Thaw();
Bind( wxEVT_IDLE,
[this]( wxIdleEvent& aEvent )

View File

@ -24,6 +24,7 @@
#include <string_utils.h>
#include <wx/clipbrd.h>
#include <core/kicad_algo.h>
#include <core/raii.h>
SEARCH_PANE_LISTVIEW::SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler, wxWindow* parent,
wxWindowID winid, const wxPoint& pos,
@ -203,7 +204,8 @@ std::vector<long> SEARCH_PANE_LISTVIEW::Sort()
void SEARCH_PANE_LISTVIEW::RefreshColumnNames()
{
Freeze();
WINDOW_FREEZER raiiFreezer( this );
DeleteAllColumns();
std::vector<std::tuple<wxString, int, wxListColumnFormat>> columns = m_handler->GetColumns();
@ -215,8 +217,6 @@ void SEARCH_PANE_LISTVIEW::RefreshColumnNames()
for( int ii = 0; ii < (int) columns.size(); ++ii )
SetColumnWidth( ii, widthUnit * std::get<1>( columns[ ii ] ) );
Thaw();
}

View File

@ -585,7 +585,7 @@ void WIDGET_HOTKEY_LIST::ApplyFilterString( const wxString& aFilterStr )
void WIDGET_HOTKEY_LIST::ResetAllHotkeys( bool aResetToDefault )
{
Freeze();
WINDOW_FREEZER raiiFreezer( this );
// Reset all the hotkeys, not just the ones shown
// Should not need to check conflicts, as the state we're about
@ -597,8 +597,6 @@ void WIDGET_HOTKEY_LIST::ResetAllHotkeys( bool aResetToDefault )
updateFromClientData();
updateColumnWidths();
Thaw();
}
@ -633,7 +631,8 @@ void WIDGET_HOTKEY_LIST::updateColumnWidths()
void WIDGET_HOTKEY_LIST::updateShownItems( const wxString& aFilterStr )
{
Freeze();
WINDOW_FREEZER raiiFreezer( this );
DeleteAllItems();
HOTKEY_FILTER filter( aFilterStr );
@ -656,7 +655,6 @@ void WIDGET_HOTKEY_LIST::updateShownItems( const wxString& aFilterStr )
}
updateFromClientData();
Thaw();
}

View File

@ -1014,14 +1014,14 @@ void DIALOG_ERC::deleteAllMarkers( bool aIncludeExclusions )
// Clear current selection list to avoid selection of deleted items
// Freeze to avoid repainting the dialog, which can cause a RePaint()
// of the screen as well
Freeze();
WINDOW_FREEZER raiiFreezer( this );
m_parent->GetToolManager()->RunAction( ACTIONS::selectionClear );
m_markerTreeModel->DeleteItems( false, aIncludeExclusions, false );
SCH_SCREENS screens( m_parent->Schematic().Root() );
screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC, aIncludeExclusions );
Thaw();
}

View File

@ -22,6 +22,7 @@
#include <wx/log.h>
#include <core/profile.h>
#include <core/raii.h>
#include <tool/tool_manager.h>
#include <kiface_base.h>
#include <sch_edit_frame.h>
@ -305,9 +306,8 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect
bool singleSheetSchematic = m_schematic->Hierarchy().size() == 1;
size_t nodeCnt = 0;
m_netNavigator->Freeze();
PROF_TIMER timer;
WINDOW_FREEZER raiiFreezer( m_netNavigator );
PROF_TIMER timer;
if( m_highlightedConn.IsEmpty() )
{
@ -375,8 +375,6 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect
wxLogTrace( traceUiProfile, wxS( "Adding %zu nodes to net navigator took %s." ),
nodeCnt, timer.to_string() );
m_netNavigator->Thaw();
}

View File

@ -24,6 +24,7 @@
*/
#include <bitmaps.h>
#include <core/raii.h>
#include <sch_edit_frame.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
@ -210,7 +211,7 @@ void HIERARCHY_PANE::UpdateHierarchySelection()
void HIERARCHY_PANE::UpdateHierarchyTree( bool aClear )
{
Freeze();
WINDOW_FREEZER raiiFreezer( this );
bool eventsWereBound = m_events_bound;
@ -302,8 +303,6 @@ void HIERARCHY_PANE::UpdateHierarchyTree( bool aClear )
m_events_bound = true;
}
Thaw();
}

View File

@ -666,8 +666,10 @@ void PROJECT_TREE_PANE::ReCreateTreePrj()
if( !m_TreeProject )
m_TreeProject = new PROJECT_TREE( this );
else
m_TreeProject->DeleteAllItems();
WINDOW_FREEZER raiiFreezer( m_TreeProject );
m_TreeProject->DeleteAllItems();
if( !pro_dir ) // This is empty from PROJECT_TREE_PANE constructor
return;
@ -723,8 +725,8 @@ void PROJECT_TREE_PANE::ReCreateTreePrj()
m_TreeProject->SetItemBold( m_root, true );
// The main project file is now a JSON file
PROJECT_TREE_ITEM* data = new PROJECT_TREE_ITEM( TREE_FILE_TYPE::JSON_PROJECT,
fn.GetFullPath(), m_TreeProject );
PROJECT_TREE_ITEM* data = new PROJECT_TREE_ITEM( TREE_FILE_TYPE::JSON_PROJECT, fn.GetFullPath(),
m_TreeProject );
m_TreeProject->SetItemData( m_root, data );
@ -765,12 +767,13 @@ void PROJECT_TREE_PANE::ReCreateTreePrj()
// Sort filenames by alphabetic order
m_TreeProject->SortChildren( m_root );
CallAfter( [this] ()
{
wxLogTrace( traceGit, "PROJECT_TREE_PANE::ReCreateTreePrj: starting timers" );
m_gitSyncTimer.Start( 100, wxTIMER_ONE_SHOT );
m_gitStatusTimer.Start( 500, wxTIMER_ONE_SHOT );
} );
CallAfter(
[this] ()
{
wxLogTrace( traceGit, "PROJECT_TREE_PANE::ReCreateTreePrj: starting timers" );
m_gitSyncTimer.Start( 100, wxTIMER_ONE_SHOT );
m_gitStatusTimer.Start( 500, wxTIMER_ONE_SHOT );
} );
}
@ -1613,6 +1616,8 @@ void PROJECT_TREE_PANE::EmptyTreePrj()
// Make sure we don't try to inspect the tree after we've deleted its items.
shutdownFileWatcher();
m_TreeProject->Freeze();
m_TreeProject->DeleteAllItems();
// Remove the git repository when the project is unloaded
@ -1625,13 +1630,8 @@ void PROJECT_TREE_PANE::EmptyTreePrj()
{
// Block until any in-flight Git actions complete, showing a pulsing progress dialog
{
wxProgressDialog progress(
_("Please wait"),
_("Waiting for Git operations to finish..."),
100,
this,
wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_SMOOTH
);
wxProgressDialog progress( _( "Please wait" ), _( "Waiting for Git operations to finish..." ),
100, this, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_SMOOTH );
// Keep trying to acquire the lock, pulsing the dialog every 100 ms
while ( !lock.try_lock() )

View File

@ -82,6 +82,26 @@ protected:
};
// Temporarily freeze a window, and then un-freeze on destruction
class WINDOW_FREEZER
{
public:
WINDOW_FREEZER( wxWindow* aWindow )
{
m_window = aWindow;
m_window->Freeze();
}
~WINDOW_FREEZER()
{
m_window->Thaw();
}
protected:
wxWindow* m_window;
};
/// Temporarily disable a window, and then re-enable on destruction.
class WINDOW_DISABLER
{

View File

@ -149,7 +149,7 @@ int PL_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
PL_SELECTION& selection = selTool->GetSelection();
// The Properties frame will be updated. Avoid flicker during update:
m_frame->GetPropertiesFrame()->Freeze();
WINDOW_FREEZER raiiFreezer( m_frame->GetPropertiesFrame() );
if( selection.GetSize() == 1 )
{
@ -173,9 +173,6 @@ int PL_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
m_frame->GetPropertiesFrame()->CopyPrmsFromGeneralToPanel();
// The Properties frame is updated. Reenable it:
m_frame->GetPropertiesFrame()->Thaw();
return 0;
}

View File

@ -504,7 +504,7 @@ void PANEL_SETUP_TIME_DOMAIN_PARAMETERS::OnDelayProfileGridCellChanging( wxGridE
if( !oldName.IsEmpty() )
{
m_viaPropagationGrid->Freeze();
WINDOW_FREEZER raiiFreezer( m_viaPropagationGrid );
updateViaProfileNamesEditor( oldName, newName );
@ -514,8 +514,6 @@ void PANEL_SETUP_TIME_DOMAIN_PARAMETERS::OnDelayProfileGridCellChanging( wxGridE
if( m_viaPropagationGrid->GetCellValue( row, VIA_GRID_PROFILE_NAME ) == oldName )
m_viaPropagationGrid->SetCellValue( row, VIA_GRID_PROFILE_NAME, newName );
}
m_viaPropagationGrid->Thaw();
}
else
{

View File

@ -380,7 +380,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
if( footprintWizard == nullptr )
return;
m_parameterGrid->Freeze();
WINDOW_FREEZER raiiFreezer( m_parameterGrid );
m_parameterGrid->ClearGrid();
m_parameterGridPage = m_pageList->GetSelection();
@ -429,12 +429,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
wxArrayString options;
while( tokenizer.HasMoreTokens() )
{
options.Add( tokenizer.GetNextToken() );
}
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE,
new wxGridCellChoiceEditor( options ) );
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellChoiceEditor( options ) );
units = wxT( "" );
}
@ -466,8 +463,6 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
}
ResizeParamColumns();
m_parameterGrid->Thaw();
}
void FOOTPRINT_WIZARD_FRAME::ResizeParamColumns()

View File

@ -32,16 +32,16 @@
#include <settings/color_settings.h>
#include <tools/pcb_actions.h>
#include <dpi_scaling_common.h>
#include <core/raii.h>
PCB_LAYER_BOX_SELECTOR::PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxString& value, const wxPoint& pos,
const wxSize& size, int n, const wxString choices[],
int style ) :
LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices ), m_boardFrame( nullptr ),
PCB_LAYER_BOX_SELECTOR::PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size, int n,
const wxString choices[], int style ) :
LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices ),
m_boardFrame( nullptr ),
m_showNotEnabledBrdlayers( false ),
m_layerPresentation( std::make_unique<PCB_LAYER_PRESENTATION>(
nullptr ) ) // The parent isn't awlays the frame
m_layerPresentation( std::make_unique<PCB_LAYER_PRESENTATION>( nullptr ) ) // The parent isn't always the frame
{
}
@ -56,7 +56,8 @@ void PCB_LAYER_BOX_SELECTOR::SetBoardFrame( PCB_BASE_FRAME* aFrame )
// Reload the Layers
void PCB_LAYER_BOX_SELECTOR::Resync()
{
Freeze();
WINDOW_FREEZER raiiFreezer( this );
Clear();
const int size = 14;
@ -118,7 +119,6 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
SetSelection( wxNOT_FOUND );
Fit();
Thaw();
}

View File

@ -895,7 +895,7 @@ void PCB_NET_INSPECTOR_PANEL::updateNets( const std::vector<NETINFO_ITEM*>& aNet
netsToUpdate.emplace_back( net );
}
m_netsList->Freeze();
WINDOW_FREEZER raiiFreezer( m_netsList );
std::vector<std::unique_ptr<LIST_ITEM>> newListItems = calculateNets( aNets, true );
@ -946,8 +946,6 @@ void PCB_NET_INSPECTOR_PANEL::updateNets( const std::vector<NETINFO_ITEM*>& aNet
// Delete any nets we have not yet handled
for( const NETINFO_ITEM* netToDelete : netsToDelete )
m_dataModel->deleteItem( m_dataModel->findItem( netToDelete->GetNetCode() ) );
m_netsList->Thaw();
}

View File

@ -213,7 +213,7 @@ void DIALOG_ZONE_MANAGER::onDialogResize( wxSizeEvent& event )
void DIALOG_ZONE_MANAGER::OnZoneSelectionChanged( ZONE* zone )
{
Freeze();
WINDOW_FREEZER raiiFreezer( this );
for( ZONE_SELECTION_CHANGE_NOTIFIER* i :
std::list<ZONE_SELECTION_CHANGE_NOTIFIER*>{ m_panelZoneProperties, m_zoneViewer } )
@ -222,7 +222,6 @@ void DIALOG_ZONE_MANAGER::OnZoneSelectionChanged( ZONE* zone )
}
Layout();
Thaw();
}