From 2d6e6c8006f1ec5f301b3c969011cee483fdacde Mon Sep 17 00:00:00 2001 From: mappu Date: Tue, 2 Oct 2018 19:27:25 +1300 Subject: [PATCH] convert passed pa struct from pointer to const reference --- qpulse.cpp | 4 ++-- qpulse.h | 4 ++-- trayicon.cpp | 22 ++++++++-------------- trayicon.h | 2 +- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/qpulse.cpp b/qpulse.cpp index 1198dd2..6603803 100644 --- a/qpulse.cpp +++ b/qpulse.cpp @@ -46,7 +46,7 @@ void QPulse::onGotCardInfoListSt(pa_context*, const pa_card_info *i, int eol, vo QPulse* qp = static_cast(userdata); //ThreadedMainLoopLock lock(qp->ml); - emit qp->GotCardInfoList(i, eol); + emit qp->GotCardInfoList(*i, eol); } void QPulse::onGotServerInfoSt(pa_context*, const pa_server_info *i, void *userdata) @@ -54,7 +54,7 @@ void QPulse::onGotServerInfoSt(pa_context*, const pa_server_info *i, void *userd QPulse* qp = static_cast(userdata); //ThreadedMainLoopLock lock(qp->ml); - emit qp->GotServerInfo(i); + emit qp->GotServerInfo(*i); } void QPulse::onConnectionStateChangedSt(pa_context*, void *userdata) diff --git a/qpulse.h b/qpulse.h index 7cbfbee..4ae8373 100644 --- a/qpulse.h +++ b/qpulse.h @@ -18,8 +18,8 @@ public: signals: void ConnectionStateChanged(); - void GotServerInfo(const pa_server_info *i); - void GotCardInfoList(const pa_card_info *i, int eol); + void GotServerInfo(const pa_server_info& i); + void GotCardInfoList(const pa_card_info& i, int eol); public slots: diff --git a/trayicon.cpp b/trayicon.cpp index 9f40d9a..5d9eec0 100644 --- a/trayicon.cpp +++ b/trayicon.cpp @@ -69,7 +69,7 @@ void TrayIcon::onRefreshAction_triggered() refreshData(); } -void TrayIcon::onGotPulseCardInfo(const pa_card_info *cardInfo, int eol) +void TrayIcon::onGotPulseCardInfo(const pa_card_info& cardInfo, int eol) { if (eol) { // OK - rebuild the menu @@ -84,25 +84,19 @@ void TrayIcon::onGotPulseCardInfo(const pa_card_info *cardInfo, int eol) return; } - /* - QString name; // = pa_proplist_to_string(cardInfo->proplist);; // copy to QString from internally-managed buffers - if (true) { // 0 != pa_proplist_isempty(cardInfo->proplist) && 1 == pa_proplist_contains(cardInfo->proplist, PA_PROP_DEVICE_DESCRIPTION)) { - name = pa_proplist_gets(cardInfo->proplist, PA_PROP_DEVICE_DESCRIPTION);; - } else { - name = cardInfo->name; - } - */ - /* - QString name(cardInfo->name); + QString name = pa_proplist_gets(cardInfo.proplist, PA_PROP_DEVICE_DESCRIPTION); + + if (name.length() == 0) { + name = cardInfo.name; + } if (name.length() == 0) { name = tr("Default card"); } - */ QMenu* cardMenu = new QMenu(name); - for (size_t i = 0; i < cardInfo->n_profiles; ++i) { - auto profileAction = new QAction(cardInfo->profiles[i].description, cardMenu); + for (size_t i = 0; i < cardInfo.n_profiles; ++i) { + auto profileAction = new QAction(cardInfo.profiles[i].description, cardMenu); cardMenu->addAction(profileAction); } diff --git a/trayicon.h b/trayicon.h index b083fc3..faf14b7 100644 --- a/trayicon.h +++ b/trayicon.h @@ -19,7 +19,7 @@ public: public slots: void on_quitAction_triggered(); void onRefreshAction_triggered(); - void onGotPulseCardInfo(const pa_card_info *i, int eol); + void onGotPulseCardInfo(const pa_card_info& i, int eol); protected: QPulse pulse;