Fix the following issues:

a) paste
- conductor does not move
- pressing escape does not abort
- pressing anything during the process crashes the program instead of aborting
b) similar issue with the escape not working fixed for graphics items, texxt fields (and probably others)
This commit is contained in:
Andre Rummler
2026-09-17 11:34:25 +02:00
parent ff3c2e0916
commit 923723a9de
6 changed files with 31 additions and 11 deletions
+14 -10
View File
@@ -87,12 +87,12 @@ DiagramEventAddPaste::DiagramEventAddPaste(Diagram *diagram, const QPointF &star
*/
DiagramEventAddPaste::~DiagramEventAddPaste()
{
if (!m_finished && m_diagram) {
cancel();
}
if (m_status_bar) {
m_status_bar->clearMessage();
if (!m_finished) {
removeItems();
m_finished = true;
m_running = false;
}
if (m_status_bar) m_status_bar->clearMessage();
}
/**
@@ -139,6 +139,10 @@ void DiagramEventAddPaste::moveTo(const QPointF &scene_pos)
it.key()->setPos(anchor + it.value());
}
}
const auto conductors = m_content.conductors(); // AnyConductor by default
for (auto *cond : conductors) {
cond->updatePath();
}
}
void DiagramEventAddPaste::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
@@ -216,13 +220,14 @@ void DiagramEventAddPaste::commit()
void DiagramEventAddPaste::cancel()
{
if (m_finished || !m_diagram) return;
removeItems();
m_finished = true;
m_running = false;
emit finish(); // only the user-driven path signals
}
//Conductors first: they hold pointers to the terminals of the
//elements below, so removing an element out from under one would
//leave it pointing at freed memory for as long as it is still in the
//scene.
void DiagramEventAddPaste::removeItems()
{
const QList<Conductor *> conductors = m_content.conductors(DiagramContent::AnyConductor);
for (auto *conductor : conductors) {
m_diagram->removeItem(conductor);
@@ -237,5 +242,4 @@ void DiagramEventAddPaste::cancel()
m_content.clear();
m_relative_pos.clear();
emit finish();
}