Ignore:
Timestamp:
03/09/12 18:41:20 (2 years ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
rebase_source:
58454f004517f0a64bc7f3113ed030111629c51e
Message:

Fixed a random Orange Canvas crash when exiting the application.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/orngCanvas.pyw

    r10463 r10489  
    1313import orngTabs, orngDoc, orngDlgs, orngOutput, orngHelp, OWReport 
    1414import  user, orngMisc 
     15 
     16import gc 
    1517 
    1618RedR = False 
     
    967969        if closed: 
    968970            self.canvasIsClosing = 1        # output window (and possibly report window also) will check this variable before it will close the window 
    969             self.output.logFile.close() 
    970             self.output.hide() 
    971              
    972             ce.accept() 
    973971             
    974972            self.helpWindow.close() 
    975973            self.reportWindow.close() 
     974             
     975            self.output.catchOutput(False) 
     976            self.output.catchException(False) 
     977            self.output.hide() 
     978            self.output.logFile.close() 
     979             
     980            ce.accept() 
     981             
    976982        else: 
    977983            ce.ignore() 
     
    11561162#        eventDict = {0: 'None', 1: 'Timer', 2: 'MouseButtonPress', 3: 'MouseButtonRelease', 4: 'MouseButtonDblClick', 5: 'MouseMove', 6: 'KeyPress', 7: 'KeyRelease', 8: 'FocusIn', 9: 'FocusOut', 10: 'Enter', 11: 'Leave', 12: 'Paint', 13: 'Move', 14: 'Resize', 17: 'Show', 18: 'Hide', 19: 'Close', 21: 'ParentChange', 24: 'WindowActivate', 25: 'WindowDeactivate', 26: 'ShowToParent', 27: 'HideToParent', 31: 'Wheel', 33: 'WindowTitleChange', 34: 'WindowIconChange', 35: 'ApplicationWindowIconChange', 36: 'ApplicationFontChange', 37: 'ApplicationLayoutDirectionChange', 38: 'ApplicationPaletteChange', 39: 'PaletteChange', 40: 'Clipboard', 43: 'MetaCall', 50: 'SockAct', 51: 'ShortcutOverride', 52: 'DeferredDelete', 60: 'DragEnter', 61: 'DragMove', 62: 'DragLeave', 63: 'Drop', 68: 'ChildAdded', 69: 'ChildPolished', 70: 'ChildInserted', 71: 'ChildRemoved', 74: 'PolishRequest', 75: 'Polish', 76: 'LayoutRequest', 77: 'UpdateRequest', 78: 'UpdateLater', 82: 'ContextMenu', 83: 'InputMethod', 86: 'AccessibilityPrepare', 87: 'TabletMove', 88: 'LocaleChange', 89: 'LanguageChange', 90: 'LayoutDirectionChange', 92: 'TabletPress', 93: 'TabletRelease', 94: 'OkRequest', 96: 'IconDrag', 97: 'FontChange', 98: 'EnabledChange', 99: 'ActivationChange', 100: 'StyleChange', 101: 'IconTextChange', 102: 'ModifiedChange', 103: 'WindowBlocked', 104: 'WindowUnblocked', 105: 'WindowStateChange', 109: 'MouseTrackingChange', 110: 'ToolTip', 111: 'WhatsThis', 112: 'StatusTip', 113: 'ActionChanged', 114: 'ActionAdded', 115: 'ActionRemoved', 116: 'FileOpen', 117: 'Shortcut', 118: 'WhatsThisClicked', 119: 'AccessibilityHelp', 120: 'ToolBarChange', 121: 'ApplicationActivate', 122: 'ApplicationDeactivate', 123: 'QueryWhatsThis', 124: 'EnterWhatsThisMode', 125: 'LeaveWhatsThisMode', 126: 'ZOrderChange', 127: 'HoverEnter', 128: 'HoverLeave', 129: 'HoverMove', 130: 'AccessibilityDescription', 131: 'ParentAboutToChange', 132: 'WinEventAct', 150: 'EnterEditFocus', 151: 'LeaveEditFocus', 153: 'MenubarUpdated', 155: 'GraphicsSceneMouseMove', 156: 'GraphicsSceneMousePress', 157: 'GraphicsSceneMouseRelease', 158: 'GraphicsSceneMouseDoubleClick', 159: 'GraphicsSceneContextMenu', 160: 'GraphicsSceneHoverEnter', 161: 'GraphicsSceneHoverMove', 162: 'GraphicsSceneHoverLeave', 163: 'GraphicsSceneHelp', 164: 'GraphicsSceneDragEnter', 165: 'GraphicsSceneDragMove', 166: 'GraphicsSceneDragLeave', 167: 'GraphicsSceneDrop', 168: 'GraphicsSceneWheel', 169: 'KeyboardLayoutChange', 170: 'DynamicPropertyChange', 171: 'TabletEnterProximity', 172: 'TabletLeaveProximity', 173: 'NonClientAreaMouseMove', 174: 'NonClientAreaMouseButtonPress', 175: 'NonClientAreaMouseButtonRelease', 176: 'NonClientAreaMouseButtonDblClick', 177: 'MacSizeChange', 178: 'ContentsRectChange', 181: 'GraphicsSceneResize', 182: 'GraphicsSceneMove', 183: 'CursorChange', 184: 'ToolTipChange', 186: 'GrabMouse', 187: 'UngrabMouse', 188: 'GrabKeyboard', 189: 'UngrabKeyboard'} 
    11571163#        import time 
    1158 #        try: 
     1164#        if isinstance(receiver, QWidget): 
    11591165#            if str(receiver.windowTitle()) != "": 
    1160 #                print time.strftime("%H:%M:%S"), "%15s" % str(receiver.windowTitle()) + ": ",      # print only events for QWidget classes and up 
     1166#                print time.strftime("%H:%M:%S"), "%15s %15s" % (str(receiver.windowTitle()) ,type(receiver).__name__) + ": ",      # print only events for QWidget classes and up 
    11611167#                if eventDict.has_key(event.type()): 
    11621168#                    print eventDict[event.type()]  
    11631169#                else: 
    11641170#                    print "unknown event name (" + str(event.type()) + ")" 
    1165 #        except: 
    1166 #            pass 
    1167 #            #print str(receiver.objectName()), 
     1171#        else: 
     1172#            print time.strftime("%H:%M:%S"), type(receiver).__name__, str(receiver.objectName()), 
     1173#            if eventDict.has_key(event.type()): 
     1174#                print eventDict[event.type()]  
     1175#            else: 
     1176#                print "unknown event name (" + str(event.type()) + ")" 
    11681177#                 
    11691178#        return QApplication.notify(self, receiver, event) 
     
    11811190        if arg == "-reload": 
    11821191            dlg.menuItemOpenLastSchema() 
    1183     app.exec_() 
     1192    r = app.exec_() 
    11841193    app.closeAllWindows() 
     1194     
     1195    del qApp.canvasDlg 
     1196    del dlg 
     1197     
     1198    app.processEvents() 
     1199     
     1200    # Call gc.collect before the app is destroyed to colect any remainig 
     1201    # cycles. Some sip objects are stored in it's global state (for instance 
     1202    # QGraphicsScene) and can cause a crash in Py_Finalize when sip trys to  
     1203    # deallocate it (a bug in sip?). 
     1204     
     1205    gc.collect() 
     1206    del app 
     1207     
     1208    return r 
    11851209 
    11861210if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.