From 7906be37b62da5eb3b5388401e7a00f0612b944c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 15 Sep 2023 09:51:42 +0400 Subject: [PATCH] Change #if-ery to be more in line with cmake logic (LINUX = NOT WIN32 AND NOT APPLE) --- Telegram/SourceFiles/_other/packer.cpp | 4 +-- Telegram/SourceFiles/core/crash_reports.cpp | 26 +++++++++---------- Telegram/SourceFiles/core/update_checker.cpp | 16 ++++++------ .../data/data_document_resolver.cpp | 18 ++++++------- Telegram/SourceFiles/logs.cpp | 2 +- .../platform/platform_file_utilities.h | 12 ++++----- .../platform/platform_integration.cpp | 12 ++++----- .../SourceFiles/platform/platform_launcher.h | 12 ++++----- .../platform/platform_main_window.h | 12 ++++----- .../platform/platform_notifications_manager.h | 12 ++++----- .../platform/platform_overlay_widget.h | 12 ++++----- .../SourceFiles/platform/platform_specific.h | 12 ++++----- Telegram/SourceFiles/platform/platform_tray.h | 12 ++++----- .../settings/settings_notifications.cpp | 12 ++++----- Telegram/SourceFiles/stdafx.h | 4 +-- Telegram/lib_base | 2 +- Telegram/lib_spellcheck | 2 +- Telegram/lib_storage | 2 +- Telegram/lib_ui | 2 +- 19 files changed, 93 insertions(+), 93 deletions(-) diff --git a/Telegram/SourceFiles/_other/packer.cpp b/Telegram/SourceFiles/_other/packer.cpp index 0ba79c1be..dc36330e5 100644 --- a/Telegram/SourceFiles/_other/packer.cpp +++ b/Telegram/SourceFiles/_other/packer.cpp @@ -267,7 +267,7 @@ int main(int argc, char *argv[]) } QByteArray inner = f.readAll(); stream << name << quint32(inner.size()) << inner; -#ifdef Q_OS_UNIX +#ifndef Q_OS_WIN stream << (QFileInfo(fullName).isExecutable() ? true : false); #endif } @@ -496,7 +496,7 @@ int main(int argc, char *argv[]) QString outName((targetwin64 ? QString("tx64upd%1") : QString("tupdate%1")).arg(AlphaVersion ? AlphaVersion : version)); #elif defined Q_OS_MAC QString outName((targetarmac ? QString("tarmacupd%1") : QString("tmacupd%1")).arg(AlphaVersion ? AlphaVersion : version)); -#elif defined Q_OS_UNIX +#else QString outName(QString("tlinuxupd%1").arg(AlphaVersion ? AlphaVersion : version)); #else #error Unknown platform! diff --git a/Telegram/SourceFiles/core/crash_reports.cpp b/Telegram/SourceFiles/core/crash_reports.cpp index be7e77cdd..efcad014f 100644 --- a/Telegram/SourceFiles/core/crash_reports.cpp +++ b/Telegram/SourceFiles/core/crash_reports.cpp @@ -25,7 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #pragma warning(pop) -#elif defined Q_OS_UNIX // Q_OS_WIN +#else // Q_OS_WIN #include #include @@ -197,13 +197,15 @@ const int HandledSignals[] = { SIGABRT, SIGFPE, SIGILL, -#ifdef Q_OS_UNIX +#ifndef Q_OS_WIN SIGBUS, SIGTRAP, -#endif // Q_OS_UNIX +#endif // !Q_OS_WIN }; -#ifdef Q_OS_UNIX +#ifdef Q_OS_WIN +void SignalHandler(int signum) { +#else // Q_OS_WIN struct sigaction OldSigActions[32]/* = { 0 }*/; void RestoreSignalHandlers() { @@ -229,9 +231,7 @@ void InvokeOldSignalHandler(int signum, siginfo_t *info, void *ucontext) { void SignalHandler(int signum, siginfo_t *info, void *ucontext) { RestoreSignalHandlers(); -#else // Q_OS_UNIX -void SignalHandler(int signum) { -#endif // else for Q_OS_UNIX +#endif // else for Q_OS_WIN const char* name = 0; switch (signum) { @@ -253,9 +253,9 @@ void SignalHandler(int signum) { ReportingThreadId = nullptr; } -#ifdef Q_OS_UNIX +#ifndef Q_OS_WIN InvokeOldSignalHandler(signum, info, ucontext); -#endif // Q_OS_UNIX +#endif // !Q_OS_WIN } bool SetSignalHandlers = true; @@ -267,9 +267,9 @@ google_breakpad::ExceptionHandler* BreakpadExceptionHandler = 0; bool DumpCallback(const wchar_t* _dump_dir, const wchar_t* _minidump_id, void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion, bool success) #elif defined Q_OS_MAC // Q_OS_WIN bool DumpCallback(const char* _dump_dir, const char* _minidump_id, void *context, bool success) -#elif defined Q_OS_UNIX // Q_OS_MAC +#else // Q_OS_MAC bool DumpCallback(const google_breakpad::MinidumpDescriptor &md, void *context, bool success) -#endif // Q_OS_UNIX +#endif // else for Q_OS_WIN || Q_OS_MAC { if (CrashLogged) return success; CrashLogged = true; @@ -370,7 +370,7 @@ void StartCatching() { false)) { // asynchronous_start } #endif // else for MAC_USE_BREAKPAD -#elif defined Q_OS_UNIX +#else BreakpadExceptionHandler = new google_breakpad::ExceptionHandler( google_breakpad::MinidumpDescriptor(QFile::encodeName(dumpspath).toStdString()), /*FilterCallback*/ 0, @@ -379,7 +379,7 @@ void StartCatching() { true, -1 ); -#endif // Q_OS_UNIX +#endif // else for Q_OS_WIN || Q_OS_MAC #endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS } diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index 590354c56..f80fd3eb2 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -49,9 +49,9 @@ extern "C" { #endif // else of Q_OS_WIN && !DESKTOP_APP_USE_PACKAGED #endif // !TDESKTOP_DISABLE_AUTOUPDATE -#ifdef Q_OS_UNIX +#ifndef Q_OS_WIN #include -#endif // Q_OS_UNIX +#endif // !Q_OS_WIN namespace Core { namespace { @@ -448,9 +448,9 @@ bool UnpackUpdate(const QString &filepath) { bool executable = false; stream >> relativeName >> fileSize >> fileInnerData; -#ifdef Q_OS_UNIX +#ifndef Q_OS_WIN stream >> executable; -#endif // Q_OS_UNIX +#endif // !Q_OS_WIN if (stream.status() != QDataStream::Ok) { LOG(("Update Error: cant read file from downloaded stream, status: %1").arg(stream.status())); return false; @@ -1554,10 +1554,10 @@ bool checkReadyUpdate() { #elif defined Q_OS_MAC // Q_OS_WIN QString curUpdater = (cExeDir() + cExeName() + u"/Contents/Frameworks/Updater"_q); QFileInfo updater(cWorkingDir() + u"tupdates/temp/Telegram.app/Contents/Frameworks/Updater"_q); -#elif defined Q_OS_UNIX // Q_OS_MAC +#else // Q_OS_MAC QString curUpdater = (cExeDir() + u"Updater"_q); QFileInfo updater(cWorkingDir() + u"tupdates/temp/Updater"_q); -#endif // Q_OS_UNIX +#endif // else for Q_OS_WIN || Q_OS_MAC if (!updater.exists()) { QFileInfo current(curUpdater); if (!current.exists()) { @@ -1591,7 +1591,7 @@ bool checkReadyUpdate() { ClearAll(); return false; } -#elif defined Q_OS_UNIX // Q_OS_MAC +#else // Q_OS_MAC // if the files in the directory are owned by user, while the directory is not, // update will still fail since it's not possible to remove files if (QFile::exists(curUpdater) @@ -1619,7 +1619,7 @@ bool checkReadyUpdate() { return false; } } -#endif // Q_OS_UNIX +#endif // else for Q_OS_WIN || Q_OS_MAC #ifdef Q_OS_MAC base::Platform::RemoveQuarantine(QFileInfo(curUpdater).absolutePath()); diff --git a/Telegram/SourceFiles/data/data_document_resolver.cpp b/Telegram/SourceFiles/data/data_document_resolver.cpp index 2839eeb76..ead282bcf 100644 --- a/Telegram/SourceFiles/data/data_document_resolver.cpp +++ b/Telegram/SourceFiles/data/data_document_resolver.cpp @@ -159,14 +159,7 @@ wv xm xml ym yuv").split(' '); bool IsExecutableName(const QString &filepath) { static const auto kExtensions = [] { const auto joined = -#ifdef Q_OS_MAC - u"\ -applescript action app bin command csh osx workflow terminal url caction \ -mpkg pkg scpt scptd xhtm webarchive"_q; -#elif defined Q_OS_UNIX // Q_OS_MAC - u"bin csh deb desktop ksh out pet pkg pup rpm run sh shar \ -slp zsh"_q; -#else // Q_OS_MAC || Q_OS_UNIX +#ifdef Q_OS_WIN u"\ ad ade adp app application appref-ms asp asx bas bat bin cab cdxml cer cfg \ chi chm cmd cnt com cpl crt csh der diagcab dll drv eml exe fon fxp gadget \ @@ -179,7 +172,14 @@ psd1 psm1 pssc pst py py3 pyc pyd pyi pyo pyw pywz pyz rb reg rgs scf scr \ sct search-ms settingcontent-ms sh shb shs slk sys t tmp u3p url vb vbe vbp \ vbs vbscript vdx vsmacros vsd vsdm vsdx vss vssm vssx vst vstm vstx vsw vsx \ vtx website ws wsc wsf wsh xbap xll xnk xs"_q; -#endif // !Q_OS_MAC && !Q_OS_UNIX +#elif defined Q_OS_MAC // Q_OS_MAC + u"\ +applescript action app bin command csh osx workflow terminal url caction \ +mpkg pkg scpt scptd xhtm webarchive"_q; +#else // Q_OS_WIN || Q_OS_MAC + u"bin csh deb desktop ksh out pet pkg pup rpm run sh shar \ +slp zsh"_q; +#endif // !Q_OS_WIN && !Q_OS_MAC const auto list = joined.split(' '); return base::flat_set(list.begin(), list.end()); }(); diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp index b8bd88d6c..b61a2d29b 100644 --- a/Telegram/SourceFiles/logs.cpp +++ b/Telegram/SourceFiles/logs.cpp @@ -560,7 +560,7 @@ void writeDebug(const QString &v) { //OutputDebugString(reinterpret_cast(msg.utf16())); #elif defined Q_OS_MAC //objc_outputDebugString(msg); -#elif defined Q_OS_UNIX && defined _DEBUG +#elif defined _DEBUG //std::cout << msg.toUtf8().constData(); #endif } diff --git a/Telegram/SourceFiles/platform/platform_file_utilities.h b/Telegram/SourceFiles/platform/platform_file_utilities.h index 91ef52aae..b28b821bc 100644 --- a/Telegram/SourceFiles/platform/platform_file_utilities.h +++ b/Telegram/SourceFiles/platform/platform_file_utilities.h @@ -43,10 +43,10 @@ bool Get( // Platform dependent implementations. -#ifdef Q_OS_MAC -#include "platform/mac/file_utilities_mac.h" -#elif defined Q_OS_UNIX // Q_OS_MAC -#include "platform/linux/file_utilities_linux.h" -#elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX +#if defined Q_OS_WINRT || defined Q_OS_WIN #include "platform/win/file_utilities_win.h" -#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WINRT || Q_OS_WIN +#elif defined Q_OS_MAC // Q_OS_WINRT || Q_OS_WIN +#include "platform/mac/file_utilities_mac.h" +#else // Q_OS_WINRT || Q_OS_WIN || Q_OS_MAC +#include "platform/linux/file_utilities_linux.h" +#endif // else for Q_OS_WINRT || Q_OS_WIN || Q_OS_MAC diff --git a/Telegram/SourceFiles/platform/platform_integration.cpp b/Telegram/SourceFiles/platform/platform_integration.cpp index 021024c6f..d2f832eeb 100644 --- a/Telegram/SourceFiles/platform/platform_integration.cpp +++ b/Telegram/SourceFiles/platform/platform_integration.cpp @@ -7,13 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "platform/platform_integration.h" -#ifdef Q_OS_MAC -#include "platform/mac/integration_mac.h" -#elif defined Q_OS_UNIX // Q_OS_MAC -#include "platform/linux/integration_linux.h" -#elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX +#if defined Q_OS_WINRT || defined Q_OS_WIN #include "platform/win/integration_win.h" -#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WINRT || Q_OS_WIN +#elif defined Q_OS_MAC // Q_OS_WINRT || Q_OS_WIN +#include "platform/mac/integration_mac.h" +#else // Q_OS_WINRT || Q_OS_WIN || Q_OS_MAC +#include "platform/linux/integration_linux.h" +#endif // else Q_OS_WINRT || Q_OS_WIN || Q_OS_MAC namespace Platform { namespace { diff --git a/Telegram/SourceFiles/platform/platform_launcher.h b/Telegram/SourceFiles/platform/platform_launcher.h index d79aea65c..172730e67 100644 --- a/Telegram/SourceFiles/platform/platform_launcher.h +++ b/Telegram/SourceFiles/platform/platform_launcher.h @@ -21,10 +21,10 @@ namespace Platform { // Platform dependent implementations. -#ifdef Q_OS_MAC -#include "platform/mac/launcher_mac.h" -#elif defined Q_OS_UNIX // Q_OS_MAC -#include "platform/linux/launcher_linux.h" -#elif defined Q_OS_WINRT || defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX +#if defined Q_OS_WINRT || defined Q_OS_WIN #include "platform/win/launcher_win.h" -#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WINRT || Q_OS_WIN +#elif defined Q_OS_MAC // Q_OS_WINRT || Q_OS_WIN +#include "platform/mac/launcher_mac.h" +#else // Q_OS_WINRT || Q_OS_WIN || Q_OS_MAC +#include "platform/linux/launcher_linux.h" +#endif // else for Q_OS_WINRT || Q_OS_WIN || Q_OS_MAC diff --git a/Telegram/SourceFiles/platform/platform_main_window.h b/Telegram/SourceFiles/platform/platform_main_window.h index 4bdb93981..e52de1edc 100644 --- a/Telegram/SourceFiles/platform/platform_main_window.h +++ b/Telegram/SourceFiles/platform/platform_main_window.h @@ -17,10 +17,10 @@ class MainWindow; // Platform dependent implementations. -#ifdef Q_OS_MAC -#include "platform/mac/main_window_mac.h" -#elif defined Q_OS_UNIX // Q_OS_MAC -#include "platform/linux/main_window_linux.h" -#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX +#ifdef Q_OS_WIN #include "platform/win/main_window_win.h" -#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WIN +#elif defined Q_OS_MAC // Q_OS_WIN +#include "platform/mac/main_window_mac.h" +#else // Q_OS_WIN || Q_OS_MAC +#include "platform/linux/main_window_linux.h" +#endif // else Q_OS_WIN || Q_OS_MAC diff --git a/Telegram/SourceFiles/platform/platform_notifications_manager.h b/Telegram/SourceFiles/platform/platform_notifications_manager.h index 62db3378a..3ddb70a54 100644 --- a/Telegram/SourceFiles/platform/platform_notifications_manager.h +++ b/Telegram/SourceFiles/platform/platform_notifications_manager.h @@ -27,10 +27,10 @@ void Create(Window::Notifications::System *system); // Platform dependent implementations. -#ifdef Q_OS_MAC -#include "platform/mac/notifications_manager_mac.h" -#elif defined Q_OS_UNIX // Q_OS_MAC -#include "platform/linux/notifications_manager_linux.h" -#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX +#ifdef Q_OS_WIN #include "platform/win/notifications_manager_win.h" -#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WIN +#elif defined Q_OS_MAC // Q_OS_MAC +#include "platform/mac/notifications_manager_mac.h" +#else // Q_OS_WIN || Q_OS_MAC +#include "platform/linux/notifications_manager_linux.h" +#endif // else for Q_OS_WIN || Q_OS_MAC diff --git a/Telegram/SourceFiles/platform/platform_overlay_widget.h b/Telegram/SourceFiles/platform/platform_overlay_widget.h index 2de3687d0..5b599858a 100644 --- a/Telegram/SourceFiles/platform/platform_overlay_widget.h +++ b/Telegram/SourceFiles/platform/platform_overlay_widget.h @@ -95,10 +95,10 @@ private: // Platform dependent implementations. -#ifdef Q_OS_MAC -#include "platform/mac/overlay_widget_mac.h" -#elif defined Q_OS_UNIX // Q_OS_MAC -#include "platform/linux/overlay_widget_linux.h" -#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX +#ifdef Q_OS_WIN #include "platform/win/overlay_widget_win.h" -#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WIN +#elif defined Q_OS_MAC // Q_OS_WIN +#include "platform/mac/overlay_widget_mac.h" +#else // Q_OS_WIN || Q_OS_MAC +#include "platform/linux/overlay_widget_linux.h" +#endif // else for Q_OS_WIN || Q_OS_MAC diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h index 7db700e00..ce839beb1 100644 --- a/Telegram/SourceFiles/platform/platform_specific.h +++ b/Telegram/SourceFiles/platform/platform_specific.h @@ -63,10 +63,10 @@ void finish(); } // namespace ThirdParty } // namespace Platform -#ifdef Q_OS_MAC -#include "platform/mac/specific_mac.h" -#elif defined Q_OS_UNIX // Q_OS_MAC -#include "platform/linux/specific_linux.h" -#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX +#ifdef Q_OS_WIN #include "platform/win/specific_win.h" -#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WIN +#elif defined Q_OS_MAC // Q_OS_WIN +#include "platform/mac/specific_mac.h" +#else // Q_OS_WIN || Q_OS_MAC +#include "platform/linux/specific_linux.h" +#endif // else for Q_OS_WIN || Q_OS_MAC diff --git a/Telegram/SourceFiles/platform/platform_tray.h b/Telegram/SourceFiles/platform/platform_tray.h index 3d6b90724..0838b52e4 100644 --- a/Telegram/SourceFiles/platform/platform_tray.h +++ b/Telegram/SourceFiles/platform/platform_tray.h @@ -15,10 +15,10 @@ class Tray; // Platform dependent implementations. -#ifdef Q_OS_MAC -#include "platform/mac/tray_mac.h" -#elif defined Q_OS_UNIX // Q_OS_MAC -#include "platform/linux/tray_linux.h" -#elif defined Q_OS_WIN // Q_OS_MAC || Q_OS_UNIX +#ifdef Q_OS_WIN #include "platform/win/tray_win.h" -#endif // Q_OS_MAC || Q_OS_UNIX || Q_OS_WIN +#elif defined Q_OS_MAC // Q_OS_WIN +#include "platform/mac/tray_mac.h" +#else // Q_OS_WIN || Q_OS_MAC +#include "platform/linux/tray_linux.h" +#endif // else for Q_OS_WIN || Q_OS_MAC diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index 17e95b41a..246e67450 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/platform_specific.h" #include "platform/platform_notifications_manager.h" #include "base/platform/base_platform_info.h" +#include "base/call_delayed.h" #include "mainwindow.h" #include "core/application.h" #include "main/main_session.h" @@ -49,7 +50,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_dialogs.h" #include -#include namespace Settings { namespace { @@ -675,11 +675,11 @@ void NotificationsCount::SampleWidget::destroyDelayed() { _deleted = true; // Ubuntu has a lag if deleteLater() called immediately. -#if defined Q_OS_UNIX && !defined Q_OS_MAC - QTimer::singleShot(1000, [this] { delete this; }); -#else // Q_OS_UNIX && !Q_OS_MAC - deleteLater(); -#endif // Q_OS_UNIX && !Q_OS_MAC + if constexpr (Platform::IsLinux()) { + base::call_delayed(1000, this, [this] { delete this; }); + } else { + deleteLater(); + } } class NotifyPreview final { diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 795adbddd..153aa953f 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -76,9 +76,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include // Fix Google Breakpad build for Mac App Store and Linux version -#ifdef Q_OS_UNIX +#ifndef Q_OS_WIN #define __STDC_FORMAT_MACROS -#endif // Q_OS_UNIX +#endif // !Q_OS_WIN // Remove 'small' macro definition. #ifdef Q_OS_WIN diff --git a/Telegram/lib_base b/Telegram/lib_base index 07d3c631d..ed2134a98 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit 07d3c631d45f2ce50e8373dc934827350ed20758 +Subproject commit ed2134a980be19258b2e7c557367c12b94fda35d diff --git a/Telegram/lib_spellcheck b/Telegram/lib_spellcheck index dfc42b20c..135cb95b1 160000 --- a/Telegram/lib_spellcheck +++ b/Telegram/lib_spellcheck @@ -1 +1 @@ -Subproject commit dfc42b20ce602b105e5400e03eed626fd5bab7df +Subproject commit 135cb95b1606b9051b3a150a99b9db9c20bb1c11 diff --git a/Telegram/lib_storage b/Telegram/lib_storage index 839609369..1dfd1c186 160000 --- a/Telegram/lib_storage +++ b/Telegram/lib_storage @@ -1 +1 @@ -Subproject commit 839609369d04615475cb1518636de3619106a917 +Subproject commit 1dfd1c186dd67e8de5f0721e6fae487a05f3ea94 diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 8f7fe24ac..8d005bc82 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 8f7fe24ac49e5644749770f54e81fb5290c354d5 +Subproject commit 8d005bc820ac2653d15c07d974ede1e17a6ce0fa