Navigation Menu

Skip to content

Commit

Permalink
Make sure to properly clear the system clipboard when copying data
Browse files Browse the repository at this point in the history
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 316860a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ExtendedTableWidget.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 316860a

Please sign in to comment.