Permalink
Browse files

Make sure to properly clear the system clipboard when copying data

When copying binary data or similar using the internal copy-paste buffer
we need to clear the system clipboard first in order to avoid confusion
between the two paste sources. Just calling clear() on the clipboard
doesn't seem to work on my system, so this commit manually sets the
clipboard text to a null string.
  • Loading branch information...
MKleusberg committed Dec 4, 2017
1 parent 47b0749 commit 316860a7091bfe0f7de43e78cf6c03b0f9d7387d
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/ExtendedTableWidget.cpp
@@ -208,6 +208,7 @@ void ExtendedTableWidget::copy(const bool withHeaders)
if (text.isEmpty())
{
// The field is either NULL or empty. Those are are handled via the internal copy-paste buffer
qApp->clipboard()->setText(QString()); // Calling clear() alone doesn't seem to work on all systems
qApp->clipboard()->clear();
m_buffer.push_back(QByteArrayList{data.toByteArray()});
return;
@@ -235,6 +236,7 @@ void ExtendedTableWidget::copy(const bool withHeaders)
if (containsBinary)
{
// Make sure to clear the system clipboard, so it's not used when pasting
qApp->clipboard()->setText(QString()); // Calling clear() alone doesn't seem to work on all systems
qApp->clipboard()->clear();

// Copy selected data into internal copy-paste buffer

0 comments on commit 316860a

Please sign in to comment.