Skip to content

Commit

Permalink
overlay: Auto disconnect when the overlay widget is deleted
Browse files Browse the repository at this point in the history
Register `__on_destroyed` as a Qt slot so it can be automatically
disconnected when the overlay widget is deleted/destroyed.
This fixes a possible 'RuntimeError C/C++ object was deleted ...' error
when the overlay is deleted before the target widget.
  • Loading branch information
ales-erjavec committed Jul 4, 2016
1 parent ecc474d commit d211933
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Orange/widgets/utils/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
QWidget, QPixmap, QStyleOption, QPainter
)
from PyQt4.QtCore import Qt, QSize, QRect, QPoint, QEvent, QTimer
from PyQt4.QtCore import pyqtSignal as Signal
from PyQt4.QtCore import pyqtSignal as Signal, pyqtSlot as Slot


class OverlayWidget(QWidget):
Expand Down Expand Up @@ -172,6 +172,7 @@ def getsize(hint, minimum, maximum, policy):
geom = QRect(QPoint(x, y), size)
self.setGeometry(geom)

@Slot()
def __on_destroyed(self):
self.__widget = None
if self.isVisible():
Expand Down

0 comments on commit d211933

Please sign in to comment.