Hi Igor, Ops… You are right, it is not static.
I have tried your suggestion but now it crashes everytime I close the app and I can’t even get a stack trace like before. If I run it on debug, it points me to assembler code. Not anything I can really point to. Regards, Nuno > > On 07 Jan 2015, at 10:19, Igor Mironchik <igor.mironc...@gmail.com> wrote: > > On Wed, 07 Jan 2015 13:01:32 +0300, Nuno Santos <nunosan...@imaginando.pt > <mailto:nunosan...@imaginando.pt>> wrote: > >> Yes, >> >> int main(int argc, char **argv) >> { >> QGuiApplication app(argc, argv); >> >> ... >> >> return app.exec(); >> } > > No. Here QGuiApplication is not static. Then in your app the situation is the > next: QGuiApplication destroyes before your Manager. But any QObject-derived > class must be created after QApplication and destroyed before QApplication. > May be this is the reason of your crash. > > Make QGuiApplication static. For example: > > static QSharedPointer< QApplication > application( int argc = 0, char ** argv > = 0 ) > { > static QSharedPointer< QApplication > app( > new QApplication( argc, argv ) ); > > return app; > } > > and in main() > > QSharedPointer< QApplication > app = application( argc, argv ); > > before any QObject... > >> >> >>> On 07 Jan 2015, at 09:54, Igor Mironchik <igor.mironc...@gmail.com> wrote: >>> >>> Hi, I have one question: is QApplication static too? >>> >>> On Wed, 07 Jan 2015 12:32:21 +0300, Nuno Santos <nunosan...@imaginando.pt> >>> wrote: >>> >>>> Hi, >>>> >>>> I’m having a problem with a random crash that not always happens. I >>>> would like to have your advice on how to find the origin of it. >>>> >>>> This crash always happens on program exit and the stack trace is the >>>> following: >>>> >>>> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread >>>> 0 org.qt-project.QtCore 0x0000000109a03549 >>>> QMutexPrivate::allocate() + 105 >>>> 1 org.qt-project.QtCore 0x0000000109a02d1c >>>> QBasicMutex::lockInternal(int) + 92 >>>> 2 org.qt-project.QtCore 0x0000000109a02c64 QMutex::lock() + 52 >>>> 3 org.qt-project.QtCore 0x0000000109a0b6fd >>>> QWaitCondition::wait(QMutex*, unsigned long) + 173 >>>> 4 org.qt-project.QtCore 0x0000000109a0aeae >>>> QThread::wait(unsigned long) + 110 >>>> 5 org.qt-project.QtNetwork 0x000000010a4870da >>>> QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate() + 58 >>>> 6 org.qt-project.QtNetwork 0x000000010a48722e >>>> QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate() + 14 >>>> 7 org.qt-project.QtCore 0x0000000109c3e7c7 >>>> QObject::~QObject() + 1879 >>>> 8 org.qt-project.QtNetwork 0x000000010a483c16 >>>> QNetworkAccessManager::~QNetworkAccessManager() + 262 >>>> >>>> The only particularity of this QNetworkAccessManager is the fact that it >>>> is instantiated on a class that is a singleton: >>>> >>>> class Manager : public QObject >>>> { >>>> public: >>>> >>>> static Manager* sharedManager(); >>>> >>>> ... >>>> >>>> QNetworkAccessManager* networkAccessManager(); >>>> >>>> ... >>>> >>>> protected: >>>> >>>> Manager(); >>>> ~Manager(); >>>> >>>> ... >>>> >>>> QNetworkAccessManager _networkAccessManager; >>>> }; >>>> >>>> >>>> Manager* Manager::sharedManager() >>>> { >>>> QMutexLocker lock(&managerMutex); >>>> static Manager manager; >>>> return &manager; >>>> } >>>> >>>> Manager::Manager() : >>>> _networkAccessManager() >>>> { >>>> ... >>>> } >>>> >>>> Manager::~Manager() >>>> { >>>> >>>> } >>>> >>>> Is there any obvious reason for this crash to happen randomly at program >>>> termination? >>>> >>>> Thanks, >>>> >>>> Regards, >>>> >>>> Nuno Santos >>>> _______________________________________________ >>>> Interest mailing list >>>> Interest@qt-project.org >>>> http://lists.qt-project.org/mailman/listinfo/interest >>> >>> >>> -- >>> Best Regards, >>> Igor Mironchik. >>> _______________________________________________ >>> Interest mailing list >>> Interest@qt-project.org >>> http://lists.qt-project.org/mailman/listinfo/interest >> > > > -- > Best Regards, > Igor Mironchik.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest