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/ChannelListener.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/ChannelListener.cpp')
-rw-r--r-- | src/ChannelListener.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/ChannelListener.cpp b/src/ChannelListener.cpp index 382637aee..1f0656d19 100644 --- a/src/ChannelListener.cpp +++ b/src/ChannelListener.cpp @@ -10,18 +10,12 @@ #ifdef MUMBLE # include "ServerHandler.h" # include "Database.h" +# include "Global.h" #endif #include <QtCore/QReadLocker> #include <QtCore/QWriteLocker> - -#ifdef MUMBLE -// 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" -#endif - // init static instance ChannelListener ChannelListener::s_instance; @@ -255,7 +249,7 @@ void ChannelListener::setInitialServerSyncDone(bool done) { } void ChannelListener::saveToDB() { - if (!g.sh || g.sh->qbaDigest.isEmpty() || g.uiSession == 0) { + if (!Global::get().sh || Global::get().sh->qbaDigest.isEmpty() || Global::get().uiSession == 0) { // Can't save as we don't have enough context return; } @@ -268,9 +262,9 @@ void ChannelListener::saveToDB() { } // Save the currently listened channels - g.db->setChannelListeners(g.sh->qbaDigest, ChannelListener::getListenedChannelsForUser(g.uiSession)); + Global::get().db->setChannelListeners(Global::get().sh->qbaDigest, ChannelListener::getListenedChannelsForUser(Global::get().uiSession)); // And also the currently set volume adjustments (if they're not set to 1.0) - g.db->setChannelListenerLocalVolumeAdjustments(g.sh->qbaDigest, + Global::get().db->setChannelListenerLocalVolumeAdjustments(Global::get().sh->qbaDigest, ChannelListener::getAllListenerLocalVolumeAdjustments(true)); } #endif |