From afe48da4b182e71b204d33c5f9a8f8d43cffc074 Mon Sep 17 00:00:00 2001 From: Weslly Date: Mon, 20 Nov 2017 17:25:27 -0200 Subject: [PATCH] Change MacPasteboard init object to QScopedPointer --- src/gui/Clipboard.cpp | 16 +++------------- src/gui/Clipboard.h | 3 +-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/gui/Clipboard.cpp b/src/gui/Clipboard.cpp index a35f59b19..78bad2731 100644 --- a/src/gui/Clipboard.cpp +++ b/src/gui/Clipboard.cpp @@ -28,25 +28,15 @@ Clipboard* Clipboard::m_instance(nullptr); Clipboard::Clipboard(QObject* parent) : QObject(parent) , m_timer(new QTimer(this)) +#ifdef Q_OS_MAC + , m_pasteboard(new MacPasteboard) +#endif { m_timer->setSingleShot(true); -#ifdef Q_OS_MAC - m_pasteboard = new MacPasteboard; -#endif - connect(m_timer, SIGNAL(timeout()), SLOT(clearClipboard())); connect(qApp, SIGNAL(aboutToQuit()), SLOT(clearCopiedText())); } -Clipboard::~Clipboard() -{ -#ifdef Q_OS_MAC - if (m_pasteboard) { - delete m_pasteboard; - } -#endif -} - void Clipboard::setText(const QString& text) { QClipboard* clipboard = QApplication::clipboard(); diff --git a/src/gui/Clipboard.h b/src/gui/Clipboard.h index 68f4e0485..6f8ff9ace 100644 --- a/src/gui/Clipboard.h +++ b/src/gui/Clipboard.h @@ -31,7 +31,6 @@ class Clipboard : public QObject public: void setText(const QString& text); - ~Clipboard(); static Clipboard* instance(); @@ -48,7 +47,7 @@ private: QTimer* m_timer; #ifdef Q_OS_MAC - MacPasteboard* m_pasteboard; + QScopedPointer m_pasteboard; #endif QString m_lastCopied; };