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

fix(core): add missing nullptr check

fix #4324
This commit is contained in:
sudden6 2017-05-05 23:21:07 +02:00
parent 6a6e30d639
commit 407413c65b
No known key found for this signature in database
GPG Key ID: 279509B499E032B9

View File

@ -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<const uint8_t*>(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*>(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*>(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;