refactor: bringing error code from the application thread to the main thread (and using its exit code to exit)
This commit is contained in:
parent
1854e469f4
commit
71c25b3ab9
3 changed files with 18 additions and 2 deletions
|
|
@ -111,9 +111,13 @@ int main(int argc, char **argv)
|
|||
QObject::connect(&coreThread, &QThread::finished, &app, &QApplication::quit);
|
||||
coreApp->run(coreThread);
|
||||
|
||||
const auto exitCode = QApplication::exec();
|
||||
int exitCode = QApplication::exec();
|
||||
coreThread.wait();
|
||||
|
||||
if (exitCode == s_exitSuccess) {
|
||||
exitCode = coreApp->getExitCode();
|
||||
}
|
||||
|
||||
LOG_DEBUG("core exited, code: %d", exitCode);
|
||||
return exitCode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ void App::run(QThread &coreThread)
|
|||
if (result == s_exitSuccess) {
|
||||
LOG_INFO("core stopped successfully");
|
||||
} else {
|
||||
// TODO: surface error code to main thread somehow
|
||||
updateExitCode(result);
|
||||
LOG_ERR("core stopped with error code: %d", result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "base/EventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "common/ExitCodes.h"
|
||||
#include "deskflow/IApp.h"
|
||||
#include "net/SocketMultiplexer.h"
|
||||
|
||||
|
|
@ -107,6 +108,16 @@ public:
|
|||
|
||||
void handleScreenError() const;
|
||||
|
||||
void updateExitCode(int errorCode)
|
||||
{
|
||||
m_exitCode = errorCode;
|
||||
}
|
||||
|
||||
int getExitCode() const
|
||||
{
|
||||
return m_exitCode;
|
||||
}
|
||||
|
||||
protected:
|
||||
void runEventsLoop(const void *);
|
||||
|
||||
|
|
@ -118,6 +129,7 @@ private:
|
|||
ARCH_APP_UTIL m_appUtil;
|
||||
std::unique_ptr<SocketMultiplexer> m_socketMultiplexer;
|
||||
QString m_pname;
|
||||
int m_exitCode = s_exitSuccess;
|
||||
};
|
||||
|
||||
#if !defined(WINAPI_LIBEI) && WINAPI_XWINDOWS
|
||||
|
|
|
|||
Loading…
Reference in a new issue