mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-26 08:15:32 -04:00
Do not delete MacPasteboard instance on exit, resolves #1543
This commit is contained in:
parent
199f0932bf
commit
ee8499f65c
3 changed files with 14 additions and 5 deletions
|
@ -20,8 +20,9 @@
|
||||||
|
|
||||||
#include <QMacPasteboardMime>
|
#include <QMacPasteboardMime>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
class MacPasteboard : public QMacPasteboardMime
|
class MacPasteboard : public QObject, public QMacPasteboardMime
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MacPasteboard() : QMacPasteboardMime(MIME_ALL) {}
|
explicit MacPasteboard() : QMacPasteboardMime(MIME_ALL) {}
|
||||||
|
|
|
@ -24,14 +24,19 @@
|
||||||
#include "core/Config.h"
|
#include "core/Config.h"
|
||||||
|
|
||||||
Clipboard* Clipboard::m_instance(nullptr);
|
Clipboard* Clipboard::m_instance(nullptr);
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
QPointer<MacPasteboard> Clipboard::m_pasteboard(nullptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
Clipboard::Clipboard(QObject* parent)
|
Clipboard::Clipboard(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_timer(new QTimer(this))
|
, m_timer(new QTimer(this))
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
, m_pasteboard(new MacPasteboard)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
if (!m_pasteboard) {
|
||||||
|
m_pasteboard = new MacPasteboard();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
m_timer->setSingleShot(true);
|
m_timer->setSingleShot(true);
|
||||||
connect(m_timer, SIGNAL(timeout()), SLOT(clearClipboard()));
|
connect(m_timer, SIGNAL(timeout()), SLOT(clearClipboard()));
|
||||||
connect(qApp, SIGNAL(aboutToQuit()), SLOT(clearCopiedText()));
|
connect(qApp, SIGNAL(aboutToQuit()), SLOT(clearCopiedText()));
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include "core/MacPasteboard.h"
|
#include "core/MacPasteboard.h"
|
||||||
|
#include <QPointer>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
@ -47,7 +48,9 @@ private:
|
||||||
|
|
||||||
QTimer* m_timer;
|
QTimer* m_timer;
|
||||||
#ifdef Q_OS_MAC
|
#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
|
#endif
|
||||||
QString m_lastCopied;
|
QString m_lastCopied;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue