mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 19:13:24 +00:00
Android: limit the amount of data copied to clipboard
The clipboard fails if we attempt to copy more than 1MB of data. But the data buffer used is shared between all transactions 'in flight' and we cannot tell what else is currently using that buffer. Limiting ourselves to 500k of text for the logfiles seems reasonable and hopefully makes it more likely that the transaction will succeed (sadly, Qt doesn't tell us if it failed). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bcde65b152
commit
e79d177c71
1 changed files with 14 additions and 0 deletions
|
@ -347,8 +347,22 @@ void QMLManager::copyAppLogToClipboard()
|
|||
copyString += in.readAll();
|
||||
}
|
||||
LOG_STP_CLIPBOARD(©String);
|
||||
|
||||
copyString += "---------- finish ----------\n";
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
// on Android, the clipboard is effectively limited in size, but there is no
|
||||
// predefined hard limit. All remote procedure calls use a shared Binder
|
||||
// transaction buffer that is limited to 1MB. To work around this let's truncate
|
||||
// the log once it is more than half a million characters. Qt doesn't tell us if
|
||||
// the clipboard transaction fails, hopefully this will typically leave enough
|
||||
// margin of error.
|
||||
if (copyString.size() > 500000) {
|
||||
copyString.truncate(500000);
|
||||
copyString += "\n\n---------- truncated ----------\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
// and copy to clipboard
|
||||
QApplication::clipboard()->setText(copyString, QClipboard::Clipboard);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue