summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp6
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp16
2 files changed, 20 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 7f02fb9..7781258 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -1887,8 +1887,10 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action)
}
d->actions.insert(pos, action);
- QActionPrivate *apriv = action->d_func();
- apriv->graphicsWidgets.append(this);
+ if (index == -1) {
+ QActionPrivate *apriv = action->d_func();
+ apriv->graphicsWidgets.append(this);
+ }
QActionEvent e(QEvent::ActionAdded, action, before);
QApplication::sendEvent(this, &e);
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index b85abd3..1917357 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -51,6 +51,7 @@
#include <qlineedit.h>
#include <qboxlayout.h>
#include <qaction.h>
+#include <qwidgetaction.h>
#include "../../shared/util.h"
@@ -147,6 +148,7 @@ private slots:
void setSizes();
void closePopupOnOutsideClick();
void defaultSize();
+ void shortcutsDeletion();
// Task fixes
void task236127_bspTreeIndexFails();
@@ -1782,6 +1784,20 @@ void tst_QGraphicsWidget::defaultSize()
}
+void tst_QGraphicsWidget::shortcutsDeletion()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsWidget *widget2 = new QGraphicsWidget;
+ widget->setMinimumSize(40, 40);
+ QWidgetAction *del = new QWidgetAction(widget);
+ del->setIcon(QIcon("edit-delete"));
+ del->setShortcut(Qt::Key_Delete);
+ del->setShortcutContext(Qt::WidgetShortcut);
+ widget2->addAction(del);
+ widget2->addAction(del);
+ delete widget;
+}
+
class ProxyStyle : public QCommonStyle
{
public: