summaryrefslogtreecommitdiffstats
path: root/common/resourceaccess.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-11-16 11:28:18 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-11-16 11:28:18 +0100
commit74f6131c0a67e0b1d0a656ba80f5fd542d12e743 (patch)
treefba2fb135a5da5690cae11c72b6325ea75fce4b1 /common/resourceaccess.h
parent45c2e6a6be0668aa93b38f528042dc42b780d783 (diff)
downloadsink-74f6131c0a67e0b1d0a656ba80f5fd542d12e743.tar.gz
sink-74f6131c0a67e0b1d0a656ba80f5fd542d12e743.zip
Removed ResourceAccess::Private leak and resolved resulting memory
corruption. It looks like the memory corruption (malloc started to crash) was coming QLocalSocket related signals. According to the docs it's not safe (whatever that means), to delete a QObject with pending signals, so we use deleteLater to schedule it's deletion. This resolved the crashes.
Diffstat (limited to 'common/resourceaccess.h')
-rw-r--r--common/resourceaccess.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/common/resourceaccess.h b/common/resourceaccess.h
index 7df6a1b..9387e99 100644
--- a/common/resourceaccess.h
+++ b/common/resourceaccess.h
@@ -44,6 +44,7 @@ public:
44 typedef QSharedPointer<ResourceAccessInterface> Ptr; 44 typedef QSharedPointer<ResourceAccessInterface> Ptr;
45 45
46 ResourceAccessInterface() 46 ResourceAccessInterface()
47 : QObject()
47 { 48 {
48 } 49 }
49 virtual ~ResourceAccessInterface() 50 virtual ~ResourceAccessInterface()
@@ -110,7 +111,7 @@ public:
110 typedef QSharedPointer<ResourceAccess> Ptr; 111 typedef QSharedPointer<ResourceAccess> Ptr;
111 112
112 ResourceAccess(const QByteArray &resourceInstanceIdentifier, const QByteArray &resourceType); 113 ResourceAccess(const QByteArray &resourceInstanceIdentifier, const QByteArray &resourceType);
113 ~ResourceAccess(); 114 virtual ~ResourceAccess();
114 115
115 QByteArray resourceName() const; 116 QByteArray resourceName() const;
116 bool isReady() const; 117 bool isReady() const;
@@ -167,6 +168,9 @@ public:
167 static ResourceAccessFactory &instance(); 168 static ResourceAccessFactory &instance();
168 Sink::ResourceAccess::Ptr getAccess(const QByteArray &instanceIdentifier, const QByteArray resourceType); 169 Sink::ResourceAccess::Ptr getAccess(const QByteArray &instanceIdentifier, const QByteArray resourceType);
169 170
171private:
172 ResourceAccessFactory();
173
170 QHash<QByteArray, QWeakPointer<Sink::ResourceAccess>> mWeakCache; 174 QHash<QByteArray, QWeakPointer<Sink::ResourceAccess>> mWeakCache;
171 QHash<QByteArray, Sink::ResourceAccess::Ptr> mCache; 175 QHash<QByteArray, Sink::ResourceAccess::Ptr> mCache;
172 QHash<QByteArray, QSharedPointer<QTimer>> mTimer; 176 QHash<QByteArray, QSharedPointer<QTimer>> mTimer;