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.
This commit is contained in:
Martin Kleusberg
2017-12-04 12:55:29 +01:00
parent 47b07490de
commit 316860a709
+2
View File
@@ -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