1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Properly kill all calls in ~Core

This commit is contained in:
tux3 2015-06-05 18:53:27 +02:00
parent 1753f750b3
commit 0fd489fbba
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
4 changed files with 22 additions and 8 deletions

View File

@ -26,6 +26,7 @@
#include "src/avatarbroadcaster.h" #include "src/avatarbroadcaster.h"
#include "src/profile.h" #include "src/profile.h"
#include "corefile.h" #include "corefile.h"
#include "src/video/camerasource.h"
#include <tox/tox.h> #include <tox/tox.h>
@ -117,6 +118,15 @@ Core::~Core()
coreThread->wait(500); coreThread->wait(500);
} }
for (ToxCall call : calls)
{
if (!call.active)
continue;
hangupCall(call.callId);
if (call.camera)
delete call.camera;
}
deadifyTox(); deadifyTox();
delete[] videobuf; delete[] videobuf;

View File

@ -23,6 +23,7 @@
#include "src/audiofilterer.h" #include "src/audiofilterer.h"
#endif #endif
#include "src/misc/settings.h" #include "src/misc/settings.h"
#include <assert.h>
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
@ -228,6 +229,7 @@ void Core::cancelCall(int32_t callId, uint32_t friendId)
void Core::cleanupCall(int32_t callId) void Core::cleanupCall(int32_t callId)
{ {
assert(calls[callId].active);
qDebug() << QString("cleaning up call %1").arg(callId); qDebug() << QString("cleaning up call %1").arg(callId);
calls[callId].active = false; calls[callId].active = false;
disconnect(calls[callId].sendAudioTimer,0,0,0); disconnect(calls[callId].sendAudioTimer,0,0,0);

View File

@ -286,7 +286,7 @@ void Settings::save(bool writePersonal)
return (void) QMetaObject::invokeMethod(&getInstance(), "save", return (void) QMetaObject::invokeMethod(&getInstance(), "save",
Q_ARG(bool, writePersonal)); Q_ARG(bool, writePersonal));
QString filePath = getSettingsDirPath()+globalSettingsFile; QString filePath = getSettingsDirPath();
save(filePath, writePersonal); save(filePath, writePersonal);
} }
@ -301,14 +301,15 @@ void Settings::save(QString path, bool writePersonal)
#endif #endif
saveGlobal(path); saveGlobal(path);
if (writePersonal) // Core::switchConfiguration if (writePersonal)
savePersonal(path); savePersonal(path);
} }
void Settings::saveGlobal(QString path) void Settings::saveGlobal(QString path)
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};
qDebug() << "Saving settings in " + path; path += globalSettingsFile;
qDebug() << "Saving settings at " + path;
QSettings s(path, QSettings::IniFormat); QSettings s(path, QSettings::IniFormat);
@ -417,7 +418,7 @@ void Settings::savePersonal(QString path)
qDebug() << "Saving personal settings in " << path; qDebug() << "Saving personal settings in " << path;
QSettings ps(QFileInfo(path).dir().filePath(currentProfile + ".ini"), QSettings::IniFormat); QSettings ps(path + currentProfile + ".ini", QSettings::IniFormat);
ps.beginGroup("Friends"); ps.beginGroup("Friends");
ps.beginWriteArray("Friend", friendLst.size()); ps.beginWriteArray("Friend", friendLst.size());
int index = 0; int index = 0;
@ -552,10 +553,9 @@ bool Settings::getMakeToxPortable() const
void Settings::setMakeToxPortable(bool newValue) void Settings::setMakeToxPortable(bool newValue)
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};
QFile(getSettingsDirPath()+globalSettingsFile).remove();
makeToxPortable = newValue; makeToxPortable = newValue;
save(globalSettingsFile); // Commit to the portable file that we don't want to use it save(false);
if (!newValue) // Update the new file right now if not already done
save();
} }
bool Settings::getAutorun() const bool Settings::getAutorun() const

View File

@ -19,7 +19,9 @@ Profile::Profile(QString name, QString password, bool isNewProfile)
: name{name}, password{password}, : name{name}, password{password},
newProfile{isNewProfile}, isRemoved{false} newProfile{isNewProfile}, isRemoved{false}
{ {
Settings::getInstance().setCurrentProfile(name); Settings& s = Settings::getInstance();
s.setCurrentProfile(name);
s.save(false);
HistoryKeeper::resetInstance(); HistoryKeeper::resetInstance();
coreThread = new QThread(); coreThread = new QThread();