Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- Dev: Clarify signal connection lifetimes where applicable. (#4818)
- Dev: Laid the groundwork for advanced input completion strategies. (#4639, #4846, #4853)
- 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

Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ option(BUILD_SHARED_LIBS "" OFF)
option(CHATTERINO_LTO "Enable LTO for all targets" 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)
include(CheckIPOSupported)
check_ipo_supported(RESULT CHATTERINO_ENABLE_LTO OUTPUT IPO_ERROR)
Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1039,3 +1039,8 @@ if(CHATTERINO_ENABLE_LTO)
set_property(TARGET ${LIBRARY_PROJECT}
PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

if(NOT CHATTERINO_UPDATER)
message(STATUS "Disabling the updater.")
target_compile_definitions(${LIBRARY_PROJECT} PUBLIC CHATTERINO_DISABLE_UPDATER)
endif()
14 changes: 8 additions & 6 deletions src/singletons/Updates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ void Updates::installUpdates()

void Updates::checkForUpdates()
{
#ifndef CHATTERINO_DISABLE_UPDATER
auto version = Version::instance();

if (!version.isSupportedOS())
Expand Down Expand Up @@ -291,7 +292,7 @@ void Updates::checkForUpdates()
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
auto updateExeUrl = object["updateexe"];
if (!updateExeUrl.isString())
Expand All @@ -303,7 +304,7 @@ void Updates::checkForUpdates()
}
this->updateExe_ = updateExeUrl.toString();

# ifdef Q_OS_WIN
# ifdef Q_OS_WIN
/// Windows portable
auto portableUrl = object["portable_download"];
if (!portableUrl.isString())
Expand All @@ -315,17 +316,17 @@ void Updates::checkForUpdates()
return Failure;
}
this->updatePortable_ = portableUrl.toString();
# endif
# endif

#elif defined Q_OS_LINUX
# elif defined Q_OS_LINUX
QJsonValue updateGuide = object.value("updateguide");
if (updateGuide.isString())
{
this->updateGuideLink_ = updateGuide.toString();
}
#else
# else
return Failure;
#endif
# endif

/// Current version
this->onlineVersion_ = version.toString();
Expand All @@ -345,6 +346,7 @@ void Updates::checkForUpdates()
})
.execute();
this->setStatus_(Searching);
#endif
}

Updates::Status Updates::getStatus() const
Expand Down
Loading