diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-06-28 06:42:13 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-06-28 06:52:14 -0700 |
commit | e79d177c7150166851e1e8152ecdd1908e1bcacf (patch) | |
tree | 2ba14bc22324367f891a3ac2e52f9b6e4458505f /mobile-widgets | |
parent | bcde65b152f2fdbf0e068c3a9dfabe138be2efca (diff) | |
download | subsurface-e79d177c7150166851e1e8152ecdd1908e1bcacf.tar.gz |
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>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index a3a4fffad..5269be9fe 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -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); } |