Avoid UTF8->UTF16->UTF8 roundtrip when logging on mobile

Make writeToAppLogFile() take an std::string parameter to avoid
an unnecessary UTF8->UTF16->UTF8 (std::string->QString->char *)
roundtrip.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-11-30 16:28:49 +01:00 committed by bstoeger
parent 7d1e0ef0d1
commit 4d4c250589
3 changed files with 8 additions and 8 deletions

View file

@ -1849,20 +1849,20 @@ void QMLManager::setBtEnabled(bool value)
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
void writeToAppLogFile(QString logText)
void writeToAppLogFile(const std::string &logText)
{
// write to storage and flush so that the data doesn't get lost
logText.append("\n");
QMLManager *self = QMLManager::instance();
if (self) {
self->writeToAppLogFile(logText);
}
}
void QMLManager::writeToAppLogFile(QString logText)
void QMLManager::writeToAppLogFile(const std::string &logText)
{
if (appLogFileOpen) {
appLogFile.write(qPrintable(logText));
std::string line = logText + "\n";
appLogFile.write(line.c_str());
appLogFile.flush();
}
}