QtSingleApplication crash
-
Re: QLocalServer crashes when QString is used instead of "string_literal"
qt version: 5.6.1
qtsingleapplication version: 2.6.11 __strlen_sse2_pminub 0x7ffff5173e71 2 QCoreApplication::arguments() 0x7ffff62ea2fd 3 sm_performSaveYourself(QXcbSessionManager *) 0x7fffe4d19470 4 sm_saveYourselfCallback(_SmcConn *, void *, int, int, int, int) 0x7fffe4d19fe5 5 _SmcProcessMessage 0x7fffedb9ec4d 6 IceProcessMessages 0x7fffeddb2ab7 7 QMetaObject::activate(QObject *, int, int, void * *) 0x7ffff630ece1 8 QSocketNotifier::activated(int, QSocketNotifier::QPrivateSignal) 0x7ffff638067e 9 QSocketNotifier::event(QEvent *) 0x7ffff631b809 10 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x7ffff6d30bec 11 QApplication::notify(QObject *, QEvent *) 0x7ffff6d355b2 12 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x7ffff62e6d86 13 socketNotifierSourceDispatch(_GSource *, int ( *)(void *), void *) 0x7ffff6334ca0 14 g_main_context_dispatch 0x7ffff4070d7a 15 g_main_context_iterate.isra.24 0x7ffff40710b8 16 g_main_context_iteration 0x7ffff407116c 17 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 0x7ffff633409c 18 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) 0x7ffff62e58eb 19 QCoreApplication::exec() 0x7ffff62ed426 20 main main.cpp 88 0x45bdce
-
I think I know what's going on. Can I see your main?
-
@xiaofeng Nevermind I see the code in the thread you linked, and confirmed my suspicion.
SingleInstance::SingleInstance(int argc, char *argv[]) : QApplication(argc, argv), mServerName("foo") {
If you see here
SingleInstance
takes anint argc
instead ofint &argc
, any argc passed to QApplication needs to be modifiable and as it's a reference. Change your definition toint &argc
and your crash will be gone. -
@ambershark Thanks so much. I didn't recognize it's an
int &argc
for so many years, thanks. -
@ambershark said in qtsingleapplication crash:
I'm not sure why they do the int &
Because
QCoreApplication
processes and possibly modifies the command line, as it has its own set of flags it responds to. -
@kshegunov Ah that makes a lot of sense. I figured they had a good reason for it. Qt is well thought out. :)
-