Make loggingMutex nonrecursive

A recursive mutex is less efficient and clearly not needed here.
This commit is contained in:
Igor Kushnir 2022-11-25 00:44:35 +02:00 committed by Abs62
parent d1ff165a65
commit a020ebc4b8

View file

@ -1,14 +1,15 @@
/* This file is (c) 2013 Abs62 /* This file is (c) 2013 Abs62
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#include <QMutex>
#include <QMutexLocker>
#include <QTextCodec> #include <QTextCodec>
#include <QString> #include <QString>
#include "mutex.hh"
#include "gddebug.hh" #include "gddebug.hh"
QFile * logFilePtr; QFile * logFilePtr;
static QTextCodec * utf8Codec; static QTextCodec * utf8Codec;
static Mutex loggingMutex; static QMutex loggingMutex;
void gdWarning(const char *msg, ...) void gdWarning(const char *msg, ...)
{ {
@ -18,7 +19,7 @@ QTextCodec *localeCodec = 0;
if( logFilePtr && logFilePtr->isOpen() ) if( logFilePtr && logFilePtr->isOpen() )
{ {
Mutex::Lock _( loggingMutex ); QMutexLocker _( &loggingMutex );
if( utf8Codec == 0 ) if( utf8Codec == 0 )
utf8Codec = QTextCodec::codecForName( "UTF8" ); utf8Codec = QTextCodec::codecForName( "UTF8" );
@ -44,7 +45,7 @@ QTextCodec *localeCodec = 0;
if( logFilePtr && logFilePtr->isOpen() ) if( logFilePtr && logFilePtr->isOpen() )
{ {
Mutex::Lock _( loggingMutex ); QMutexLocker _( &loggingMutex );
if( utf8Codec == 0 ) if( utf8Codec == 0 )
utf8Codec = QTextCodec::codecForName( "UTF8" ); utf8Codec = QTextCodec::codecForName( "UTF8" );