Browse Source

Don't process grid-change events when we're rebuilding the grid.

The selection has already changed and it's too
late to update any values.

Also regularises the event.Skip() handling from
8a1347d2c8.

(cherry picked from commit a1fe0f7faf)
9.0
Jeff Young 8 months ago
parent
commit
0c083e560c
  1. 38
      common/widgets/properties_panel.cpp
  2. 9
      common/widgets/properties_panel.h
  3. 6
      eeschema/widgets/sch_properties_panel.cpp
  4. 13
      pcbnew/widgets/pcb_properties_panel.cpp

38
common/widgets/properties_panel.cpp

@ -42,6 +42,7 @@ extern APIIMPORT wxPGGlobalVarsClass* wxPGGlobalVars;
PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame ) :
wxPanel( aParent ),
m_SuppressGridChangeEvents( 0 ),
m_frame( aFrame ),
m_splitter_key_proportion( -1 )
{
@ -168,13 +169,43 @@ void PROPERTIES_PANEL::OnLanguageChanged( wxCommandEvent& aEvent )
}
class SUPPRESS_GRID_CHANGED_EVENTS
{
public:
SUPPRESS_GRID_CHANGED_EVENTS( PROPERTIES_PANEL* aPanel ) :
m_panel( aPanel )
{
m_panel->m_SuppressGridChangeEvents++;
}
~SUPPRESS_GRID_CHANGED_EVENTS()
{
m_panel->m_SuppressGridChangeEvents--;
}
private:
PROPERTIES_PANEL* m_panel;
};
void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection )
{
SUPPRESS_GRID_CHANGED_EVENTS raii( this );
auto reset =
[&]()
{
if( m_grid->IsEditorFocused() )
m_grid->CommitChangesFromEditor();
m_grid->Clear();
m_displayed.clear();
};
if( aSelection.Empty() )
{
m_caption->SetLabel( _( "No objects selected" ) );
m_grid->Clear();
m_displayed.clear();
reset();
return;
}
else if( aSelection.Size() == 1 )
@ -287,8 +318,7 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection )
return;
// Some difference exists: start from scratch
m_grid->Clear();
m_displayed.clear();
reset();
std::map<wxPGProperty*, int> pgPropOrders;
std::map<wxString, std::vector<wxPGProperty*>> pgPropGroups;

9
common/widgets/properties_panel.h

@ -104,11 +104,14 @@ protected:
bool extractValueAndWritability( const SELECTION& aSelection, PROPERTY_BASE* aProperty,
wxVariant& aValue, bool& aWritable );
public:
int m_SuppressGridChangeEvents;
protected:
std::vector<PROPERTY_BASE*> m_displayed;
wxPropertyGrid* m_grid;
EDA_BASE_FRAME* m_frame;
wxStaticText* m_caption;
wxPropertyGrid* m_grid;
EDA_BASE_FRAME* m_frame;
wxStaticText* m_caption;
/// Proportion of the grid column splitter that is used for the key column (0.0 - 1.0)
float m_splitter_key_proportion;

6
eeschema/widgets/sch_properties_panel.cpp

@ -154,6 +154,9 @@ PROPERTY_BASE* SCH_PROPERTIES_PANEL::getPropertyFromEvent( const wxPropertyGridE
void SCH_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
{
if( m_SuppressGridChangeEvents )
return;
SCH_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
const SELECTION& selection = selectionTool->GetSelection();
EDA_ITEM* item = selection.Front();
@ -179,6 +182,9 @@ void SCH_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
void SCH_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
{
if( m_SuppressGridChangeEvents )
return;
SCH_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
const SELECTION& selection = selectionTool->GetSelection();
PROPERTY_BASE* property = getPropertyFromEvent( aEvent );

13
pcbnew/widgets/pcb_properties_panel.cpp

@ -181,6 +181,9 @@ PROPERTY_BASE* PCB_PROPERTIES_PANEL::getPropertyFromEvent( const wxPropertyGridE
void PCB_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
{
if( m_SuppressGridChangeEvents > 0 )
return;
PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
const SELECTION& selection = selectionTool->GetSelection();
EDA_ITEM* item = selection.Front();
@ -199,11 +202,16 @@ void PCB_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
aEvent.Veto();
return;
}
aEvent.Skip();
}
void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
{
if( m_SuppressGridChangeEvents > 0 )
return;
PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
const SELECTION& selection = selectionTool->GetSelection();
@ -228,6 +236,8 @@ void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
// Perform grid updates as necessary based on value change
AfterCommit();
aEvent.Skip();
}
@ -249,8 +259,7 @@ void PCB_PROPERTIES_PANEL::updateLists( const BOARD* aBoard )
m_propMgr.GetProperty( TYPE_HASH( PCB_SHAPE ), _HKI( "Layer" ) )->SetChoices( layersAll );
// Copper only properties
m_propMgr.GetProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ),
_HKI( "Layer" ) )->SetChoices( layersCu );
m_propMgr.GetProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ) )->SetChoices( layersCu );
m_propMgr.GetProperty( TYPE_HASH( PCB_VIA ), _HKI( "Layer Top" ) )->SetChoices( layersCu );
m_propMgr.GetProperty( TYPE_HASH( PCB_VIA ), _HKI( "Layer Bottom" ) )->SetChoices( layersCu );

Loading…
Cancel
Save