Prevent infinite event loop for multi selection

This commit is contained in:
Rebecca Breu 2021-04-06 18:15:33 +02:00
parent b98e455272
commit cc54698baa
2 changed files with 17 additions and 9 deletions

View file

@ -415,11 +415,19 @@ class MultiSelectItem(SelectableMixin,
"""Updates itself to fit the given selection area."""
logging.debug(f'Fit selection area to {rect}')
self.setRect(0, 0, rect.width(), rect.height())
self.setPos(rect.topLeft())
self.setScale(1)
self.setRotation(0)
self.setSelected(True)
# Only update when values have changed, otherwise we end up in an
# infinite event loop sceneChange -> itemChange -> sceneChange ...
if self.width != rect.width() or self.height != rect.height():
self.setRect(0, 0, rect.width(), rect.height())
if self.pos() != rect.topLeft():
self.setPos(rect.topLeft())
if self.scale() != 1:
self.setScale(1)
if self.rotation() != 0:
self.setRotation(0)
if not self.isSelected():
self.setSelected(True)
def mousePressEvent(self, event):
if (event.button() == Qt.MouseButtons.LeftButton

View file

@ -20,7 +20,7 @@ class BeeTestCase(TestCase):
inst = QtWidgets.QApplication.instance()
cls.app = inst if inst else QtWidgets.QApplication([])
@classmethod
def tearDownClass(cls):
cls.app.quit()
del cls.app
# @classmethod
# def tearDownClass(cls):
# cls.app.quit()
# del cls.app