diff --git a/src/core/core.cpp b/src/core/core.cpp index ca51b2705..795402390 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -141,8 +141,7 @@ Tox_Options initToxOptions(const QByteArray& savedata) toxOptions.proxy_type = TOX_PROXY_TYPE_NONE; toxOptions.proxy_host = nullptr; toxOptions.proxy_port = 0; - toxOptions.savedata_type = !savedata.isNull() ? TOX_SAVEDATA_TYPE_TOX_SAVE - : TOX_SAVEDATA_TYPE_NONE; + toxOptions.savedata_type = !savedata.isNull() ? TOX_SAVEDATA_TYPE_TOX_SAVE : TOX_SAVEDATA_TYPE_NONE; toxOptions.savedata_data = reinterpret_cast(savedata.data()); toxOptions.savedata_length = savedata.size(); @@ -239,6 +238,10 @@ void Core::makeTox(QByteArray savedata) */ void Core::makeAv() { + if (!tox) { + qCritical() << "No Tox instance, can't create ToxAV"; + return; + } av = new CoreAV(tox); if (!av->getToxAv()) { qCritical() << "Toxav core failed to start"; @@ -443,11 +446,7 @@ void Core::onFriendMessage(Tox*, uint32_t friendId, TOX_MESSAGE_TYPE type, const emit static_cast(core)->friendMessageReceived(friendId, msg, isAction); } -void Core::onFriendNameChange(Tox*, - uint32_t friendId, - const uint8_t* cName, - size_t cNameSize, - void* core) +void Core::onFriendNameChange(Tox*, uint32_t friendId, const uint8_t* cName, size_t cNameSize, void* core) { QString newName = ToxString(cName, cNameSize).getQString(); emit static_cast(core)->friendUsernameChanged(friendId, newName); @@ -1470,7 +1469,9 @@ void Core::setNospam(uint32_t nospam) void Core::killTimers(bool onlyStop) { assert(QThread::currentThread() == coreThread); - av->stop(); + if (av) { + av->stop(); + } toxTimer->stop(); if (!onlyStop) { delete toxTimer;