summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2014-02-20 23:26:59 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-06 06:09:57 +0100
commit736d7a26cd511ccff010c3ec1b582cd8a027d616 (patch)
tree081c5baaca4c6cc984976692118bf9602625686d
parentc5b2425e8ea1aa25d7ce4253f0205c989bf7a345 (diff)
Avoid creating a new QMimeData each time the Android clipboard is used
This patch aims to fix a memory leak that occurs when the platform clipboard is used on Android. The QMimeData from the clipboard is recreated each time mimeData is called [ChangeLog][QtCore][QPA/Android] Fixed a memory leak in the clipboard Task-number: QTBUG-36025 Change-Id: I241f586589ff256885caee5e5f737313d24d942d Reviewed-by: BogDan Vatra <bogdan@kde.org>
-rw-r--r--src/plugins/platforms/android/qandroidplatformclipboard.cpp6
-rw-r--r--src/plugins/platforms/android/qandroidplatformclipboard.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.cpp b/src/plugins/platforms/android/qandroidplatformclipboard.cpp
index bc48b4935b..0b5e96fa36 100644
--- a/src/plugins/platforms/android/qandroidplatformclipboard.cpp
+++ b/src/plugins/platforms/android/qandroidplatformclipboard.cpp
@@ -42,7 +42,6 @@
#include "qandroidplatformclipboard.h"
#include "androidjniclipboard.h"
#ifndef QT_NO_CLIPBOARD
-#include <QMimeData>
QT_BEGIN_NAMESPACE
@@ -56,9 +55,8 @@ QMimeData *QAndroidPlatformClipboard::mimeData(QClipboard::Mode mode)
if (QClipboard::Clipboard != mode || !QtAndroidClipboard::hasClipboardText())
return 0;
- QMimeData *mimeData = new QMimeData();
- mimeData->setText(QtAndroidClipboard::clipboardText());
- return mimeData;
+ m_mimeData.setText(QtAndroidClipboard::clipboardText());
+ return &m_mimeData;
}
void QAndroidPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
diff --git a/src/plugins/platforms/android/qandroidplatformclipboard.h b/src/plugins/platforms/android/qandroidplatformclipboard.h
index 644f326934..f67355c358 100644
--- a/src/plugins/platforms/android/qandroidplatformclipboard.h
+++ b/src/plugins/platforms/android/qandroidplatformclipboard.h
@@ -43,6 +43,7 @@
#define QANDROIDPLATFORMCLIPBOARD_H
#include <qpa/qplatformclipboard.h>
+#include <QMimeData>
#ifndef QT_NO_CLIPBOARD
QT_BEGIN_NAMESPACE
@@ -55,6 +56,9 @@ public:
virtual QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
virtual bool supportsMode(QClipboard::Mode mode) const;
+
+private:
+ QMimeData m_mimeData;
};
QT_END_NAMESPACE