From e6f4eadc024faa1e0e9b0a036790021cbbdb2dd6 Mon Sep 17 00:00:00 2001 From: Nicholas Guriev Date: Tue, 13 Sep 2022 17:16:01 +0300 Subject: [PATCH] Packed resources Dynamically load packed resources from a separate file. This reduces amount of main memory required for linking stage. --- Telegram/CMakeLists.txt | 13 +++++++++++-- .../SourceFiles/platform/linux/launcher_linux.cpp | 2 ++ Telegram/SourceFiles/platform/mac/launcher_mac.mm | 3 +-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 147042d46d686..7388b32722c0a 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -48,7 +48,12 @@ if (WIN32) endif() set_target_properties(Telegram PROPERTIES AUTOMOC ON) -target_prepare_qrc(Telegram) +if (LINUX) + # Do not repeat app name in path of a resource archive. + target_prepare_qrc(Telegram tresources.rcc) +else() + target_prepare_qrc(Telegram) +endif() target_link_libraries(Telegram PRIVATE @@ -1657,7 +1662,11 @@ if (LINUX AND DESKTOP_APP_USE_PACKAGED) include(GNUInstallDirs) configure_file("../lib/xdg/telegramdesktop.metainfo.xml.in" "${CMAKE_CURRENT_BINARY_DIR}/telegramdesktop.metainfo.xml" @ONLY) generate_appdata_changelog(Telegram "${CMAKE_SOURCE_DIR}/changelog.txt" "${CMAKE_CURRENT_BINARY_DIR}/telegramdesktop.metainfo.xml") - install(TARGETS Telegram RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}") + install(TARGETS Telegram + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}" + RESOURCE DESTINATION "${CMAKE_INSTALL_DATADIR}/TelegramDesktop" + ) install(FILES "Resources/art/icon16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "telegram.png") install(FILES "Resources/art/icon32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "telegram.png") install(FILES "Resources/art/icon48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "telegram.png") diff --git a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp index e3af76c18376d..d91fec5f356c6 100644 --- a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp @@ -7,6 +7,7 @@ For license and copyright information please follow this link: */ #include "platform/linux/launcher_linux.h" +#include "base/base_file_utilities.h" #include "core/crash_reports.h" #include "core/update_checker.h" #include "webview/platform/linux/webview_linux_webkit2gtk.h" @@ -64,6 +65,7 @@ int Launcher::exec() { void Launcher::initHook() { QApplication::setAttribute(Qt::AA_DisableSessionManager, true); + base::RegisterResourceArchive(u"tresources.rcc"_q); } bool Launcher::launchUpdater(UpdaterLaunch action) { diff --git a/Telegram/SourceFiles/platform/mac/launcher_mac.mm b/Telegram/SourceFiles/platform/mac/launcher_mac.mm index 95d15a8eff586..8495062021c4c 100644 --- a/Telegram/SourceFiles/platform/mac/launcher_mac.mm +++ b/Telegram/SourceFiles/platform/mac/launcher_mac.mm @@ -26,8 +26,7 @@ void Launcher::initHook() { // macOS Retina display support is working fine, others are not. QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false); - - base::RegisterBundledResources(u"Telegram.rcc"_q); + base::RegisterResourceArchive(u"Telegram.rcc"_q); } bool Launcher::launchUpdater(UpdaterLaunch action) {