From 4db5624bebc4d199f328d61d703ed82e3bba2b8a Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 11 Jun 2021 09:04:09 +0300 Subject: [PATCH] Completely removed Global namespace. --- Telegram/SourceFiles/core/application.cpp | 5 +- Telegram/SourceFiles/core/shortcuts.cpp | 3 - Telegram/SourceFiles/facades.cpp | 56 ------------------- Telegram/SourceFiles/facades.h | 21 ------- .../platform/win/windows_event_filter.cpp | 5 +- 5 files changed, 2 insertions(+), 88 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 62eaa2ac8d..6f6ccc349d 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -75,7 +75,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/confirm_phone_box.h" #include "boxes/confirm_box.h" #include "boxes/share_box.h" -#include "facades.h" #include "app.h" #include @@ -177,7 +176,6 @@ Application::~Application() { Media::Player::finish(_audio.get()); style::stopManager(); - Global::finish(); ThirdParty::finish(); Instance = nullptr; @@ -187,8 +185,7 @@ void Application::run() { style::internal::StartFonts(); ThirdParty::start(); - Global::start(); - refreshGlobalProxy(); // Depends on Global::start(). + refreshGlobalProxy(); // Depends on Core::IsAppLaunched(). // Depends on OpenSSL on macOS, so on ThirdParty::start(). // Depends on notifications settings. diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index f2ba8b879a..6548900718 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -15,7 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/base_platform_info.h" #include "platform/platform_specific.h" #include "base/parse_helper.h" -#include "facades.h" #include #include @@ -553,8 +552,6 @@ rpl::producer> Requests() { } void Start() { - Assert(Global::started()); - Data.fill(); } diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 058eb27b5b..9344d3486d 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -318,59 +318,3 @@ bool switchInlineBotButtonReceived( } } // namespace Notify - -#define DefineReadOnlyVar(Namespace, Type, Name) const Type &Name() { \ - AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::" #Name); \ - return Namespace##Data->Name; \ -} -#define DefineRefVar(Namespace, Type, Name) DefineReadOnlyVar(Namespace, Type, Name) \ -Type &Ref##Name() { \ - AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::Ref" #Name); \ - return Namespace##Data->Name; \ -} -#define DefineVar(Namespace, Type, Name) DefineRefVar(Namespace, Type, Name) \ -void Set##Name(const Type &Name) { \ - AssertCustom(Namespace##Data != nullptr, #Namespace "Data != nullptr in " #Namespace "::Set" #Name); \ - Namespace##Data->Name = Name; \ -} - -namespace Global { -namespace internal { - -struct Data { - bool TryIPv6 = !Platform::IsWindows(); - std::vector ProxiesList; - MTP::ProxyData SelectedProxy; - MTP::ProxyData::Settings ProxySettings = MTP::ProxyData::Settings::System; - bool UseProxyForCalls = false; - base::Observable ConnectionTypeChanged; -}; - -} // namespace internal -} // namespace Global - -Global::internal::Data *GlobalData = nullptr; - -namespace Global { - -bool started() { - return GlobalData != nullptr; -} - -void start() { - GlobalData = new internal::Data(); -} - -void finish() { - delete GlobalData; - GlobalData = nullptr; -} - -DefineVar(Global, bool, TryIPv6); -DefineVar(Global, std::vector, ProxiesList); -DefineVar(Global, MTP::ProxyData, SelectedProxy); -DefineVar(Global, MTP::ProxyData::Settings, ProxySettings); -DefineVar(Global, bool, UseProxyForCalls); -DefineRefVar(Global, base::Observable, ConnectionTypeChanged); - -} // namespace Global diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 0179974bed..e100343e42 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -82,24 +82,3 @@ bool switchInlineBotButtonReceived( MsgId samePeerReplyTo = 0); } // namespace Notify - -#define DeclareReadOnlyVar(Type, Name) const Type &Name(); -#define DeclareRefVar(Type, Name) DeclareReadOnlyVar(Type, Name) \ - Type &Ref##Name(); -#define DeclareVar(Type, Name) DeclareRefVar(Type, Name) \ - void Set##Name(const Type &Name); - -namespace Global { - -bool started(); -void start(); -void finish(); - -DeclareVar(bool, TryIPv6); -DeclareVar(std::vector, ProxiesList); -DeclareVar(MTP::ProxyData, SelectedProxy); -DeclareVar(MTP::ProxyData::Settings, ProxySettings); -DeclareVar(bool, UseProxyForCalls); -DeclareRefVar(base::Observable, ConnectionTypeChanged); - -} // namespace Global diff --git a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp index 60d17ff591..eab91c48d5 100644 --- a/Telegram/SourceFiles/platform/win/windows_event_filter.cpp +++ b/Telegram/SourceFiles/platform/win/windows_event_filter.cpp @@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "ui/inactive_press.h" #include "mainwindow.h" -#include "facades.h" #include "app.h" #include @@ -255,9 +254,7 @@ bool EventFilter::mainWindowEvent( } else { _window->shadowsDeactivate(); } - if (Global::started()) { - _window->update(); - } + _window->update(); } return false; case WM_WINDOWPOSCHANGING: