goldendict-ng/gddebug.hh
Igor Kushnir be22bb9ffd Prevent using temporary codec-for-locale UTF8 replacement
Utf8CodecForLocaleReplacer's temporary codec-for-locale replacements
cause race conditions in unrelated code that calls
QTextCodec::codecForLocale(). Implement and use a wrapper function that
calls QTextCodec::codecForLocale() while holding
Utf8CodecForLocaleReplacer's mutex lock to fix it.

f0b66f7507 and this commit fix #1587.

Combine several chained QString::arg() calls into one in
EpwingBook::setErrorString(). A single call is more efficient and
prevents unintended replacement inside previous argument substitutions.
2022-11-25 22:48:38 +03:00

37 lines
792 B
C++

#ifndef __GDDEBUG_HH_INCLUDED__
#define __GDDEBUG_HH_INCLUDED__
#include <QFile>
class QTextCodec;
#ifdef NO_CONSOLE
#define GD_DPRINTF(...) do {} while( 0 )
#define GD_FDPRINTF(...) do {} while( 0 )
#else
#ifdef NO_GD_DPRINTF
#define GD_DPRINTF(...) do {} while( 0 )
#else
#define GD_DPRINTF(...) printf(__VA_ARGS__)
#endif
#define GD_FDPRINTF(...) fprintf(__VA_ARGS__)
#endif
void gdWarning(const char *, ...) /* print warning message */
#if defined(Q_CC_GNU) && !defined(__INSURE__)
__attribute__ ((format (printf, 1, 2)))
#endif
;
void gdDebug(const char *, ...)
#if defined(Q_CC_GNU) && !defined(__INSURE__)
__attribute__ ((format (printf, 1, 2)))
#endif
;
QTextCodec * gdCodecForLocale();
extern QFile * logFilePtr;
#endif // __GDDEBUG_HH_INCLUDED__