| Prev |   1   2   3   | Next
maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Closing an application without killing main loop (https://talk.maemo.org/showthread.php?t=91947)

coderus 2013-12-04 20:10

Re: Closing an application without killing main loop
 
install event filter

vranki 2013-12-04 20:10

Re: Closing an application without killing main loop
 
Quote:

Originally Posted by xerxes2 (Post 1392668)
Why are you calling eventLoop.exec()? You already has one mainloop running so just put your cleanup code in the aboutToQuit callback instead. The mainloop will not exit before the aboutToQuit callback returns. There was a bug in earlier sdk but in the latest version it works just fine.

The app is single threaded - everything happens in the main event loop. Everything (signals, slots, timers, networking) is frozen during aboutToQuit() call. That's why i'd need a second event loop to do processing without exiting aboutToQuit() in main thread.

vranki 2013-12-04 20:13

Re: Closing an application without killing main loop
 
Quote:

Originally Posted by coderus (Post 1392673)
install event filter

..to which event in which object? As i wrote in the original post, i already tried it with no success.

xerxes2 2013-12-04 20:26

Re: Closing an application without killing main loop
 
Quote:

Originally Posted by vranki (Post 1392674)
The app is single threaded - everything happens in the main event loop. Everything (signals, slots, timers, networking) is frozen during aboutToQuit() call. That's why i'd need a second event loop to do processing without exiting aboutToQuit() in main thread.

Afaik you can only have one mainloop in both gtk and qt. I've never heard anything about having two.

vranki 2013-12-04 20:35

Re: Closing an application without killing main loop
 
I think the reason for newly started main loop is in qwaylandeventthread.cpp line 37:

https://qt.gitorious.org/qt/qtwaylan...thread.cpp#L37

When app window is closed, the Wayland connection is broken and if something (in the new mainloop?) calls readWaylandEvents(), the process is killed.

coderus 2013-12-04 20:59

Re: Closing an application without killing main loop
 
okay, event filtering seems not to work in emulator, try:
Code:

  app->connect( app, SIGNAL(lastWindowClosed()), app, SLOT(quit()) );
  app->connect( app, SIGNAL(aboutToQuit()), app, SLOT(quit()) );

and why not to use main class destructor for this purpose?

and
Code:

    int retVal = app->exec();
    qDebug() << "App exiting with code:" << QString::number(retVal);
    //you can do whatever here
    return retVal;


vranki 2013-12-04 21:28

Re: Closing an application without killing main loop
 
Quote:

Originally Posted by coderus (Post 1392692)
and why not to use main class destructor for this purpose?

Code:

    //you can do whatever here

Signals, slots, networking, and all other asynchronous stuff does not work without a event loop. And i need those.

coderus 2013-12-04 21:32

Re: Closing an application without killing main loop
 
what about other methods?

uvatbc 2013-12-05 00:04

Re: Closing an application without killing main loop
 
Quote:

Originally Posted by vranki (Post 1392658)
Does not work - the main loop still exits. Same with Harmattan.

Well thats surprising - I've been using setQuitOnLastWindowClosed in Maemo, Harmattan, Windows and desktop Linux at least for the last two years in qgvdial to achieve exactly what you need: Running the application in the background.

https://code.google.com/p/qgvdial/so...k/src/main.cpp

vranki 2013-12-05 12:19

Re: Closing an application without killing main loop
 
Quote:

Originally Posted by uvatbc (Post 1392726)
Well thats surprising - I've been using setQuitOnLastWindowClosed in Maemo, Harmattan, Windows and desktop Linux at least for the last two years in qgvdial to achieve exactly what you need: Running the application in the background.

https://code.google.com/p/qgvdial/so...k/src/main.cpp

Ok, i think i'll need to create a simple test application for this issue.


| Prev |   1   2   3   | Next
All times are GMT. The time now is 13:25.

vBulletin® Version 3.8.8