diff --git a/src/core/coreav.cpp b/src/core/coreav.cpp index 2b9ce1728..a7e7f3d69 100644 --- a/src/core/coreav.cpp +++ b/src/core/coreav.cpp @@ -62,7 +62,7 @@ CoreAV::~CoreAV() { for (const ToxFriendCall& call : calls) cancelCall(call.callId); - stop(); + killTimerFromThread(); toxav_kill(toxav); } @@ -87,6 +87,14 @@ void CoreAV::stop() iterateTimer->stop(); } +void CoreAV::killTimerFromThread() +{ + // Timers can only be touched from their own thread + if (QThread::currentThread() != coreavThread.get()) + return (void)QMetaObject::invokeMethod(this, "killTimerFromThread", Qt::BlockingQueuedConnection); + iterateTimer.release(); +} + void CoreAV::process() { toxav_iterate(toxav); diff --git a/src/core/coreav.h b/src/core/coreav.h index f0ead1459..279a5905f 100644 --- a/src/core/coreav.h +++ b/src/core/coreav.h @@ -98,6 +98,7 @@ private slots: static void callCallback(ToxAV *toxAV, uint32_t friendNum, bool audio, bool video, void* self); static void stateCallback(ToxAV *, uint32_t friendNum, uint32_t state, void* self); static void bitrateCallback(ToxAV *toxAV, uint32_t friendNum, uint32_t arate, uint32_t vrate, void* self); + void killTimerFromThread(); ///< Calls itself blocking queued on the coreav thread private: void process();