From 0e1bb27c446f5c5f6bbb3c06fd0d188d10de1d7c Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@digia.com>
Date: Fri, 5 Apr 2013 18:07:23 +0200
Subject: [PATCH] Fix exit crash in xmlpatternsvalidator.

Clean up QNetworkAccessManager using qAddPostRoutine().

Change-Id: I6ee8b0bcccf09abf4e4b35e063f48f6d7a631bfe
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
---
 tests/auto/xmlpatternssdk/TestSuiteHandler.cpp  | 17 ++++++++++++++++-
 .../xmlpatternssdk/XSLTTestSuiteHandler.cpp     | 17 ++++++++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp
index e7423d1b..3a44b8b3 100644
--- a/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp
+++ b/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp
@@ -52,7 +52,22 @@
 
 using namespace QPatternistSDK;
 
-Q_GLOBAL_STATIC(QNetworkAccessManager, networkAccessManager)
+static QNetworkAccessManager *s_networkAccessManager = 0;
+
+static void cleanupNetworkAccessManager()
+{
+    delete s_networkAccessManager;
+    s_networkAccessManager = 0;
+
+}
+static QNetworkAccessManager *networkAccessManager()
+{
+    if (!s_networkAccessManager) {
+        s_networkAccessManager = new QNetworkAccessManager;
+        qAddPostRoutine(cleanupNetworkAccessManager);
+    }
+    return s_networkAccessManager;
+}
 
 TestSuiteHandler::TestSuiteHandler(const QUrl &catalogFile,
                                    const bool useEList) : m_ts(0)
diff --git a/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp
index 080ffac1..c0d5a140 100644
--- a/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp
+++ b/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp
@@ -52,7 +52,22 @@
 
 using namespace QPatternistSDK;
 
-Q_GLOBAL_STATIC(QNetworkAccessManager, networkAccessManager)
+static QNetworkAccessManager *s_networkAccessManager = 0;
+
+static void cleanupNetworkAccessManager()
+{
+    delete s_networkAccessManager;
+    s_networkAccessManager = 0;
+
+}
+static QNetworkAccessManager *networkAccessManager()
+{
+    if (!s_networkAccessManager) {
+        s_networkAccessManager = new QNetworkAccessManager;
+        qAddPostRoutine(cleanupNetworkAccessManager);
+    }
+    return s_networkAccessManager;
+}
 
 XSLTTestSuiteHandler::XSLTTestSuiteHandler(const QUrl &catalogFile) : m_ts(0)
                                                                     , m_tc(0)
-- 
GitLab