1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #5850

Jimi Huotari (2):
      refactor(Qt): use 'QLatin1String' instead of 'QLatin1Literal' part 2
      refactor(Qt): use 'storeRelaxed()' and 'loadRelaxed()'
This commit is contained in:
sudden6 2019-09-29 14:00:45 +02:00
commit ffcf501ba4
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 18 additions and 2 deletions

View File

@ -75,10 +75,18 @@ void cleanup()
qDebug() << "Cleanup success"; qDebug() << "Cleanup success";
#ifdef LOG_TO_FILE #ifdef LOG_TO_FILE
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
FILE* f = logFileFile.loadRelaxed();
#else
FILE* f = logFileFile.load(); FILE* f = logFileFile.load();
#endif
if (f != nullptr) { if (f != nullptr) {
fclose(f); fclose(f);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
logFileFile.storeRelaxed(nullptr); // atomically disable logging to file
#else
logFileFile.store(nullptr); // atomically disable logging to file logFileFile.store(nullptr); // atomically disable logging to file
#endif
} }
#endif #endif
} }
@ -128,7 +136,11 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QSt
fwrite(LogMsgBytes.constData(), 1, LogMsgBytes.size(), stderr); fwrite(LogMsgBytes.constData(), 1, LogMsgBytes.size(), stderr);
#ifdef LOG_TO_FILE #ifdef LOG_TO_FILE
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
FILE* logFilePtr = logFileFile.loadRelaxed(); // atomically load the file pointer
#else
FILE* logFilePtr = logFileFile.load(); // atomically load the file pointer FILE* logFilePtr = logFileFile.load(); // atomically load the file pointer
#endif
if (!logFilePtr) { if (!logFilePtr) {
logBufferMutex->lock(); logBufferMutex->lock();
if (logBuffer) if (logBuffer)
@ -282,7 +294,11 @@ int main(int argc, char* argv[])
if (!mainLogFilePtr) if (!mainLogFilePtr)
qCritical() << "Couldn't open logfile" << logfile; qCritical() << "Couldn't open logfile" << logfile;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
logFileFile.storeRelaxed(mainLogFilePtr); // atomically set the logFile
#else
logFileFile.store(mainLogFilePtr); // atomically set the logFile logFileFile.store(mainLogFilePtr); // atomically set the logFile
#endif
#endif #endif
// Windows platform plugins DLL hell fix // Windows platform plugins DLL hell fix

View File

@ -54,8 +54,8 @@ private slots:
void TestMessageProcessor::testSelfMention() void TestMessageProcessor::testSelfMention()
{ {
MessageProcessor::SharedParams sharedParams; MessageProcessor::SharedParams sharedParams;
const QLatin1Literal testUserName{"MyUserName"}; const QLatin1String testUserName{"MyUserName"};
const QLatin1Literal testToxPk{ const QLatin1String testToxPk{
"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"}; "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"};
sharedParams.onUserNameSet(testUserName); sharedParams.onUserNameSet(testUserName);
sharedParams.setPublicKey(testToxPk); sharedParams.setPublicKey(testToxPk);