Results 1 to 4 of 4

Thread: QFileDialog::getSaveFileName() issue on Max OS X 10.8

  1. #1
    Join Date
    Sep 2011
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: QFileDialog::getSaveFileName() issue on Max OS X 10.8

    This code puts up a standard platform file save dialog:

    Qt Code:
    1. QString filters( "PDF (*.pdf);;PNG image (*.png);;JPEG image (*.jpg);;Bitmap image (*.bmp)" );
    2. QString path = "/Users/abc/";
    3. QString selectedFilter;
    4. path = QFileDialog::getSaveFileName( NULL, "caption", path,
    5. filters, &selectedFilter, QFileDialog::DontConfirmOverwrite );
    To copy to clipboard, switch view to plain text mode 

    it works fine on Windows and Mac OS X, except for Mac OS X 10.8 where it crashes the app if you click on the folder drop-down. The problem happens in both Qt 4.8.1 and 4.8.3.

    The only way I can find around it is to pass the QFileDialog::DontUseNativeDialog flag, which is less than ideal.

    So I created a tiny example app I could use to submit the bug report. But the example app works fine with the identical code!

    Any ideas?

    Andy Brice
    http://www.successfulsoftware.net

    savefile.png


    Added after 14 minutes:


    BTW The crash stack trace is:


    Crashed Thread: 0 Dispatch queue: com.apple.main-thread

    Exception Type: EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000003

    VM Regions Near 0x3:
    -->
    __TEXT 0000000100000000-0000000100aa3000 [ 10.6M] r-x/rwx SM=COW /Users/USER/*/PerfectTablePlan.app/Contents/MacOS/PerfectTablePlan

    Application Specific Information:
    Performing @selector(qtDispatcherToQAction:) from sender NSMenuItem 0x1054ca500

    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0 ??? 0x0000000000000003 0 + 3
    1 com.apple.FinderKit 0x00007fff8d6507ee ApplicationURL(TString const&) + 77
    2 com.apple.FinderKit 0x00007fff8d650a27 AppBundleIDCanOpenExtension(TString const&, TString const&) + 392
    3 com.apple.FinderKit 0x00007fff8d65114d ThisAppCanOpenExtension(TString const&) + 208
    4 com.apple.FinderKit 0x00007fff8d65154f -[FIFinderViewGutsController finderLocationPopUpWillDisplay:] + 183
    5 com.apple.FinderKit 0x00007fff8d67b7ff -[FILocationPopUp menuNeedsUpdate:] + 46
    6 com.apple.AppKit 0x00007fff950266a8 -[NSMenu _populateFromDelegateWithEventRef:] + 674
    7 com.apple.AppKit 0x00007fff94fcae64 -[NSMenu _populateWithEventRef:] + 83
    8 com.apple.AppKit 0x00007fff950256ac -[NSCarbonMenuImpl _carbonPopulateEvent:handlerCallRef:] + 427
    9 com.apple.AppKit 0x00007fff95025245 NSSLMMenuEventHandler + 342
    10 com.apple.HIToolbox 0x00007fff9864cf0a DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1206
    11 com.apple.HIToolbox 0x00007fff9864c3d9 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 410
    12 com.apple.HIToolbox 0x00007fff9864c236 SendEventToEventTargetWithOptions + 43
    13 com.apple.HIToolbox 0x00007fff98695d58 SendMenuPopulate(MenuData*, OpaqueEventTargetRef*, unsigned int, double, unsigned int, OpaqueEventRef*, unsigned char*) + 279
    14 com.apple.HIToolbox 0x00007fff9861ed5a SendMenuOpening(MenuSelectData*, MenuData*, double, unsigned int, unsigned int, __CFDictionary*, unsigned char, unsigned char*) + 286
    15 com.apple.HIToolbox 0x00007fff987b3cff PopUpMenuSelectCore(MenuData*, Point, double, Point, unsigned short, unsigned int, Rect const*, unsigned short, unsigned int, Rect const*, Rect const*, __CFString const*, OpaqueMenuRef**, unsigned short*) + 895
    16 com.apple.HIToolbox 0x00007fff987b3924 _HandlePopUpMenuSelection7 + 629
    17 com.apple.AppKit 0x00007fff950a861b _NSSLMPopUpCarbonMenu3 + 3916
    18 com.apple.AppKit 0x00007fff95409d2a _NSPopUpCarbonMenu3 + 39
    19 com.apple.AppKit 0x00007fff950a75dc -[NSCarbonMenuImpl popUpMenu:atLocation:width:forView:withSelectedIte m:withFont:withFlags:withOptions:] + 346
    20 com.apple.AppKit 0x00007fff9526b315 -[NSPopUpButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 540
    21 com.apple.AppKit 0x00007fff94ef3c9c -[NSControl mouseDown:] + 820
    22 com.apple.AppKit 0x00007fff94eeb60e -[NSWindow sendEvent:] + 6853
    23 com.apple.AppKit 0x00007fff94ee7744 -[NSApplication sendEvent:] + 5761
    24 QtGui 0x0000000101478352 -[QNSApplication sendEvent:] + 82
    25 com.apple.AppKit 0x00007fff9505076a -[NSApplication _realDoModalLoop:peek:] + 582
    26 com.apple.AppKit 0x00007fff950509ce -[NSApplication runModalForWindow:] + 120
    27 com.apple.AppKit 0x00007fff9529bdb6 -[NSSavePanel runModal] + 302
    28 QtGui 0x00000001014b2832 -[QNSOpenSavePanelDelegate runApplicationModalPanel] + 274
    29 QtGui 0x00000001014b2e65 QFileDialogPrivate::_q_macRunNativeAppModalPanel() + 65
    30 QtGui 0x0000000101917a97 QFileDialog::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 939
    31 QtCore 0x00000001011e5951 QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 2001
    32 QtCore 0x00000001011eba3b QSingleShotTimer::timerEvent(QTimerEvent*) + 53
    33 QtCore 0x00000001011e49d9 QObject::event(QEvent*) + 51
    34 QtGui 0x00000001014c6088 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 304
    35 QtGui 0x00000001014c6306 QApplication::notify(QObject*, QEvent*) + 600
    36 PerfectTablePlan 0x000000010042721d TPApplication::notify(QObject*, QEvent*) + 227
    37 QtCore 0x00000001011d0152 QCoreApplication::notifyInternal(QObject*, QEvent*) + 104
    38 QtGui 0x00000001014c581a qt_sendSpontaneousEvent(QObject*, QEvent*) + 42
    39 QtGui 0x0000000101480051 QEventDispatcherMacPrivate::activateTimer(__CFRunL oopTimer*, void*) + 193
    40 com.apple.CoreFoundation 0x00007fff92e49da4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUN CTION__ + 20
    41 com.apple.CoreFoundation 0x00007fff92e498bd __CFRunLoopDoTimer + 557
    42 com.apple.CoreFoundation 0x00007fff92e2f099 __CFRunLoopRun + 1513
    43 com.apple.CoreFoundation 0x00007fff92e2e6b2 CFRunLoopRunSpecific + 290
    44 com.apple.HIToolbox 0x00007fff986740a4 RunCurrentEventLoopInMode + 209
    45 com.apple.HIToolbox 0x00007fff98673d84 ReceiveNextEventCommon + 166
    46 com.apple.HIToolbox 0x00007fff98673cd3 BlockUntilNextEventMatchingListInMode + 62
    47 com.apple.AppKit 0x00007fff94e06613 _DPSNextEvent + 685
    48 com.apple.AppKit 0x00007fff94e05ed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
    49 com.apple.AppKit 0x00007fff94dfd283 -[NSApplication run] + 517
    50 QtGui 0x00000001014815c0 QEventDispatcherMac::processEvents(QFlags<QEventLo op::ProcessEventsFlag>) + 840
    51 QtCore 0x00000001011cd578 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsF lag>) + 394
    52 QtGui 0x0000000101915263 QDialog::exec() + 243
    53 QtGui 0x000000010192811f QFileDialog::getSaveFileName(QWidget*, QString const&, QString const&, QString const&, QString*, QFlags<QFileDialog::Option>) + 361

    In my example app (where it doesn't crash) it outputs:

    2012-10-19 13:14:06.260 filedialog_crash[54235:707] *** WARNING: -[NSImage compositeToPoint:operation:] is deprecated in MacOSX 10.8 and later. Please use -[NSImage drawAtPoint:fromRect:operation:fraction:] instead.
    2012-10-19 13:14:06.262 filedialog_crash[54235:707] *** WARNING: -[NSImage compositeToPoint:fromRect:operation:] is deprecated in MacOSX 10.8 and later. Please use -[NSImage drawAtPoint:fromRect:operation:fraction:] instead.
    Last edited by AndyBrice; 19th October 2012 at 14:15.

  2. #2
    Join Date
    Nov 2012
    Posts
    1
    Thanked 1 Time in 1 Post
    Platforms
    MacOS X

    Default Re: QFileDialog::getSaveFileName() issue on Max OS X 10.8

    I had the same crash in an native cocoa OSX program. An empty "Bundle Identifier" turned out to be the reason. After filling in my reverse web address and recompiling in Xcode it does not crash anymore.

    hope it helps,
    Rüdiger

  3. The following user says thank you to bruehl for this useful post:

    AndyBrice (20th June 2013)

  4. #3
    Join Date
    Dec 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QFileDialog::getSaveFileName() issue on Max OS X 10.8

    Actually, setting the bundle identifier didn't work out for me (Qt 4.8.3, OSX 10.8.2).

    However I located the origin of the bug: the name filter(s)!

    Let me propose a workaround from your example:
    Qt Code:
    1. QStringList filenames;
    2. QString filename;
    3. QString path = "/Users/abc/";
    4. QFileDialog dialog(0,"caption");
    5. dialog.setDefaultSuffix("pdf");
    6. dialog.setDirectory(path)
    7. dialog.setFileMode(QFileDialog::AnyFile);
    8. dialog.setAcceptMode(QFileDialog::AcceptSave);
    9. dialog.setOption(QFileDialog::DontConfirmOverwrite);
    10. if (dialog.exec())
    11. filenames = dialog.selectedFiles();
    12. if(filenames.size() == 1)
    13. filename = filenames.first();
    To copy to clipboard, switch view to plain text mode 

    For me, both QFileDialog::setNameFilter and setNameFilters make the dialog crash when selecting the path from the drop-down menu in the dialog.

    If you need many name filters, your only way out for now seems to be setting the option DontUseNativeDialog...

  5. #4
    Join Date
    Sep 2011
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Cool Re: QFileDialog::getSaveFileName() issue on Max OS X 10.8

    Quote Originally Posted by bruehl View Post
    I had the same crash in an native cocoa OSX program. An empty "Bundle Identifier" turned out to be the reason. After filling in my reverse web address and recompiling in Xcode it does not crash anymore.

    hope it helps,
    Rüdiger
    Thanks, that was the info I needed. I just added:

    <key>CFBundleIdentifier</key>
    <string>com.oryxdigital.PerfectTablePlan</string>

    To Info.plist and suddenly the crash seems to have gone away. I just need to test it a bit more now.

    Thanks!

    --
    Andy Brice
    http://www.perfecttableplan.com
    http://www.successfulsoftware.net

Similar Threads

  1. QFileDialog::getSaveFileName Save Button
    By penny in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2011, 09:55
  2. QInputDialog like QFileDialog::getSaveFileName
    By BIllNo123 in forum Newbie
    Replies: 5
    Last Post: 23rd September 2010, 15:51
  3. problem with QFileDialog::getSaveFileName
    By navi1084 in forum Qt Programming
    Replies: 4
    Last Post: 26th June 2009, 08:38
  4. A question about QFileDialog::getSaveFileName
    By Ali in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2007, 20:46
  5. QFileDialog::getSaveFileName issues with filename
    By dugs in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2006, 18:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.