Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not delete MacPasteboard instance on exit, resolves #1543 #1607

Merged
merged 1 commit into from
Mar 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/MacPasteboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

#include <QMacPasteboardMime>
#include <QTextCodec>
#include <QObject>

class MacPasteboard : public QMacPasteboardMime
class MacPasteboard : public QObject, public QMacPasteboardMime
{
public:
explicit MacPasteboard() : QMacPasteboardMime(MIME_ALL) {}
Expand Down
9 changes: 7 additions & 2 deletions src/gui/Clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@
#include "core/Config.h"

Clipboard* Clipboard::m_instance(nullptr);
#ifdef Q_OS_MAC
QPointer<MacPasteboard> Clipboard::m_pasteboard(nullptr);
#endif

Clipboard::Clipboard(QObject* parent)
: QObject(parent)
, m_timer(new QTimer(this))
{
#ifdef Q_OS_MAC
, m_pasteboard(new MacPasteboard)
if (!m_pasteboard) {
m_pasteboard = new MacPasteboard();
}
#endif
{
m_timer->setSingleShot(true);
connect(m_timer, SIGNAL(timeout()), SLOT(clearClipboard()));
connect(qApp, SIGNAL(aboutToQuit()), SLOT(clearCopiedText()));
Expand Down
5 changes: 4 additions & 1 deletion src/gui/Clipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QObject>
#ifdef Q_OS_MAC
#include "core/MacPasteboard.h"
#include <QPointer>
#endif

class QTimer;
Expand All @@ -47,7 +48,9 @@ private slots:

QTimer* m_timer;
#ifdef Q_OS_MAC
QScopedPointer<MacPasteboard> m_pasteboard;
// This object lives for the whole program lifetime and we cannot delete it on exit,
// so ignore leak warnings. See https://bugreports.qt.io/browse/QTBUG-54832
static QPointer<MacPasteboard> m_pasteboard;
#endif
QString m_lastCopied;
};
Expand Down