avoid that another action triggers while aborting operation

This commit is contained in:
Andre Rummler
2026-09-17 13:25:17 +02:00
parent 923723a9de
commit 863ac5f0ae
4 changed files with 14 additions and 7 deletions
+5
View File
@@ -801,6 +801,11 @@ void Diagram::clearEventInterface()
}
}
bool Diagram::eventInterfaceIsRunning() const
{
return m_event_interface && m_event_interface->isRunning();
}
/**
@brief Diagram::conductorsAutonumName
@return the name of autonum to use.
+1 -1
View File
@@ -216,7 +216,7 @@ class Diagram : public QGraphicsScene
// methods related to graphics items addition/removal on the diagram
virtual void addItem (QGraphicsItem *item);
virtual void removeItem (QGraphicsItem *item);
bool hasEventInterface() const { return m_event_interface != nullptr; }
bool eventInterfaceIsRunning() const;
// methods related to graphics options
ExportProperties applyProperties(const ExportProperties &);
@@ -87,12 +87,14 @@ DiagramEventAddPaste::DiagramEventAddPaste(Diagram *diagram, const QPointF &star
*/
DiagramEventAddPaste::~DiagramEventAddPaste()
{
if (!m_finished) {
if (!m_finished && m_diagram) {
removeItems();
m_finished = true;
m_running = false;
}
if (m_status_bar) m_status_bar->clearMessage();
if (m_status_bar) {
m_status_bar->clearMessage();
}
}
/**
@@ -164,13 +166,13 @@ void DiagramEventAddPaste::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (!m_running) return;
event->setAccepted(true);
if (event->button() == Qt::LeftButton) {
moveTo(event->scenePos());
commit();
} else if (event->button() == Qt::RightButton) {
cancel();
}
event->setAccepted(true);
}
void DiagramEventAddPaste::keyPressEvent(QKeyEvent *event)
@@ -179,15 +181,15 @@ void DiagramEventAddPaste::keyPressEvent(QKeyEvent *event)
switch (event->key()) {
case Qt::Key_Escape:
cancel();
event->setAccepted(true);
cancel();
break;
//Return and Enter drop the paste where it stands, so the whole
//operation can be completed without a mouse.
case Qt::Key_Return:
case Qt::Key_Enter:
commit();
event->setAccepted(true);
commit();
break;
default:
break;
+1 -1
View File
@@ -733,7 +733,7 @@ void DiagramView::keyPressEvent(QKeyEvent *e)
//way off the canvas for someone working without a mouse.
//Escape steps back out: first it drops the selection, then it
//hands focus to the next widget.
if (m_diagram && m_diagram->hasEventInterface()) {
if (m_diagram && m_diagram->eventInterfaceIsRunning()) {
QGraphicsView::keyPressEvent(e); // let the active tool see it
return;
}