Results 1 to 6 of 6

Thread: Qt4 + OSX: App Crash when starting application through Finder

  1. #1
    Join Date
    Apr 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Qt4 + OSX: App Crash when starting application through Finder

    Hi all!

    I'm pretty new to Qt programming, and even more new to this forum! So, let me introduce myself first: My name is Thomas Keller and I'm participating on the monotone project (venge.net/monotone) by creating a cross-platform GUI named guitone for this SCM.

    Now, early builds of this GUI work fine under Linux and Windows, but my local tests show that this is not the case under OSX 10.4.6 (Qt 4.1.2). In detail:

    The app is compiled perfectly, qmake creates an *.app folder structure where it places the binary into guitone.app/Contents/MacOS/guitone. When I try to start the application through the Finder though (or by using the 'open' command from the shell), the application crashes almost immediately (crash log follows).
    Now, the weird thing is that this does NOT happen if I change via the shell into that subdirectory and start the application unix-alike with ./guitone or Contents/MacOS/guitone. Though, if I do $ guitone.app/Contents/MacOS/guitone (or above) it crashes likewise it does when starting it via "open", additionally it outputs "bus error" on console.

    Has anybody a clue what am I doing wrong?

    Thanks in advance!

    Thomas.

    ---

    Date/Time: 2006-04-23 03:18:43.048 +0200
    OS Version: 10.4.6 (Build 8I127)
    Report Version: 4

    Command: guitone
    Path: bin/guitone.app/Contents/MacOS/guitone
    Parent: bash [22259]

    Version: ??? (???)

    PID: 22747
    Thread: 0

    Exception: EXC_BAD_ACCESS (0x0001)
    Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

    Thread 0 Crashed:
    0 QtGui 0x02282780 QListData::size() const + 0 (icplusplus.c:28)
    1 QtGui 0x021dab8c qt_mac_set_modal_state(OpaqueMenuRef*, bool) + 408 (icplusplus.c:28)
    2 QtGui 0x021dc4a0 QMenuBar::macUpdateMenuBar() + 556 (icplusplus.c:28)
    3 QtGui 0x0204a0b8 QApplicationPrivate::globalEventProcessor(OpaqueEv entHandlerCallRef*, OpaqueEventRef*, void*) + 8552 (icplusplus.c:28)
    4 com.apple.HIToolbox 0x9321c794 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 692
    5 com.apple.HIToolbox 0x9321beec SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 372
    6 com.apple.HIToolbox 0x9321bd68 SendEventToEventTargetWithOptions + 40
    7 com.apple.HIToolbox 0x932230c8 ToolboxEventDispatcherHandler(OpaqueEventHandlerCa llRef*, OpaqueEventRef*, void*) + 704
    8 com.apple.HIToolbox 0x9321c9e4 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1284
    9 com.apple.HIToolbox 0x9321beec SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 372
    10 com.apple.HIToolbox 0x93222c8c SendEventToEventTarget + 40
    11 QtGui 0x0204604c qt_mac_send_event(QFlags<QEventLoop::ProcessEvents Flag>, OpaqueEventRef*, OpaqueWindowPtr*) + 192 (icplusplus.c:28)
    12 QtGui 0x0204f2bc QEventDispatcherMac:rocessEvents(QFlags<QEventLoop::ProcessEventsFlag> ) + 568 (icplusplus.c:28)
    13 QtCore 0x013e84c4 QEventLoop:rocessEvents(QFlags<QEventLoop::ProcessEventsFlag> ) + 68 (icplusplus.c:28)
    14 QtCore 0x013e87ac QEventLoop::exec(QFlags<QEventLoop::ProcessEventsF lag>) + 140 (icplusplus.c:28)
    15 QtCore 0x013eab78 QCoreApplication::exec() + 192 (icplusplus.c:28)
    16 guitone 0x0000d114 main + 580 (main.cpp:41)
    17 guitone 0x000056d8 _start + 348 (crt.c:272)
    18 guitone 0x00005578 start + 60

    Thread 0 crashed with PPC Thread State 64:
    srr0: 0x0000000002282780 srr1: 0x000000000200f030 vrsave: 0x0000000000000000
    cr: 0x24022288 xer: 0x0000000000000000 lr: 0x00000000021dab8c ctr: 0x0000000090bc8c70
    r0: 0x00000000021dab80 r1: 0x00000000bfffef10 r2: 0x0000000001655ab0 r3: 0x0000000000000000
    r4: 0x00000000ffffe989 r5: 0x0000000000000000 r6: 0x00000000ffffe989 r7: 0x0000000001655b00
    r8: 0x0000000001655b00 r9: 0x0000000001655b00 r10: 0x0000000000000000 r11: 0x00000000ffffffff
    r12: 0x0000000000000001 r13: 0x0000000000000002 r14: 0x0000000000000000 r15: 0x00000000a321c4f8
    r16: 0x000000000161de90 r17: 0x00000000bffff350 r18: 0x0000000063757465 r19: 0x000000000000000e
    r20: 0x000000000160a790 r21: 0x00000000ffffd96e r22: 0x0000000000000000 r23: 0x00000000bffff4c0
    r24: 0x0000000000000000 r25: 0x00000000bfffef54 r26: 0x0000000001654b30 r27: 0x000000000000000e
    r28: 0x0000000071756974 r29: 0x00000000016121b0 r30: 0x0000000000000000 r31: 0x00000000021da9fc
    ...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4 + OSX: App Crash when starting application through Finder

    You have a dangling pointer somewhere, probably due to using a relative path somewhere which obviously fails. Without seeing the code it is hard to pinpoint the exact reason.

  3. #3
    Join Date
    Apr 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Qt4 + OSX: App Crash when starting application through Finder

    Indeed, it is a problem with a relative path. This is my main function:

    #include <QApplication>
    #include <QLocale>
    #include <QTranslator>
    #include "view/Guitone.h"

    int main(int argc, char** argv)
    {
    QApplication app(argc,argv);

    // try to find a suitable locale and setup translations
    QString locale = QLocale::system().name();
    QTranslator translator;
    translator.load(QString("i18n/guitone_") + locale);
    app.installTranslator(&translator);

    // create and show the main window
    Guitone *mainWnd = new Guitone();
    mainWnd->show();

    app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
    return app.exec();
    }

    When I comment out the complete translation stuff, the app does not crash anymore (Weird that the app doesn't crash on other platforms if the translations are not found. The Qt docs state that there is always a fallback to the original strings).

    Now, how can I can bring that back in? I managed it to copy the needed ressources via a script file to .app/Contents/MacOS/i18n and apparently the application picks them up (I can see the translation about a second long), but then it crashes again. Do I need to use absolute paths here? Unfortunately this is handled differently on every OS, I've found the following method for OSX:

    _NSGetExecutablePath(path, &path_len)

    Thanks in advance for your answers!

    Thomas

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 + OSX: App Crash when starting application through Finder

    Try:
    Qt Code:
    1. QString path( QCoreApplication::applicationDirPath() + "/i18n" );
    2. // or QString path( QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
    3. if( translator.load( "guitone_" + locale, path ) ) {
    4. app.installTranslator( &translator );
    5. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Apr 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Qt4 + OSX: App Crash when starting application through Finder

    This is my code - I now even set the file by hand, but the app still crashes:

    QTranslator translator;
    QString path = QCoreApplication::applicationDirPath() + "/i18n";
    if (translator.load("guitone_de.qm", path))
    {
    app.installTranslator(&translator);
    }

    Could it be that the translation file is somehow flawed? I create it as usual doing a call to lrelease, but still... any ideas?

    Thanks,
    Tommy.

  6. #6
    Join Date
    Apr 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Qt4 + OSX: App Crash when starting application through Finder

    I've disabled loading translations for OSX in the meantime. If anybody knows a resolution for this problem, please let me know. Either here or http://developer.berlios.de/bugs/?fu...&group_id=6547

    Thanks,
    Tommy.

Similar Threads

  1. Application starting slowly.
    By aj2903 in forum Qt Programming
    Replies: 3
    Last Post: 30th December 2008, 11:19
  2. Replies: 0
    Last Post: 27th May 2008, 01:00
  3. Gnome makes application crash
    By regix in forum Qt Programming
    Replies: 35
    Last Post: 18th August 2006, 19:44
  4. Starting application in full screen
    By safknw in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2006, 18:02
  5. Replies: 0
    Last Post: 21st February 2006, 16:30

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.