stop rewrite

This commit is contained in:
Julien Wadel 2021-10-13 17:03:18 +02:00
parent 2912e6c9d3
commit 2e4c439ee5
4 changed files with 30 additions and 16 deletions

View file

@ -159,7 +159,7 @@
</message>
<message>
<source>usernameStatusInvalidCharacters</source>
<translation>Caractères invalides détectés (regex: `%1`).</translation>
<translation>Caractères invalides détectés (regex&#x202f;: `%1`).</translation>
</message>
<message>
<source>usernameStatusInvalid</source>
@ -175,7 +175,7 @@
</message>
<message>
<source>passwordStatusInvalidCharacters</source>
<translation>Caractères invalides détectés (regex: `%1`).</translation>
<translation>Caractères invalides détectés (regex&#x202f;: `%1`).</translation>
</message>
<message>
<source>passwordStatusMissingCharacters</source>
@ -1883,7 +1883,7 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
</message>
<message>
<source>serverTooltip</source>
<translation>Serveur LDAP. ie: ldap:// pour un serveur local ou ldap://ldap.example.org/</translation>
<translation>Serveur LDAP. ie&#x202f;: ldap:// pour un serveur local ou ldap://ldap.example.org/</translation>
</message>
<message>
<source>bindDNLabel</source>

View file

@ -697,6 +697,10 @@ void App::registerSharedToolTypes () {
// -----------------------------------------------------------------------------
void App::setTrayIcon () {
if(mSystemTrayIcon){
mSystemTrayIcon->hide();
delete mSystemTrayIcon;
}
QQuickWindow *root = getMainWindow();
QSystemTrayIcon *systemTrayIcon = new QSystemTrayIcon(mEngine);
@ -750,6 +754,7 @@ void App::setTrayIcon () {
systemTrayIcon->setIcon(QIcon(Constants::WindowIconPath));
systemTrayIcon->setToolTip(APPLICATION_NAME);
systemTrayIcon->show();
mSystemTrayIcon = systemTrayIcon;
if(!QSystemTrayIcon::isSystemTrayAvailable())
qInfo() << "System tray is not available";

View file

@ -72,7 +72,6 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) :
QObject::connect(coreHandlers, &CoreHandlers::coreStarting, this, &CoreManager::startIterate, Qt::QueuedConnection);
QObject::connect(coreHandlers, &CoreHandlers::setLastRemoteProvisioningState, this, &CoreManager::setLastRemoteProvisioningState);
QObject::connect(coreHandlers, &CoreHandlers::coreStarted, this, &CoreManager::initCoreManager, Qt::QueuedConnection);
QObject::connect(coreHandlers, &CoreHandlers::coreStopped, this, &CoreManager::stopIterate, Qt::QueuedConnection);
QObject::connect(coreHandlers, &CoreHandlers::logsUploadStateChanged, this, &CoreManager::handleLogsUploadStateChanged);
QTimer::singleShot(10, [this, configPath](){// Delay the creation in order to have the CoreManager instance set before
createLinphoneCore(configPath);
@ -134,14 +133,12 @@ void CoreManager::init (QObject *parent, const QString &configPath) {
void CoreManager::uninit () {
if (mInstance) {
connect(mInstance, &QObject::destroyed, []()mutable{
mInstance = nullptr;
qInfo() << "Core is correctly destroyed";
mInstance = nullptr;
});
QObject::connect(mInstance->getHandlers().get(), &CoreHandlers::coreStopped, mInstance, &QObject::deleteLater, Qt::QueuedConnection); // Delete data only when the core is Off
mInstance->stopIterate();
mInstance->lockVideoRender();// Stop do iterations. We have to protect GUI.
mInstance->mCore->stop();
mInstance->unlockVideoRender();
qInfo() << "Waiting for completion of stopping core";
QTest::qWaitFor([&]() {return mInstance == nullptr;},10000);
if( mInstance){
@ -348,17 +345,28 @@ void CoreManager::startIterate(){
}
void CoreManager::stopIterate(){
qInfo() << QStringLiteral("Stop iterate");
mCbsTimer->stop();
mCbsTimer->deleteLater();// allow the timer to continue its stuff
mCbsTimer = nullptr;
qInfo() << QStringLiteral("Stopping iterate");
mCbsTimerStop = true;
}
void CoreManager::iterate () {
lockVideoRender();
if(mCore)
mCore->iterate();
unlockVideoRender();
if( mCbsTimerStop){
qInfo() << QStringLiteral("Stop iterate");
mCbsTimerStop = false;
mCbsTimer->stop();
mCbsTimer->deleteLater();// allow the timer to continue its stuff
mCbsTimer = nullptr;
qInfo() << "Stopping core";
mCore->stop();
}else{
lockVideoRender();
if(mCore){
auto state = mCore->getGlobalState();
if( state != linphone::GlobalState::Shutdown && state != linphone::GlobalState::Off)
mCore->iterate();
}
unlockVideoRender();
}
}
// -----------------------------------------------------------------------------

View file

@ -229,6 +229,7 @@ private:
LdapListModel *mLdapListModel = nullptr;
QTimer *mCbsTimer = nullptr;
bool mCbsTimerStop = false;
QMutex mMutexVideoRender;