Ignore:
Timestamp:
04/19/13 13:39:17 (12 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Using 'LayoutRequest' event to schedule an anchor layout.

This prevents the layout routine from being invoked after the AnchorLayout
object is deleted (Qt automatically clears the event queue for deleted
objects).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/canvas/layout.py

    r11207 r11463  
    99import sip 
    1010 
    11 from PyQt4.QtGui import QGraphicsObject 
    12 from PyQt4.QtCore import QRectF, QLineF, QTimer 
     11from PyQt4.QtGui import QGraphicsObject, QApplication 
     12from PyQt4.QtCore import QRectF, QLineF, QEvent 
    1313 
    1414from .items import NodeItem, LinkItem, SourceAnchorItem, SinkAnchorItem 
     
    135135        if self.isEnabled() and not self.__layoutPending: 
    136136            self.__layoutPending = True 
    137             QTimer.singleShot(0, self.__delayedActivate) 
     137            QApplication.postEvent(self, QEvent(QEvent.LayoutRequest)) 
    138138 
    139139    def __delayedActivate(self): 
    140140        if self.__layoutPending: 
    141141            self.activate() 
     142 
     143    def event(self, event): 
     144        if event.type() == QEvent.LayoutRequest: 
     145            self.activate() 
     146            return True 
     147 
     148        return QGraphicsObject.event(self, event) 
    142149 
    143150 
Note: See TracChangeset for help on using the changeset viewer.