sigproxy: Don't expose the thread_local '_current' attribute
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 2 Sep 2018 21:23:06 +0000 (23:23 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 18 Nov 2018 10:06:43 +0000 (11:06 +0100)
Windows does not allow exporting thread_local attributes in the
DLL interface. Since it's not good practice anyway to expose such
an implementation detail in the public header, make the accessor
non-inline and move the attribute into a private anonymous namespace,
removing it from the public interface.

src/common/signalproxy.cpp
src/common/signalproxy.h

index 19b9af8..721f32a 100644 (file)
@@ -166,7 +166,9 @@ int SignalProxy::SignalRelay::qt_metacall(QMetaObject::Call _c, int _id, void **
 //  SignalProxy
 // ==================================================
 
-thread_local SignalProxy *SignalProxy::_current{nullptr};
+namespace {
+thread_local SignalProxy *_current{nullptr};
+}
 
 SignalProxy::SignalProxy(QObject *parent)
     : QObject(parent)
@@ -204,6 +206,12 @@ SignalProxy::~SignalProxy()
 }
 
 
+SignalProxy *SignalProxy::current()
+{
+    return _current;
+}
+
+
 void SignalProxy::setProxyMode(ProxyMode mode)
 {
     if (!_peerMap.empty()) {
index f3ea4c5..a3d7703 100644 (file)
@@ -80,9 +80,7 @@ public:
     void dumpProxyStats();
     void dumpSyncMap(SyncableObject *object);
 
-    static SignalProxy *current() {
-        return _current;
-    }
+    static SignalProxy *current();
 
     /**@{*/
     /**
@@ -217,8 +215,6 @@ private:
     Peer *_sourcePeer = nullptr;
     Peer *_targetPeer = nullptr;
 
-    thread_local static SignalProxy *_current;
-
     friend class SignalRelay;
     friend class SyncableObject;
     friend class Peer;