![]() |
2013-12-04
, 17:15
|
|
Moderator |
Posts: 2,622 |
Thanked: 5,447 times |
Joined on Jan 2010
|
#2
|
![]() |
2013-12-04
, 17:22
|
|
Posts: 513 |
Thanked: 651 times |
Joined on Feb 2011
@ Sweden
|
#3
|
![]() |
2013-12-04
, 17:48
|
|
Posts: 3,404 |
Thanked: 4,474 times |
Joined on Oct 2005
@ Germany
|
#4
|
app->setQuitOnLastWindowClosed(false);
The Following User Says Thank You to pycage For This Useful Post: | ||
![]() |
2013-12-04
, 17:48
|
|
Posts: 2,355 |
Thanked: 5,249 times |
Joined on Jan 2009
@ Barcelona
|
#5
|
I'm writing an application which has to do dome network operations after user has closed the UI. Normally this is not possible, as the applications Qt main loop exits when closing the UI.
![]() |
2013-12-04
, 19:36
|
Posts: 50 |
Thanked: 100 times |
Joined on Jan 2012
@ Tampere, Finland
|
#6
|
![]() |
2013-12-04
, 19:47
|
Posts: 50 |
Thanked: 100 times |
Joined on Jan 2012
@ Tampere, Finland
|
#7
|
I think what you want is the aboutToQuit signal which doesn't quit the mainloop until its callback returns.
http://qt-project.org/doc/qt-5.0/qtc...ml#aboutToQuit
// Called when app about to quit - handle upsync & quitting void ClientLogic::aboutToQuit() { qDebug() << Q_FUNC_INFO; QEventLoop eventLoop; eventLoop.exec(); }
virtual void ClientLogic::aboutToQuit() The Wayland connection broke. Did the Wayland compositor die? Killing all inferiors Debugging has finished
![]() |
2013-12-04
, 19:54
|
|
Posts: 6,436 |
Thanked: 12,701 times |
Joined on Nov 2011
@ Ängelholm, Sweden
|
#8
|
![]() |
2013-12-04
, 20:00
|
|
Posts: 513 |
Thanked: 651 times |
Joined on Feb 2011
@ Sweden
|
#9
|
I created a aboutToQuit slot like this:
On emulator quitting with this results in output:Code:// Called when app about to quit - handle upsync & quitting void ClientLogic::aboutToQuit() { qDebug() << Q_FUNC_INFO; QEventLoop eventLoop; eventLoop.exec(); }
Debugger just displays ??'s as stack trace so it's useless. The crash happens when eventLoop.exec() is called.Code:virtual void ClientLogic::aboutToQuit() The Wayland connection broke. Did the Wayland compositor die? Killing all inferiors Debugging has finished
![]() |
2013-12-04
, 20:05
|
Posts: 50 |
Thanked: 100 times |
Joined on Jan 2012
@ Tampere, Finland
|
#10
|
isnt better to rewrite logics?
set event filter, catch close event, do whatever.
I'm writing an application which has to do dome network operations after user has closed the UI. Normally this is not possible, as the applications Qt main loop exits when closing the UI.
On Harmattan i found a workaround - re-starting the mainloop by calling QGuiApplication::exec(). This seems to crash on Sailfish.
The next workaround i tried to use is to create an event filter for the QGuiApplication and try to filter out the close event. QEvent::Close never happens, but QEvent::ApplicationDeactivate does. It can be used to prevent killing main loop, but unfortunately it also happens when user swipes the application to the background.
Any ideas on how can i accomplish this?