Crash on launch with file on Mac
-
Appreciate the response. I did look at the browser sample, and it looks to me like they're doing the same thing that I'm doing. I may need to fall back to the old approach of incrementally changing their code into my code, but it's so different that I was hoping to avoid that.
Thanks,
Aaron -
Here's what I've got at the moment. Note that the crash still happens without any of the code in the body of either function.
@
explicit MapMakerApplication(int argc, char **argv);
~MapMakerApplication();MapMakerApplication::MapMakerApplication(int argc, char **argv)
: QApplication(argc, argv)
{
logFile = fopen("/Users/asher/logs/MMLog.txt", "a");
fprintf(logFile, "------------------------------------------------------------------\nStarting log\n");
fflush(logFile);
}
MapMakerApplication::~MapMakerApplication()
{
for (int i = 0; i < _windows.size(); ++i)
delete _windows.at(i);
_windows.clear();
}@If it helps, I'm never actually getting the FileOpenEvent before the crash. However, if I start the application directly or through the debugger, it launches fine.
Thanks,
Aaron -
Ok, exactly what I have guessed. Your problem has nothing to do with the QFileOpenEvent. Just change your constructor signature
from
@
explicit MapMakerApplication(int argc, char **argv);
@to
@
explicit MapMakerApplication(int &argc, char **argv);
@Note the reference ampersand for argc! There are some threads around in the forums that explain the faulty behavior. Basically it's due to QCoreApplication's requirement of argc to stay valid during its lifetime, which is not the case for pass-by-value arguments.
PS:
[quote author="aaronsher" date="1342628763"]Just to be clear, though, if I don't subclass QApplication, I have no trouble, so it's something about the structure of this class.
[/quote]Which proofs my guess even more ;-)
-
Hello,
I have a similar problem but I can't find this "browser" demo. Can someone tell me which folder is it in?Thanks
-
Aah so this demo is QT 4.7 specific! I am using Qt 4.8 and this demo wasn't available. I just downloaded the 4.7 version to get the demo. Thank you.
-
[quote author="aaronsher" date="1342629125"]Cool, thanks! Wow, that's one I never would have guessed, though looking again at the browser sample I see that they are doing that and I missed it the first time.
Aaron[/quote]
Please mark the title as Solved :)
-
[SOLVED] How do I do that?
-
Hi All,
I am getting very similar crash using Qt 4.8.5 on OSX 10.9When I double click my file in Finder while my application is running it opens correctly, but if my application is not already running I get a crash just after showing its splash screen, note that I am using the correct int& argc in my inherited QApplication
Part of the crash stack:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 QtCore 0x000000010315614a QString::fromLocal8Bit(char const*, int) + 42
1 QtCore 0x000000010321d9cc QCoreApplication::arguments() + 124
2 QtGui 0x000000010356a77f QMacInputContext::reset() + 49311
3 com.apple.AppKit 0x00007fff8810ef65 __69-[NSApplication(NSAppleEventHandling) _handleAEOpenDocumentsForURLs:]_block_invoke + 1651
4 com.apple.AppKit 0x00007fff87f0ac63 __78-[NSDocumentController(NSInternal) _autoreopenDocumentsWithCompletionHandler:]_block_invoke_2 + 140
5 com.apple.AppKit 0x00007fff87f0a84d -[NSDocumentController(NSInternal) _autoreopenDocumentsWithCompletionHandler:] + 746
6 com.apple.AppKit 0x00007fff87d759fb -[NSApplication _reopenWindowsAsNecessaryIncludingRestorableState:registeringAsReady:completionHandler:] + 323
7 com.apple.AppKit 0x00007fff8810e869 -[NSApplication(NSAppleEventHandling) _handleAEOpenDocumentsForURLs:] + 306
8 com.apple.AppKit 0x00007fff87d752bb -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 450
9 com.apple.Foundation 0x00007fff89a0eeaa -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294
10 com.apple.Foundation 0x00007fff89a0ed1d _NSAppleEventManagerGenericHandler + 106
11 com.apple.AE 0x00007fff83d55e1f aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 381
12 com.apple.AE 0x00007fff83d55c32 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31
13 com.apple.AE 0x00007fff83d55b36 aeProcessAppleEvent + 315
14 com.apple.HIToolbox 0x00007fff877495f1 AEProcessAppleEvent + 56
15 com.apple.AppKit 0x00007fff87d710f6 _DPSNextEvent + 1026
16 com.apple.AppKit 0x00007fff87d708db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
17 com.apple.AppKit 0x00007fff87d649cc -[NSApplication run] + 553
18 QtGui 0x0000000103572171 QDesktopWidget::resizeEvent(QResizeEvent*) + 3553
19 QtGui 0x0000000103574070 QDesktopWidget::resizeEvent(QResizeEvent*) + 11488
20 QtCore 0x000000010321c745 QCoreApplication::processEvents(QFlagsQEventLoop::ProcessEventsFlag) + 69
21 QtGui 0x0000000103614aaf QWidgetPrivate::show_helper() + 639
22 QtGui 0x0000000103614cff QWidget::setVisible(bool) + 511
....Last thing, I found when outputting application argc in exec function that it is not 1 as when I run it from QCreator, it is 24576!
I hope someone had found a solution for this because I've been trying to sort it for a week
thanks in advance