diff --git a/klipper/klipper.h b/klipper/klipper.h --- a/klipper/klipper.h +++ b/klipper/klipper.h @@ -159,7 +159,7 @@ QClipboard* m_clip; - QSharedPointer m_last; + QWeakPointer m_last; QTime m_showTimer; diff --git a/klipper/klipper.cpp b/klipper/klipper.cpp --- a/klipper/klipper.cpp +++ b/klipper/klipper.cpp @@ -606,17 +606,17 @@ Ignore lock( m_locklevel ); HistoryItemPtr item = HistoryItem::create( clipData ); - bool saveHistory = true; + bool saveInHistory = true; if (clipData->data(QStringLiteral("x-kde-passwordManagerHint")) == QByteArrayLiteral("secret")) { - saveHistory = false; + saveInHistory = false; } if (clipData->hasImage() && m_bIgnoreImages) { - saveHistory = false; + saveInHistory = false; } - m_last = item; + m_last = item.toWeakRef(); - if (saveHistory) { + if (saveInHistory) { history()->insert( item ); } return item; @@ -697,7 +697,7 @@ // This won't quite work, but it's close enough for now. // The trouble is that the top selection =! top clipboard // but we don't track that yet. We will.... - auto top = m_last; + auto top = m_last.toStrongRef(); if ( top ) { setClipboard( *top, selectionMode ? Selection : Clipboard); } @@ -721,7 +721,7 @@ } if ( changed && clipEmpty && m_bNoNullClipboard ) { - auto top = m_last; + auto top = m_last.toStrongRef(); if ( top ) { // keep old clipboard after someone set it to null qCDebug(KLIPPER_LOG) << "Resetting clipboard (Prevent empty clipboard)";