Fix CApplication::processEventsFor so it can be used in samples/unit tests

This commit is contained in:
Klaus Basan
2017-08-14 22:29:32 +02:00
committed by Mathew Sutcliffe
parent 769e3a0e29
commit a993ccd1c1
2 changed files with 5 additions and 4 deletions

View File

@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
if (clientFlag)
{
// 2nd Process !!! Running on the client's side
// This runs in a second process, hence cannot be directly debugged within Qt Creators
// This runs in a second process, hence cannot be directly debugged within Qt Creator
out << "Running client side " << QCoreApplication::applicationPid() << endl;
// run tests
@@ -161,8 +161,8 @@ int main(int argc, char *argv[])
BlackMisc::CDBusServer *dBusServer = new BlackMisc::CDBusServer(useSessionBusForServer ? "session" : address);
if (dBusServer->hasQDBusServer())
{
out << "server" << dBusServer->qDBusServer()->address() <<
" connected:" << dBusServer->qDBusServer()->isConnected() << endl;
out << "server" << dBusServer->qDBusServer()->address()
<< " connected:" << dBusServer->qDBusServer()->isConnected() << endl;
}
// start client process
QStringList args;

View File

@@ -712,7 +712,8 @@ namespace BlackCore
void CApplication::processEventsFor(int milliseconds)
{
if (CApplication::instance()->isShuttingDown()) { return; }
// sApp check allows to use in test cases without sApp
if (sApp && sApp->isShuttingDown()) { return; }
QEventLoop eventLoop;
QTimer::singleShot(milliseconds, &eventLoop, &QEventLoop::quit);
eventLoop.exec();