[consider merging] avoiding a crash due to recursion in PCell recomputation with macro editor open (IDE generated processEvent calls and these may issue mouse events during execution of a mouse event response code)

This commit is contained in:
Matthias Koefferlein 2025-03-13 00:01:28 +01:00
parent 930e09809b
commit d6273f9bbb
3 changed files with 16 additions and 4 deletions

View File

@ -35,6 +35,7 @@
#include "layLayoutViewBase.h"
#include "layCellSelectionForm.h"
#include "layQtTools.h"
#include "layBusy.h"
#include "tlExceptions.h"
#include "tlString.h"
@ -870,19 +871,21 @@ InstPropertiesPage::do_apply (bool current_only, bool relative)
db::Instance new_inst = pos->back ().inst_ptr;
// Don't apply the same change twice
std::map<db::Instance, db::Instance>::const_iterator i = insts_seen.find (pos->back ().inst_ptr);
std::map<db::Instance, db::Instance>::const_iterator i = insts_seen.find (new_inst);
if (i == insts_seen.end ()) {
db::Instance org_inst = new_inst;
const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ());
db::Cell &cell = cv->layout ().cell (pos->cell_index ());
double dbu = cv->layout ().dbu ();
if (!current_only || pos->back ().inst_ptr == current) {
new_inst = applicator->do_apply_inst (cell, pos->back ().inst_ptr, dbu, relative_mode);
if (!current_only || org_inst == current) {
new_inst = applicator->do_apply_inst (cell, org_inst, dbu, relative_mode);
}
insts_seen.insert (std::make_pair (pos->back ().inst_ptr, new_inst));
insts_seen.insert (std::make_pair (org_inst, new_inst));
} else {
new_inst = i->second;

View File

@ -28,6 +28,7 @@
#include "dbLayout.h"
#include "dbLibrary.h"
#include "dbPCellDeclaration.h"
#include "layBusy.h"
#include <QLineEdit>
@ -630,6 +631,10 @@ ChangeTargetPCellApplicator::ChangeTargetPCellApplicator (db::pcell_id_type pcel
db::Instance
ChangeTargetPCellApplicator::do_apply_inst (db::Cell &cell, const db::Instance &instance, double /*dbu*/, bool /*relative*/) const
{
// Prevent recursion due to processEvents produced by macro code when
// executing inside the IDE
lay::BusySection busy;
tl_assert (cell.layout ());
db::Layout *layout = cell.layout ();

View File

@ -38,6 +38,7 @@
#include "layMarker.h"
#include "layLayerProperties.h"
#include "layLayoutViewBase.h"
#include "layBusy.h"
#if defined(HAVE_QT)
# include "layLayoutView.h"
@ -1722,6 +1723,9 @@ InstService::make_cell (const lay::CellView &cv)
return std::make_pair (true, m_current_cell);
}
// prevents recursion
lay::BusySection busy;
// NOTE: do this at the beginning: creating a transaction might delete transactions behind the
// head transaction, hence releasing (thus: deleting) cells. To prevert interference, create
// the transaction at the beginning.