Fix restart behavior:
- fix crash. - exit on last window closed. - add return staus code for later use.
This commit is contained in:
parent
1938ae65e0
commit
bdf1d197ec
5 changed files with 17 additions and 6 deletions
|
|
@ -86,6 +86,7 @@ void App::init() {
|
||||||
qDebug() << "[App] Starting Thread";
|
qDebug() << "[App] Starting Thread";
|
||||||
mLinphoneThread->start();
|
mLinphoneThread->start();
|
||||||
}
|
}
|
||||||
|
setQuitOnLastWindowClosed(true); // TODO: use settings to set it
|
||||||
|
|
||||||
// QML
|
// QML
|
||||||
mEngine = new QQmlApplicationEngine(this);
|
mEngine = new QQmlApplicationEngine(this);
|
||||||
|
|
@ -148,6 +149,10 @@ void App::initCppInterfaces() {
|
||||||
|
|
||||||
void App::clean() {
|
void App::clean() {
|
||||||
// Wait 500ms to let time for log te be stored.
|
// Wait 500ms to let time for log te be stored.
|
||||||
|
delete mNotifier;
|
||||||
|
mNotifier = nullptr;
|
||||||
|
delete mEngine;
|
||||||
|
mEngine = nullptr;
|
||||||
mLinphoneThread->wait(250);
|
mLinphoneThread->wait(250);
|
||||||
qApp->processEvents(QEventLoop::AllEvents, 250);
|
qApp->processEvents(QEventLoop::AllEvents, 250);
|
||||||
mLinphoneThread->exit();
|
mLinphoneThread->exit();
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,8 @@ public:
|
||||||
QQmlApplicationEngine *mEngine = nullptr;
|
QQmlApplicationEngine *mEngine = nullptr;
|
||||||
bool notify(QObject *receiver, QEvent *event);
|
bool notify(QObject *receiver, QEvent *event);
|
||||||
|
|
||||||
|
enum class StatusCode { gRestartCode = 1000, gDeleteDataCode = 1001 };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createCommandParser();
|
void createCommandParser();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,11 @@ Notifier::~Notifier() {
|
||||||
delete mMutex;
|
delete mMutex;
|
||||||
|
|
||||||
const int nComponents = Notifications.size();
|
const int nComponents = Notifications.size();
|
||||||
|
if (mComponents) {
|
||||||
for (int i = 0; i < nComponents; ++i)
|
for (int i = 0; i < nComponents; ++i)
|
||||||
mComponents[i]->deleteLater();
|
if (mComponents[i]) mComponents[i]->deleteLater();
|
||||||
delete[] mComponents;
|
delete[] mComponents;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,10 @@ int main(int argc, char *argv[]) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
while (result >= 0) {
|
do {
|
||||||
result = app.exec();
|
result = app.exec();
|
||||||
}
|
} while (result == (int)App::StatusCode::gRestartCode);
|
||||||
|
qWarning() << "[Main] Exiting app with the code : " << result;
|
||||||
app.clean();
|
app.clean();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ bool Thread::mustBeInLinphoneThread(const QString &context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Thread::mustBeInMainThread(const QString &context) {
|
bool Thread::mustBeInMainThread(const QString &context) {
|
||||||
bool isMainThread = QThread::currentThread() == App::getInstance()->thread();
|
if (!qApp) return true;
|
||||||
|
bool isMainThread = QThread::currentThread() == qApp->thread();
|
||||||
if (!isMainThread) qCritical() << "[Thread] Not processing in Main thread from " << context;
|
if (!isMainThread) qCritical() << "[Thread] Not processing in Main thread from " << context;
|
||||||
return isMainThread;
|
return isMainThread;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue