Implement compile-time flag to disable automatic update checks. (#4854)

Usage: `cmake -DCHATTERINO_UPDATER=OFF ..`

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
This commit is contained in:
Patrick Klein 2023-10-02 10:43:20 +01:00 committed by GitHub
parent bc218b4261
commit 5b17ae3f7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View file

@ -29,6 +29,7 @@
- Dev: Clarify signal connection lifetimes where applicable. (#4818) - Dev: Clarify signal connection lifetimes where applicable. (#4818)
- Dev: Laid the groundwork for advanced input completion strategies. (#4639, #4846, #4853) - Dev: Laid the groundwork for advanced input completion strategies. (#4639, #4846, #4853)
- Dev: Fixed flickering when running with Direct2D on Windows. (#4851) - Dev: Fixed flickering when running with Direct2D on Windows. (#4851)
- Dev: Add a compile-time flag `CHATTERINO_DISABLE_UPDATER` to disable update checks. (#4854)
## 2.4.6 ## 2.4.6

View file

@ -27,6 +27,9 @@ option(BUILD_SHARED_LIBS "" OFF)
option(CHATTERINO_LTO "Enable LTO for all targets" OFF) option(CHATTERINO_LTO "Enable LTO for all targets" OFF)
option(CHATTERINO_PLUGINS "Enable EXPERIMENTAL plugin support in Chatterino" OFF) option(CHATTERINO_PLUGINS "Enable EXPERIMENTAL plugin support in Chatterino" OFF)
option(CHATTERINO_UPDATER "Enable update checks" ON)
mark_as_advanced(CHATTERINO_UPDATER)
if(CHATTERINO_LTO) if(CHATTERINO_LTO)
include(CheckIPOSupported) include(CheckIPOSupported)
check_ipo_supported(RESULT CHATTERINO_ENABLE_LTO OUTPUT IPO_ERROR) check_ipo_supported(RESULT CHATTERINO_ENABLE_LTO OUTPUT IPO_ERROR)

View file

@ -1039,3 +1039,8 @@ if(CHATTERINO_ENABLE_LTO)
set_property(TARGET ${LIBRARY_PROJECT} set_property(TARGET ${LIBRARY_PROJECT}
PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif() endif()
if(NOT CHATTERINO_UPDATER)
message(STATUS "Disabling the updater.")
target_compile_definitions(${LIBRARY_PROJECT} PUBLIC CHATTERINO_DISABLE_UPDATER)
endif()

View file

@ -250,6 +250,7 @@ void Updates::installUpdates()
void Updates::checkForUpdates() void Updates::checkForUpdates()
{ {
#ifndef CHATTERINO_DISABLE_UPDATER
auto version = Version::instance(); auto version = Version::instance();
if (!version.isSupportedOS()) if (!version.isSupportedOS())
@ -291,7 +292,7 @@ void Updates::checkForUpdates()
return Failure; return Failure;
} }
#if defined Q_OS_WIN || defined Q_OS_MACOS # if defined Q_OS_WIN || defined Q_OS_MACOS
/// Downloads an installer for the new version /// Downloads an installer for the new version
auto updateExeUrl = object["updateexe"]; auto updateExeUrl = object["updateexe"];
if (!updateExeUrl.isString()) if (!updateExeUrl.isString())
@ -303,7 +304,7 @@ void Updates::checkForUpdates()
} }
this->updateExe_ = updateExeUrl.toString(); this->updateExe_ = updateExeUrl.toString();
# ifdef Q_OS_WIN # ifdef Q_OS_WIN
/// Windows portable /// Windows portable
auto portableUrl = object["portable_download"]; auto portableUrl = object["portable_download"];
if (!portableUrl.isString()) if (!portableUrl.isString())
@ -315,17 +316,17 @@ void Updates::checkForUpdates()
return Failure; return Failure;
} }
this->updatePortable_ = portableUrl.toString(); this->updatePortable_ = portableUrl.toString();
# endif # endif
#elif defined Q_OS_LINUX # elif defined Q_OS_LINUX
QJsonValue updateGuide = object.value("updateguide"); QJsonValue updateGuide = object.value("updateguide");
if (updateGuide.isString()) if (updateGuide.isString())
{ {
this->updateGuideLink_ = updateGuide.toString(); this->updateGuideLink_ = updateGuide.toString();
} }
#else # else
return Failure; return Failure;
#endif # endif
/// Current version /// Current version
this->onlineVersion_ = version.toString(); this->onlineVersion_ = version.toString();
@ -345,6 +346,7 @@ void Updates::checkForUpdates()
}) })
.execute(); .execute();
this->setStatus_(Searching); this->setStatus_(Searching);
#endif
} }
Updates::Status Updates::getStatus() const Updates::Status Updates::getStatus() const