From 084320d256b3a7c600c3635d1c1f3b7cbcd0710a Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 15 Oct 2014 16:24:36 -0400 Subject: [PATCH] Fixed and documented the use of DownloadTransform::nam --- openbr/plugins/misc.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openbr/plugins/misc.cpp b/openbr/plugins/misc.cpp index 320e179..9d5e929 100644 --- a/openbr/plugins/misc.cpp +++ b/openbr/plugins/misc.cpp @@ -106,7 +106,13 @@ public: private: BR_PROPERTY(Mode, mode, Encoded) - mutable QThreadStorage nam; + // The reasons for this data structure are as follows: + // 1) The QNetworkAccessManager must be used in the thread that _created_ it, + // hence the use of `QThreadStorage`. + // 2) The QThreadStorage must be deleted _after_ the threads that added QNetworkAccessManager + // to it are deleted, hence the `static` ensuring that `nam` is deleted at program termination, + // long after the threads that created QNetworkAccessManager are deleted. + static QThreadStorage nam; void project(const Template &src, Template &dst) const { @@ -165,6 +171,7 @@ private: } } }; +QThreadStorage DownloadTransform::nam; BR_REGISTER(Transform, DownloadTransform) -- libgit2 0.21.4