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

   // parsing other arguments of argc,argv

   return app.exec();
}

My problem is the following: Function may be returned during parsing other arguments (without reaching app.exec()) and when QApplication object is deleted I am getting following error message QThread: Destroyed while thread is still running. As a possible solution I am trying to create QApplication after argument parsing is done.

I have tried app.thread()->quit(); before return statement but it doesn't help.

When QApplication object is created it removes specific arguments (-style, etc.) from argc, argv.

Is it possible to get them from argc, argv manually without creating QApplication object?

It is weird that in a single threaded program I am getting QThread: Destroyed while thread is still running error.

The best "solution" I have found so far is to create QApplication dynamically and not to delete it. The memory leak is not an issue because it is leaked just before program exits.

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122
Ashot
  • 10,807
  • 14
  • 66
  • 117
  • 1
    Will you provide a [MCVE](http://stackoverflow.com/help/mcve)? – Leon Sep 05 '16 at 07:56
  • Sorry but I can't. On MCVE error message disappears. Problem is related to our build system and one specific platform. Maybe wrong library is linked. I just need workaround to suppress wrong error message. – Ashot Sep 05 '16 at 08:00
  • @Ashot Some Qt classes create threads behind the scenes (such as `QFileSystemWatcher` and some of the networking classes), so your application may not necessarily be single threaded. – RA. Sep 05 '16 at 21:13
  • [This answer](http://stackoverflow.com/questions/20616585/qts-default-threads) may be of interest here. – TheDarkKnight Sep 06 '16 at 08:38

0 Answers0