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

refactor(Qt): use 'storeRelaxed()' and 'loadRelaxed()'

This fixes build with Qt 5.14 by replacing the deprecated
QAtomic::load() and store() functions with the new ones.

- https://code.qt.io/cgit/qt/qtbase.git/commit/?h=5.14&id=79bdc7cf
This commit is contained in:
Jimi Huotari 2019-09-25 13:23:37 +03:00 committed by Anthony Bilinski
parent 489d07c0eb
commit c20e1c20e3
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -75,10 +75,18 @@ void cleanup()
qDebug() << "Cleanup success";
#ifdef LOG_TO_FILE
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
FILE* f = logFileFile.loadRelaxed();
#else
FILE* f = logFileFile.load();
#endif
if (f != nullptr) {
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
#endif
}
#endif
}
@ -128,7 +136,11 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QSt
fwrite(LogMsgBytes.constData(), 1, LogMsgBytes.size(), stderr);
#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
#endif
if (!logFilePtr) {
logBufferMutex->lock();
if (logBuffer)
@ -282,7 +294,11 @@ int main(int argc, char* argv[])
if (!mainLogFilePtr)
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
#endif
#endif
// Windows platform plugins DLL hell fix