Skip to content

Commit 8d74a70

Browse files
committed
widget: Fix an error on mouse press when widget has no basic layout
... and therefore no message_bar
1 parent d3b9255 commit 8d74a70

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Orange/widgets/tests/test_widget.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
from unittest.mock import patch, MagicMock
77

8-
from AnyQt.QtCore import QRect, QByteArray, QObject, pyqtSignal
8+
from AnyQt.QtCore import Qt, QPoint, QRect, QByteArray, QObject, pyqtSignal
99
from AnyQt.QtGui import QShowEvent
1010
from AnyQt.QtWidgets import QAction
11-
from AnyQt.QtTest import QSignalSpy
11+
from AnyQt.QtTest import QSignalSpy, QTest
1212

1313
from Orange.widgets.gui import OWComponent
1414
from Orange.widgets.settings import Setting, SettingProvider
@@ -92,6 +92,7 @@ class TestWidget2(OWWidget):
9292

9393
w = TestWidget2()
9494
w.showEvent(QShowEvent())
95+
QTest.mousePress(w, Qt.LeftButton, Qt.NoModifier, QPoint(1, 1))
9596

9697
def test_store_restore_layout_geom(self):
9798
class Widget(OWWidget):

Orange/widgets/widget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,8 @@ def closeEvent(self, event):
827827

828828
def mousePressEvent(self, event):
829829
""" Flash message bar icon on mouse press """
830-
self.message_bar.flashIcon()
830+
if self.message_bar is not None:
831+
self.message_bar.flashIcon()
831832
event.ignore()
832833

833834
def setVisible(self, visible):

0 commit comments

Comments
 (0)