diff options
author | Robert Adam <dev@robert-adam.de> | 2021-03-04 12:39:42 +0300 |
---|---|---|
committer | Robert Adam <dev@robert-adam.de> | 2021-03-06 20:57:22 +0300 |
commit | d6f9e97ad64828066d5134c9d87e2673847eed79 (patch) | |
tree | 331c84ef78f47046f0eb46ffdf57ef40f12153d1 /src/mumble/TextToSpeech_unix.cpp | |
parent | d72cd32dae61dd2ec008698fc41dfc60f53df558 (diff) |
REFAC(client): Remove global "g" macro
Defining a macro (global namespace) named "g" as a shortcut for
accessing the Global struct never was a good idea. In order to avoid the
problems this created (you must never name a variable "g" or include
Global.h before a header that may have such a variable), the macro was
removed and was instead replaced with a static function Global::get()
that returns a reference to the Global struct.
Just as with the old g macro, the existence of the respective pointer is
not explicitly checked before dereferencing. It is assumed that
everywhere where it is used, the Global struct has already been created.
Diffstat (limited to 'src/mumble/TextToSpeech_unix.cpp')
-rw-r--r-- | src/mumble/TextToSpeech_unix.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/mumble/TextToSpeech_unix.cpp b/src/mumble/TextToSpeech_unix.cpp index 30d8db377..8c4b5fe7c 100644 --- a/src/mumble/TextToSpeech_unix.cpp +++ b/src/mumble/TextToSpeech_unix.cpp @@ -4,6 +4,7 @@ // Mumble source tree or at <https://www.mumble.info/LICENSE>. #include "TextToSpeech.h" +#include "Global.h" #ifdef USE_SPEECHD # ifdef USE_SPEECHD_PKGCONFIG @@ -15,10 +16,6 @@ #include <QtCore/QLocale> -// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name -// (like protobuf 3.7 does). As such, for now, we have to make this our last include. -#include "Global.h" - class TextToSpeechPrivate { #ifdef USE_SPEECHD protected: @@ -60,10 +57,10 @@ void TextToSpeechPrivate::ensureInitialized() { qWarning("TextToSpeech: Failed to contact speech dispatcher."); } else { QString lang; - if (!g.s.qsTTSLanguage.isEmpty()) { - lang = g.s.qsTTSLanguage; - } else if (!g.s.qsLanguage.isEmpty()) { - QLocale locale(g.s.qsLanguage); + if (!Global::get().s.qsTTSLanguage.isEmpty()) { + lang = Global::get().s.qsTTSLanguage; + } else if (!Global::get().s.qsLanguage.isEmpty()) { + QLocale locale(Global::get().s.qsLanguage); lang = locale.bcp47Name(); } else { QLocale systemLocale; |