From 0cda1431ec22aa38bd835581d1a82e945d67e17c Mon Sep 17 00:00:00 2001 From: mappu Date: Tue, 2 Oct 2018 19:27:51 +1300 Subject: [PATCH] qpulse: properly deref requested operation objects --- qpulse.cpp | 18 ++++++++++++++---- qpulse.h | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/qpulse.cpp b/qpulse.cpp index 6603803..5739d29 100644 --- a/qpulse.cpp +++ b/qpulse.cpp @@ -27,18 +27,28 @@ pa_context_state_t QPulse::ConnectionState() return pa_context_get_state(c); } -void QPulse::RequestServerInfo() +bool QPulse::RequestServerInfo() { //ThreadedMainLoopLock lock(ml); - pa_context_get_server_info(c, &QPulse::onGotServerInfoSt, this); + pa_operation* o = pa_context_get_server_info(c, &QPulse::onGotServerInfoSt, this); + if (! o) { + return false; + } + + pa_operation_unref(o); } -void QPulse::RequestCardInfo() +bool QPulse::RequestCardInfo() { //ThreadedMainLoopLock lock(ml); - pa_context_get_card_info_list(c, &QPulse::onGotCardInfoListSt, this); + pa_operation* o = pa_context_get_card_info_list(c, &QPulse::onGotCardInfoListSt, this); + if (! o) { + return false; + } + + pa_operation_unref(o); } void QPulse::onGotCardInfoListSt(pa_context*, const pa_card_info *i, int eol, void *userdata) diff --git a/qpulse.h b/qpulse.h index 4ae8373..0974036 100644 --- a/qpulse.h +++ b/qpulse.h @@ -13,8 +13,8 @@ public: pa_context_state_t ConnectionState(); - void RequestServerInfo(); - void RequestCardInfo(); + bool RequestServerInfo(); + bool RequestCardInfo(); signals: void ConnectionStateChanged();