Fixing issue #2162 (crash on selection + query)

Problem was that changing the active cellview index by clicking
on a specific item in the properties dialog cause a "clear_selection".
That interfered with the code of the properties dialog that
expects a static selection.

Fixed by disabling the events that lead to "clear_selection".
Side effect is that under these circumstances the active_cellview_changed
event is not triggered which also prevents side effects due to
scripts hooking into that event.
This commit is contained in:
Matthias Koefferlein 2025-09-28 16:14:11 +02:00
parent ec5de0ffe8
commit 292f6f84c6
7 changed files with 36 additions and 11 deletions

View File

@ -150,8 +150,7 @@ ShapeEditService::get_edit_layer ()
mp_layout = &(cv->layout ());
mp_cell = cv.cell ();
// fetches the last configuration for the given layer
view ()->set_active_cellview_index (cv_index);
view ()->set_active_cellview_index_silent (cv_index);
}
void
@ -173,8 +172,9 @@ ShapeEditService::change_edit_layer (const db::LayerProperties &lp)
close_editor_hooks (false);
}
view ()->set_active_cellview_index_silent (m_cv_index);
// fetches the last configuration for the given layer
view ()->set_active_cellview_index (m_cv_index);
config_recent_for_layer (lp, m_cv_index);
if (editing ()) {
@ -237,7 +237,9 @@ ShapeEditService::update_edit_layer (const lay::LayerPropertiesConstIterator &cl
return;
}
view ()->set_active_cellview_index (cv_index);
// NOTE: we don't want side effects during this operation - i.e. some that
// change the selection. Hence no events here.
view ()->set_active_cellview_index_silent (cv_index);
const lay::ParsedLayerSource &source = cl->source (true /*real*/);
int layer = cl->layer_index ();

View File

@ -879,6 +879,7 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (decl_Dispatcher,
gsi::method ("active_cellview_index=|#active_setview_index=|#set_active_cellview_index", &lay::LayoutViewBase::set_active_cellview_index, gsi::arg ("index"),
"@brief Makes the cellview with the given index the active one (shown in hierarchy browser)\n"
"See \\active_cellview_index.\n"
"Note, that this changing the active cell view index has side effects such as terminating an editing operation.\n"
"\n"
"This method has been renamed from set_active_cellview_index to active_cellview_index= in version 0.25. "
"The original name is still available, but is deprecated."

View File

@ -4943,6 +4943,19 @@ LayoutViewBase::active_cellview_index () const
return m_active_cellview_index;
}
void
LayoutViewBase::set_active_cellview_index_silent (int index)
{
enable_active_cellview_changed_event (false);
try {
set_active_cellview_index (index);
enable_active_cellview_changed_event (true, true /*silent*/);
} catch (...) {
enable_active_cellview_changed_event (true, true /*silent*/);
throw;
}
}
void
LayoutViewBase::set_active_cellview_index (int index)
{

View File

@ -2151,6 +2151,12 @@ public:
*/
virtual void set_active_cellview_index (int index);
/**
* @brief Select a certain cellview for the active one
* This version does not emit any events while changing the cellview index
*/
void set_active_cellview_index_silent (int index);
/**
* @brief An event triggered if the active cellview changes
* This event is triggered after the active cellview changed.

View File

@ -707,11 +707,13 @@ HierarchyControlPanel::update_required ()
}
void
HierarchyControlPanel::select_active (int cellview_index)
HierarchyControlPanel::select_active (int cellview_index, bool silent)
{
if (cellview_index != m_active_index) {
mp_selector->setCurrentIndex (cellview_index);
selection_changed (cellview_index);
if (! silent) {
selection_changed (cellview_index);
}
}
}

View File

@ -140,7 +140,7 @@ public:
* selects the active cellview by index. The index must be
* a valid index within the context of the layout view.
*/
void select_active (int cellview_index);
void select_active (int cellview_index, bool silent = false);
/**
* @brief Get the active cellview

View File

@ -418,7 +418,7 @@ LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool edit
copy_from (source);
bookmarks (source->bookmarks ());
LayoutView::set_active_cellview_index (source->active_cellview_index ());
set_active_cellview_index_silent (source->active_cellview_index ());
}
LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, LayoutViewWidget *widget, unsigned int options)
@ -445,7 +445,7 @@ LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool edit
copy_from (source);
bookmarks (source->bookmarks ());
LayoutView::set_active_cellview_index (source->active_cellview_index ());
set_active_cellview_index_silent (source->active_cellview_index ());
}
bool
@ -1387,12 +1387,13 @@ LayoutView::active_cellview_index () const
}
}
void
void
LayoutView::set_active_cellview_index (int index)
{
if (index >= 0 && index < int (cellviews ())) {
if (mp_hierarchy_panel) {
mp_hierarchy_panel->select_active (index);
// NOTE: we don't send events from here, that is done in "LayoutViewBase::set_active_cellview_index"
mp_hierarchy_panel->select_active (index, true /*no events*/);
}
LayoutViewBase::set_active_cellview_index (index);
}