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/ManualPlugin.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/ManualPlugin.cpp')
-rw-r--r-- | src/mumble/ManualPlugin.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/mumble/ManualPlugin.cpp b/src/mumble/ManualPlugin.cpp index 4b90d05e1..ef1a4746d 100644 --- a/src/mumble/ManualPlugin.cpp +++ b/src/mumble/ManualPlugin.cpp @@ -16,9 +16,6 @@ #include <float.h> #include "../../plugins/mumble_plugin.h" - -// 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" static QPointer< Manual > mDlg = nullptr; @@ -85,7 +82,7 @@ Manual::Manual(QWidget *p) : QDialog(p) { my.context = defaultContext.toStdString(); my.identity = defaultIdentity.toStdWString(); - qsbSilentUserDisplaytime->setValue(g.s.manualPlugin_silentUserDisplaytime); + qsbSilentUserDisplaytime->setValue(Global::get().s.manualPlugin_silentUserDisplaytime); updateLoopRunning.store(false); } @@ -210,7 +207,7 @@ void Manual::on_buttonBox_clicked(QAbstractButton *button) { } void Manual::on_qsbSilentUserDisplaytime_valueChanged(int value) { - g.s.manualPlugin_silentUserDisplaytime = value; + Global::get().s.manualPlugin_silentUserDisplaytime = value; } void Manual::on_speakerPositionUpdate(QHash< unsigned int, Position2D > positions) { @@ -251,7 +248,7 @@ void Manual::on_speakerPositionUpdate(QHash< unsigned int, Position2D > position } else { // Remove the stale item speakerIt.remove(); - if (g.s.manualPlugin_silentUserDisplaytime == 0) { + if (Global::get().s.manualPlugin_silentUserDisplaytime == 0) { // Delete it immediately delete speakerItem; } else { @@ -296,14 +293,14 @@ void Manual::on_updateStaleSpeakers() { double elapsedTime = static_cast< std::chrono::duration< double > >(std::chrono::steady_clock::now() - entry.staleSince).count(); - if (elapsedTime >= g.s.manualPlugin_silentUserDisplaytime) { + if (elapsedTime >= Global::get().s.manualPlugin_silentUserDisplaytime) { // The item has been around long enough - remove it now staleIt.remove(); delete entry.staleItem; } else { // Let the item fade out - double opacity = (g.s.manualPlugin_silentUserDisplaytime - elapsedTime) - / static_cast< double >(g.s.manualPlugin_silentUserDisplaytime); + double opacity = (Global::get().s.manualPlugin_silentUserDisplaytime - elapsedTime) + / static_cast< double >(Global::get().s.manualPlugin_silentUserDisplaytime); entry.staleItem->setOpacity(opacity); } } |