mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-31 10:59:23 +00:00
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";
|
||||
mLinphoneThread->start();
|
||||
}
|
||||
setQuitOnLastWindowClosed(true); // TODO: use settings to set it
|
||||
|
||||
// QML
|
||||
mEngine = new QQmlApplicationEngine(this);
|
||||
|
|
@ -148,6 +149,10 @@ void App::initCppInterfaces() {
|
|||
|
||||
void App::clean() {
|
||||
// Wait 500ms to let time for log te be stored.
|
||||
delete mNotifier;
|
||||
mNotifier = nullptr;
|
||||
delete mEngine;
|
||||
mEngine = nullptr;
|
||||
mLinphoneThread->wait(250);
|
||||
qApp->processEvents(QEventLoop::AllEvents, 250);
|
||||
mLinphoneThread->exit();
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ public:
|
|||
QQmlApplicationEngine *mEngine = nullptr;
|
||||
bool notify(QObject *receiver, QEvent *event);
|
||||
|
||||
enum class StatusCode { gRestartCode = 1000, gDeleteDataCode = 1001 };
|
||||
|
||||
private:
|
||||
void createCommandParser();
|
||||
|
||||
|
|
|
|||
|
|
@ -118,9 +118,11 @@ Notifier::~Notifier() {
|
|||
delete mMutex;
|
||||
|
||||
const int nComponents = Notifications.size();
|
||||
for (int i = 0; i < nComponents; ++i)
|
||||
mComponents[i]->deleteLater();
|
||||
delete[] mComponents;
|
||||
if (mComponents) {
|
||||
for (int i = 0; i < nComponents; ++i)
|
||||
if (mComponents[i]) mComponents[i]->deleteLater();
|
||||
delete[] mComponents;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -46,9 +46,10 @@ int main(int argc, char *argv[]) {
|
|||
#endif
|
||||
|
||||
int result = 0;
|
||||
while (result >= 0) {
|
||||
do {
|
||||
result = app.exec();
|
||||
}
|
||||
} while (result == (int)App::StatusCode::gRestartCode);
|
||||
qWarning() << "[Main] Exiting app with the code : " << result;
|
||||
app.clean();
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ bool Thread::mustBeInLinphoneThread(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;
|
||||
return isMainThread;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue