mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-03-09 08:30:24 -04:00
Properly run Qt event loop
Check RsControlModule.processShouldExit() via a lazy timer this should guarantee QCoreApplication enough autonomy to gracefully handle any event specially stop
This commit is contained in:
parent
d80a806d2a
commit
c1d8d6a52d
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* RetroShare Android Service
|
* RetroShare Android Service
|
||||||
* Copyright (C) 2016-2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
* Copyright (C) 2016-2018 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMetaObject>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
# include "util/androiddebug.h"
|
# include "util/androiddebug.h"
|
||||||
@ -52,16 +52,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
ApiServerLocal apiServerLocal(&api, sockPath); (void) apiServerLocal;
|
ApiServerLocal apiServerLocal(&api, sockPath); (void) apiServerLocal;
|
||||||
|
|
||||||
while (!ctrl_mod.processShouldExit())
|
QTimer shouldExitTimer;
|
||||||
{
|
QObject::connect( &shouldExitTimer, &QTimer::timeout, [&](){
|
||||||
app.processEvents();
|
if(ctrl_mod.processShouldExit()) app.quit(); });
|
||||||
usleep(20000);
|
shouldExitTimer.start();
|
||||||
}
|
|
||||||
|
|
||||||
/* Since QCoreApplication::quit() is a no-op until the event loop has been
|
|
||||||
* started, we need to defer the call until it starts. Thus, we queue a
|
|
||||||
* deferred method call to quit() */
|
|
||||||
QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user