Skip to content

Commit 316860a

Browse files
committed
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.
1 parent 47b0749 commit 316860a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/ExtendedTableWidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ void ExtendedTableWidget::copy(const bool withHeaders)
208208
if (text.isEmpty())
209209
{
210210
// The field is either NULL or empty. Those are are handled via the internal copy-paste buffer
211+
qApp->clipboard()->setText(QString()); // Calling clear() alone doesn't seem to work on all systems
211212
qApp->clipboard()->clear();
212213
m_buffer.push_back(QByteArrayList{data.toByteArray()});
213214
return;
@@ -235,6 +236,7 @@ void ExtendedTableWidget::copy(const bool withHeaders)
235236
if (containsBinary)
236237
{
237238
// Make sure to clear the system clipboard, so it's not used when pasting
239+
qApp->clipboard()->setText(QString()); // Calling clear() alone doesn't seem to work on all systems
238240
qApp->clipboard()->clear();
239241

240242
// Copy selected data into internal copy-paste buffer

0 commit comments

Comments
 (0)