Ignore:
Timestamp:
05/21/13 13:14:30 (11 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Pass the full executable path and positional filename arguments to QApplication.

Fixes a problem when starting in OSX.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/main.py

    r11532 r11535  
    1111import optparse 
    1212import cPickle 
     13import shlex 
    1314from contextlib import nested 
    1415 
     
    6162def main(argv=None): 
    6263    if argv is None: 
    63         argv = sys.argv[1:] 
     64        argv = sys.argv 
    6465 
    6566    usage = "usage: %prog [options] [scheme_file]" 
     
    9798                      type="str", default=None) 
    9899 
    99     (options, args) = parser.parse_args(argv) 
     100    (options, args) = parser.parse_args(argv[1:]) 
    100101 
    101102    levels = [logging.CRITICAL, 
     
    111112    log.info("Starting 'Orange Canvas' application.") 
    112113 
    113     qt_argv = ["orange-canvas"] 
     114    qt_argv = argv[:1] 
    114115 
    115116    if options.style is not None: 
     
    117118 
    118119    if options.qt is not None: 
    119         qt_argv += options.qt.split() 
     120        qt_argv += shlex.split(options.qt) 
     121 
     122    qt_argv += args 
    120123 
    121124    log.debug("Starting CanvasApplicaiton with argv = %r.", qt_argv) 
     
    123126 
    124127    # intercept any QFileOpenEvent requests until the main window is 
    125     # fully initialized 
     128    # fully initialized. 
     129    # NOTE: The QApplication must have the executable ($0) and filename 
     130    # arguments passed in argv otherwise the FileOpen events are 
     131    # triggered for them (this is done by Cocoa, but QApplicaiton filters 
     132    # them out if passed in argv) 
     133 
    126134    open_requests = [] 
    127     app.fileOpenRequest.connect(open_requests.append) 
     135 
     136    def onrequest(url): 
     137        log.info("Received an file open request %s", url) 
     138        open_requests.append(url) 
     139 
     140    app.fileOpenRequest.connect(onrequest) 
    128141 
    129142    # Note: config.init must be called after the QApplication constructor 
     
    225238    canvas_window.set_widget_registry(widget_registry) 
    226239    canvas_window.show() 
     240    canvas_window.raise_() 
    227241 
    228242    want_welcome = \ 
     
    230244        and not options.no_welcome 
    231245 
    232     canvas_window.raise_() 
     246    # Process events to make sure the canvas_window layout has 
     247    # a chance to activate (the welcome dialog is modal and will 
     248    # block the event queue, plus we need a chance to receive open file 
     249    # signals when running without a splash screen) 
     250    app.processEvents() 
     251 
     252    app.fileOpenRequest.connect(canvas_window.open_scheme_file) 
    233253 
    234254    if want_welcome and not args and not open_requests: 
    235         # Process events to make sure the canvas_window layout has 
    236         # a chance to activate (the welcome dialog is modal and will 
    237         # block the event queue) 
    238         app.processEvents() 
    239255        canvas_window.welcome_dialog() 
    240256 
     
    248264        canvas_window.load_scheme(open_requests[-1].toLocalFile()) 
    249265 
    250     app.fileOpenRequest.connect(canvas_window.open_scheme_file) 
    251  
    252266    stdout_redirect = \ 
    253267        settings.value("output/redirect-stdout", True, type=bool) 
Note: See TracChangeset for help on using the changeset viewer.