Changeset 7985:8814ef517479 in orange


Ignore:
Timestamp:
06/06/11 11:53:00 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
e01a6c5288905c965041535612fb6cd045a2101a
Message:

Added a check in CanvasWidgetAction.callback to prevent max recursion errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeCanvas/orngTabs.py

    r7171 r7985  
    548548        self.widgetSuggestEdit.listWidget.setIconSize(QSize(16,16))  
    549549        self.setDefaultWidget(self.widgetSuggestEdit) 
     550        self._in_callback = False 
    550551         
    551552    def callback(self): 
    552         text = str(self.widgetSuggestEdit.text()) 
    553         for action in self.actions: 
    554             if action.widgetInfo.name == text: 
    555                 self.widgetInfo = action.widgetInfo 
    556                 self.parent.setActiveAction(self) 
    557                 self.activate(QAction.Trigger) 
    558                 QApplication.sendEvent(self.widgetSuggestEdit, QKeyEvent(QEvent.KeyPress, Qt.Key_Enter, Qt.NoModifier)) 
    559                 return 
     553        if not self._in_callback: 
     554            try: 
     555                self._in_callback = True 
     556                text = str(self.widgetSuggestEdit.text()) 
     557                for action in self.actions: 
     558                    if action.widgetInfo.name == text: 
     559                        self.widgetInfo = action.widgetInfo 
     560                        self.parent.setActiveAction(self) 
     561                        self.activate(QAction.Trigger) 
     562                        QApplication.sendEvent(self.widgetSuggestEdit, QKeyEvent(QEvent.KeyPress, Qt.Key_Enter, Qt.NoModifier)) 
     563                        return 
     564            finally: 
     565                self._in_callback = False 
    560566         
    561567 
Note: See TracChangeset for help on using the changeset viewer.