From 73b54f85c543d7e6de4194c1e6c91aa9ce79902d Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 22 Jan 2014 09:17:39 +0100 Subject: [PATCH] Cleanup of the android clipboard handling Currently there's an unguarded class member for the clipboard, allocated but unused and not deleted in the destructor. The getter creates a static clipboard allocated on the heap. This patch aims to add the missing guards as well as use the class member. Task-number: QTBUG-36025 Change-Id: I86969390eebcd67b65707e3ecbd4b3be15c7dadb Reviewed-by: BogDan Vatra --- .../android/src/qandroidplatformintegration.cpp | 14 +++++++++----- .../android/src/qandroidplatformintegration.h | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index e4a2ad582d..9bfb6e9a70 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -118,7 +118,10 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidFDB = new QAndroidPlatformFontDatabase(); m_androidPlatformServices = new QAndroidPlatformServices(); + +#ifndef QT_NO_CLIPBOARD m_androidPlatformClipboard = new QAndroidPlatformClipboard(); +#endif m_androidSystemLocale = new QAndroidSystemLocale; } @@ -217,6 +220,11 @@ QAndroidPlatformIntegration::~QAndroidPlatformIntegration() delete m_androidPlatformNativeInterface; delete m_androidFDB; delete m_androidSystemLocale; + +#ifndef QT_NO_CLIPBOARD + delete m_androidPlatformClipboard; +#endif + QtAndroid::setAndroidPlatformIntegration(NULL); } QPlatformFontDatabase *QAndroidPlatformIntegration::fontDatabase() const @@ -227,11 +235,7 @@ QPlatformFontDatabase *QAndroidPlatformIntegration::fontDatabase() const #ifndef QT_NO_CLIPBOARD QPlatformClipboard *QAndroidPlatformIntegration::clipboard() const { -static QAndroidPlatformClipboard *clipboard = 0; - if (!clipboard) - clipboard = new QAndroidPlatformClipboard; - - return clipboard; + return m_androidPlatformClipboard; } #endif diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h index 474c1e837e..c5476128a5 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h @@ -171,7 +171,11 @@ private: QPainter *m_compositePainter; QAndroidPlatformNativeInterface *m_androidPlatformNativeInterface; QAndroidPlatformServices *m_androidPlatformServices; + +#ifndef QT_NO_CLIPBOARD QPlatformClipboard *m_androidPlatformClipboard; +#endif + QAndroidSystemLocale *m_androidSystemLocale; #ifndef QT_NO_ACCESSIBILITY mutable QPlatformAccessibility *m_accessibility;