desktop/clementine/75f9439843a0e9cdc26cd739d5e1dbd93bd974bc.patch
2018-06-24 21:49:33 +02:00

169 lines
5.8 KiB
Diff

From 948140fab56f593e60b3f623bda5ba1c97f2d6ab Mon Sep 17 00:00:00 2001
From: Valeriy <jazzvoid@gmail.com>
Date: Wed, 11 May 2016 17:58:12 +0300
Subject: [PATCH 1/3] disconnect GVolumeMonitor signals from GioLister before
destroying it fixes #5369
---
src/core/signalchecker.cpp | 9 ++++-----
src/core/signalchecker.h | 6 +++---
src/devices/giolister.cpp | 18 +++++++++++++-----
src/devices/giolister.h | 2 ++
4 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/core/signalchecker.cpp b/src/core/signalchecker.cpp
index 20767f284..2b0505638 100644
--- a/src/core/signalchecker.cpp
+++ b/src/core/signalchecker.cpp
@@ -21,7 +21,7 @@
#include "core/logging.h"
-bool CheckedGConnect(gpointer source, const char* signal, GCallback callback,
+gulong CheckedGConnect(gpointer source, const char* signal, GCallback callback,
gpointer data, const int callback_param_count) {
guint signal_id = 0;
GQuark detail = 0;
@@ -29,7 +29,7 @@ bool CheckedGConnect(gpointer source, const char* signal, GCallback callback,
if (!g_signal_parse_name(signal, G_OBJECT_TYPE(source), &signal_id, &detail,
false)) {
qFatal("Connecting to invalid signal: %s", signal);
- return false;
+ return 0;
}
GSignalQuery query;
@@ -39,9 +39,8 @@ bool CheckedGConnect(gpointer source, const char* signal, GCallback callback,
int signal_params = query.n_params + 2;
if (signal_params != callback_param_count) {
qFatal("Connecting callback to signal with different parameters counts");
- return false;
+ return 0;
}
- g_signal_connect(source, signal, G_CALLBACK(callback), data);
- return true;
+ return g_signal_connect(source, signal, G_CALLBACK(callback), data);
}
diff --git a/src/core/signalchecker.h b/src/core/signalchecker.h
index 75977e6f5..79b6b5364 100644
--- a/src/core/signalchecker.h
+++ b/src/core/signalchecker.h
@@ -25,14 +25,14 @@
#include <boost/typeof/typeof.hpp>
// Do not call this directly, use CHECKED_GCONNECT instead.
-bool CheckedGConnect(gpointer source, const char* signal, GCallback callback,
- gpointer data, const int callback_param_count);
+gulong CheckedGConnect(gpointer source, const char* signal, GCallback callback,
+ gpointer data, const int callback_param_count);
#define FUNCTION_ARITY(callback) \
boost::function_types::function_arity<BOOST_TYPEOF(callback)>::value
#define CHECKED_GCONNECT(source, signal, callback, data) \
CheckedGConnect(source, signal, G_CALLBACK(callback), data, \
- FUNCTION_ARITY(callback));
+ FUNCTION_ARITY(callback))
#endif // CORE_SIGNALCHECKER_H_
diff --git a/src/devices/giolister.cpp b/src/devices/giolister.cpp
index 1979f189c..d48cc4806 100644
--- a/src/devices/giolister.cpp
+++ b/src/devices/giolister.cpp
@@ -94,11 +94,19 @@ void GioLister::Init() {
g_list_free(mounts);
// Connect signals from the monitor
- CHECKED_GCONNECT(monitor_, "volume-added", &VolumeAddedCallback, this);
- CHECKED_GCONNECT(monitor_, "volume-removed", &VolumeRemovedCallback, this);
- CHECKED_GCONNECT(monitor_, "mount-added", &MountAddedCallback, this);
- CHECKED_GCONNECT(monitor_, "mount-changed", &MountChangedCallback, this);
- CHECKED_GCONNECT(monitor_, "mount-removed", &MountRemovedCallback, this);
+ signals_.append(CHECKED_GCONNECT(monitor_, "volume-added", &VolumeAddedCallback, this));
+ signals_.append(CHECKED_GCONNECT(monitor_, "volume-removed", &VolumeRemovedCallback, this));
+ signals_.append(CHECKED_GCONNECT(monitor_, "mount-added", &MountAddedCallback, this));
+ signals_.append(CHECKED_GCONNECT(monitor_, "mount-changed", &MountChangedCallback, this));
+ signals_.append(CHECKED_GCONNECT(monitor_, "mount-removed", &MountRemovedCallback, this));
+}
+
+GioLister::~GioLister()
+{
+ foreach(gulong signal, signals_)
+ {
+ g_signal_handler_disconnect(monitor_, signal);
+ }
}
QStringList GioLister::DeviceUniqueIDs() {
diff --git a/src/devices/giolister.h b/src/devices/giolister.h
index eafa69dc6..c01680bb2 100644
--- a/src/devices/giolister.h
+++ b/src/devices/giolister.h
@@ -36,6 +36,7 @@ class GioLister : public DeviceLister {
public:
GioLister() {}
+ ~GioLister();
int priority() const { return 50; }
@@ -137,6 +138,7 @@ class GioLister : public DeviceLister {
private:
ScopedGObject<GVolumeMonitor> monitor_;
+ QList<gulong> signals_;
QMutex mutex_;
QMap<QString, DeviceInfo> devices_;
From 806e689d1d4a10ca4012ccfcc770dd7fe98b0107 Mon Sep 17 00:00:00 2001
From: Valeriy <jazzvoid@gmail.com>
Date: Wed, 11 May 2016 19:00:30 +0300
Subject: [PATCH 2/3] replace foreach with range-based for
---
src/devices/giolister.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/devices/giolister.cpp b/src/devices/giolister.cpp
index d48cc4806..f1a776bc0 100644
--- a/src/devices/giolister.cpp
+++ b/src/devices/giolister.cpp
@@ -103,7 +103,7 @@ void GioLister::Init() {
GioLister::~GioLister()
{
- foreach(gulong signal, signals_)
+ for (gulong signal : signals_)
{
g_signal_handler_disconnect(monitor_, signal);
}
From cbc7092ed90a5bbf681afd7391cb06d4f2c4ae1e Mon Sep 17 00:00:00 2001
From: Valeriy <jazzvoid@gmail.com>
Date: Tue, 17 May 2016 14:47:02 +0300
Subject: [PATCH 3/3] fix code style
---
src/devices/giolister.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/devices/giolister.cpp b/src/devices/giolister.cpp
index f1a776bc0..aa3bddb34 100644
--- a/src/devices/giolister.cpp
+++ b/src/devices/giolister.cpp
@@ -101,10 +101,8 @@ void GioLister::Init() {
signals_.append(CHECKED_GCONNECT(monitor_, "mount-removed", &MountRemovedCallback, this));
}
-GioLister::~GioLister()
-{
- for (gulong signal : signals_)
- {
+GioLister::~GioLister() {
+ for (gulong signal : signals_) {
g_signal_handler_disconnect(monitor_, signal);
}
}