Use CEventLoop to process events until a signal is received

refs #869
This commit is contained in:
Roland Winklmeier
2017-02-17 18:10:01 +01:00
committed by Mathew Sutcliffe
parent 63f625fe4e
commit 66cf96d47f
2 changed files with 15 additions and 28 deletions

View File

@@ -20,6 +20,7 @@
#include "blackmisc/datacache.h"
#include "blackmisc/dbusserver.h"
#include "blackmisc/directoryutils.h"
#include "blackmisc/eventloop.h"
#include "blackmisc/filelogger.h"
#include "blackmisc/logcategory.h"
#include "blackmisc/logcategorylist.h"
@@ -349,13 +350,10 @@ namespace BlackCore
CStatusMessageList CApplication::waitForSetup()
{
if (!this->m_setupReader) { return CStatusMessage(this).error("No setup reader"); }
if (!this->m_setupReader->isSetupAvailable())
CEventLoop::processEventsUntil(this, &CApplication::setupHandlingCompleted, 5000, [this]
{
QEventLoop eventLoop;
QTimer::singleShot(5000, &eventLoop, &QEventLoop::quit);
connect(this, &CApplication::setupHandlingCompleted, &eventLoop, &QEventLoop::quit);
eventLoop.exec();
}
return this->m_setupReader->isSetupAvailable();
});
// setup handling completed with success or failure, or we run into time out
if (this->m_setupReader->isSetupAvailable()) { return CStatusMessage(this).info("Setup available"); }