From 47cc6adab11958bcdd50bb24817f9429f1f566bb Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 27 Oct 2020 02:44:13 +0300 Subject: Fix quitting the application Event emitter should only be freed when it emits NULL. Previously dc_accounts_event_emitter_unref() was called earlier then needed, causing use-after-free. As a result, the application got stuck waiting for event emitter thread to finish. --- eventemitter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'eventemitter.h') diff --git a/eventemitter.h b/eventemitter.h index 0b18a8e..21a8af1 100644 --- a/eventemitter.h +++ b/eventemitter.h @@ -17,6 +17,8 @@ class EventLoopThread : public QThread while((event = dc_accounts_get_next_event(m_eventEmitter))) { emit emitEvent(new DcEvent{event}); } + dc_accounts_event_emitter_unref(m_eventEmitter); + std::cout << "NO MORE EVENTS!" << std::endl; } public: @@ -44,7 +46,6 @@ public: ~DcAccountsEventEmitter(); Q_INVOKABLE void start(); - Q_INVOKABLE void stop(); Q_INVOKABLE void processEvent(DcEvent *event); signals: -- cgit v1.2.3-70-g09d2