Fix crash that could occur if closing the usercard quickly after blocking (#4711)

* Specifically, this adds a caller to the network request, which makes the
success or failure callback not fire.
This has the unintended consequence of the block list not reloading if
the usercard is closed, but it's not a big concern.

* Add unrelated `-DUSE_ALTERNATE_LINKER` cmake option

From https://github.com/heavyai/heavydb/blob/0517d99b467806f6af7b4c969e351368a667497d/CMakeLists.txt#L87-L103
This commit is contained in:
pajlada
2023-07-01 14:01:47 +02:00
committed by GitHub
parent 2f272b37ca
commit d2f1516818
9 changed files with 52 additions and 18 deletions
+2
View File
@@ -16,6 +16,7 @@
- Bugfix: Fix visual glitches with smooth scrolling. (#4501) - Bugfix: Fix visual glitches with smooth scrolling. (#4501)
- Bugfix: Fixed pings firing for the "Your username" highlight when not signed in. (#4698) - Bugfix: Fixed pings firing for the "Your username" highlight when not signed in. (#4698)
- Bugfix: Fixed partially broken filters on Qt 6 builds. (#4702) - Bugfix: Fixed partially broken filters on Qt 6 builds. (#4702)
- Bugfix: Fixed crash that could occurr when closing the usercard too quickly after blocking or unblocking a user. (#4711)
- Dev: Added command to set Qt's logging filter/rules at runtime (`/c2-set-logging-rules`). (#4637) - Dev: Added command to set Qt's logging filter/rules at runtime (`/c2-set-logging-rules`). (#4637)
- Dev: Added the ability to see & load custom themes from the Themes directory. No stable promises are made of this feature, changes might be made that breaks custom themes without notice. (#4570) - Dev: Added the ability to see & load custom themes from the Themes directory. No stable promises are made of this feature, changes might be made that breaks custom themes without notice. (#4570)
- Dev: Added test cases for emote and tab completion. (#4644) - Dev: Added test cases for emote and tab completion. (#4644)
@@ -30,6 +31,7 @@
- Dev: Added `sccache` in Windows CI. (#4678) - Dev: Added `sccache` in Windows CI. (#4678)
- Dev: Moved preprocessor Git and date definitions to executables only. (#4681) - Dev: Moved preprocessor Git and date definitions to executables only. (#4681)
- Dev: Refactored tests to be able to use `ctest` and run in debug builds. (#4700) - Dev: Refactored tests to be able to use `ctest` and run in debug builds. (#4700)
- Dev: Added the ability to use an alternate linker using the `-DUSE_ALTERNATE_LINKER=...` CMake parameter. (#4711)
## 2.4.4 ## 2.4.4
+21
View File
@@ -49,6 +49,27 @@ elseif (CCACHE_PROGRAM)
set(_compiler_launcher ${CCACHE_PROGRAM}) set(_compiler_launcher ${CCACHE_PROGRAM})
endif () endif ()
# Alternate linker code taken from heavyai/heavydb
# https://github.com/heavyai/heavydb/blob/0517d99b467806f6af7b4c969e351368a667497d/CMakeLists.txt#L87-L103
macro(set_alternate_linker linker)
find_program(LINKER_EXECUTABLE ld.${USE_ALTERNATE_LINKER} ${USE_ALTERNATE_LINKER})
if(LINKER_EXECUTABLE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 12.0.0)
add_link_options("-ld-path=${USE_ALTERNATE_LINKER}")
else()
add_link_options("-fuse-ld=${USE_ALTERNATE_LINKER}")
endif()
else()
set(USE_ALTERNATE_LINKER "" CACHE STRING "Use alternate linker" FORCE)
endif()
endmacro()
set(USE_ALTERNATE_LINKER "" CACHE STRING "Use alternate linker. Leave empty for system default; alternatives are 'gold', 'lld', 'bfd', 'mold'")
if(NOT "${USE_ALTERNATE_LINKER}" STREQUAL "")
set_alternate_linker(${USE_ALTERNATE_LINKER})
endif()
if (_compiler_launcher) if (_compiler_launcher)
set(CMAKE_CXX_COMPILER_LAUNCHER "${_compiler_launcher}" CACHE STRING "CXX compiler launcher") set(CMAKE_CXX_COMPILER_LAUNCHER "${_compiler_launcher}" CACHE STRING "CXX compiler launcher")
message(STATUS "Using ${_compiler_launcher} for speeding up build") message(STATUS "Using ${_compiler_launcher} for speeding up build")
+4 -2
View File
@@ -105,12 +105,14 @@ public:
(override)); (override));
MOCK_METHOD(void, blockUser, MOCK_METHOD(void, blockUser,
(QString targetUserId, std::function<void()> successCallback, (QString targetUserId, const QObject *caller,
std::function<void()> successCallback,
HelixFailureCallback failureCallback), HelixFailureCallback failureCallback),
(override)); (override));
MOCK_METHOD(void, unblockUser, MOCK_METHOD(void, unblockUser,
(QString targetUserId, std::function<void()> successCallback, (QString targetUserId, const QObject *caller,
std::function<void()> successCallback,
HelixFailureCallback failureCallback), HelixFailureCallback failureCallback),
(override)); (override));
@@ -650,7 +650,7 @@ void CommandController::initialize(Settings &, Paths &paths)
target, target,
[currentUser, channel, target](const HelixUser &targetUser) { [currentUser, channel, target](const HelixUser &targetUser) {
getApp()->accounts->twitch.getCurrent()->blockUser( getApp()->accounts->twitch.getCurrent()->blockUser(
targetUser.id, targetUser.id, nullptr,
[channel, target, targetUser] { [channel, target, targetUser] {
channel->addMessage(makeSystemMessage( channel->addMessage(makeSystemMessage(
QString("You successfully blocked user %1") QString("You successfully blocked user %1")
@@ -703,7 +703,7 @@ void CommandController::initialize(Settings &, Paths &paths)
target, target,
[currentUser, channel, target](const auto &targetUser) { [currentUser, channel, target](const auto &targetUser) {
getApp()->accounts->twitch.getCurrent()->unblockUser( getApp()->accounts->twitch.getCurrent()->unblockUser(
targetUser.id, targetUser.id, nullptr,
[channel, target, targetUser] { [channel, target, targetUser] {
channel->addMessage(makeSystemMessage( channel->addMessage(makeSystemMessage(
QString("You successfully unblocked user %1") QString("You successfully unblocked user %1")
+6 -4
View File
@@ -121,11 +121,12 @@ void TwitchAccount::loadBlocks()
}); });
} }
void TwitchAccount::blockUser(QString userId, std::function<void()> onSuccess, void TwitchAccount::blockUser(QString userId, const QObject *caller,
std::function<void()> onSuccess,
std::function<void()> onFailure) std::function<void()> onFailure)
{ {
getHelix()->blockUser( getHelix()->blockUser(
userId, userId, caller,
[this, userId, onSuccess] { [this, userId, onSuccess] {
TwitchUser blockedUser; TwitchUser blockedUser;
blockedUser.id = userId; blockedUser.id = userId;
@@ -141,11 +142,12 @@ void TwitchAccount::blockUser(QString userId, std::function<void()> onSuccess,
std::move(onFailure)); std::move(onFailure));
} }
void TwitchAccount::unblockUser(QString userId, std::function<void()> onSuccess, void TwitchAccount::unblockUser(QString userId, const QObject *caller,
std::function<void()> onSuccess,
std::function<void()> onFailure) std::function<void()> onFailure)
{ {
getHelix()->unblockUser( getHelix()->unblockUser(
userId, userId, caller,
[this, userId, onSuccess] { [this, userId, onSuccess] {
TwitchUser ignoredUser; TwitchUser ignoredUser;
ignoredUser.id = userId; ignoredUser.id = userId;
+5 -2
View File
@@ -9,6 +9,7 @@
#include <QColor> #include <QColor>
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QObject>
#include <QString> #include <QString>
#include <rapidjson/document.h> #include <rapidjson/document.h>
@@ -71,9 +72,11 @@ public:
bool isAnon() const; bool isAnon() const;
void loadBlocks(); void loadBlocks();
void blockUser(QString userId, std::function<void()> onSuccess, void blockUser(QString userId, const QObject *caller,
std::function<void()> onSuccess,
std::function<void()> onFailure); std::function<void()> onFailure);
void unblockUser(QString userId, std::function<void()> onSuccess, void unblockUser(QString userId, const QObject *caller,
std::function<void()> onSuccess,
std::function<void()> onFailure); std::function<void()> onFailure);
SharedAccessGuard<const std::set<QString>> accessBlockedUserIds() const; SharedAccessGuard<const std::set<QString>> accessBlockedUserIds() const;
+4 -2
View File
@@ -541,7 +541,7 @@ void Helix::loadBlocks(QString userId,
.execute(); .execute();
} }
void Helix::blockUser(QString targetUserId, void Helix::blockUser(QString targetUserId, const QObject *caller,
std::function<void()> successCallback, std::function<void()> successCallback,
HelixFailureCallback failureCallback) HelixFailureCallback failureCallback)
{ {
@@ -549,6 +549,7 @@ void Helix::blockUser(QString targetUserId,
urlQuery.addQueryItem("target_user_id", targetUserId); urlQuery.addQueryItem("target_user_id", targetUserId);
this->makePut("users/blocks", urlQuery) this->makePut("users/blocks", urlQuery)
.caller(caller)
.onSuccess([successCallback](auto /*result*/) -> Outcome { .onSuccess([successCallback](auto /*result*/) -> Outcome {
successCallback(); successCallback();
return Success; return Success;
@@ -560,7 +561,7 @@ void Helix::blockUser(QString targetUserId,
.execute(); .execute();
} }
void Helix::unblockUser(QString targetUserId, void Helix::unblockUser(QString targetUserId, const QObject *caller,
std::function<void()> successCallback, std::function<void()> successCallback,
HelixFailureCallback failureCallback) HelixFailureCallback failureCallback)
{ {
@@ -568,6 +569,7 @@ void Helix::unblockUser(QString targetUserId,
urlQuery.addQueryItem("target_user_id", targetUserId); urlQuery.addQueryItem("target_user_id", targetUserId);
this->makeDelete("users/blocks", urlQuery) this->makeDelete("users/blocks", urlQuery)
.caller(caller)
.onSuccess([successCallback](auto /*result*/) -> Outcome { .onSuccess([successCallback](auto /*result*/) -> Outcome {
successCallback(); successCallback();
return Success; return Success;
+5 -4
View File
@@ -805,12 +805,12 @@ public:
HelixFailureCallback failureCallback) = 0; HelixFailureCallback failureCallback) = 0;
// https://dev.twitch.tv/docs/api/reference#block-user // https://dev.twitch.tv/docs/api/reference#block-user
virtual void blockUser(QString targetUserId, virtual void blockUser(QString targetUserId, const QObject *caller,
std::function<void()> successCallback, std::function<void()> successCallback,
HelixFailureCallback failureCallback) = 0; HelixFailureCallback failureCallback) = 0;
// https://dev.twitch.tv/docs/api/reference#unblock-user // https://dev.twitch.tv/docs/api/reference#unblock-user
virtual void unblockUser(QString targetUserId, virtual void unblockUser(QString targetUserId, const QObject *caller,
std::function<void()> successCallback, std::function<void()> successCallback,
HelixFailureCallback failureCallback) = 0; HelixFailureCallback failureCallback) = 0;
@@ -1118,11 +1118,12 @@ public:
HelixFailureCallback failureCallback) final; HelixFailureCallback failureCallback) final;
// https://dev.twitch.tv/docs/api/reference#block-user // https://dev.twitch.tv/docs/api/reference#block-user
void blockUser(QString targetUserId, std::function<void()> successCallback, void blockUser(QString targetUserId, const QObject *caller,
std::function<void()> successCallback,
HelixFailureCallback failureCallback) final; HelixFailureCallback failureCallback) final;
// https://dev.twitch.tv/docs/api/reference#unblock-user // https://dev.twitch.tv/docs/api/reference#unblock-user
void unblockUser(QString targetUserId, void unblockUser(QString targetUserId, const QObject *caller,
std::function<void()> successCallback, std::function<void()> successCallback,
HelixFailureCallback failureCallback) final; HelixFailureCallback failureCallback) final;
+3 -2
View File
@@ -36,6 +36,7 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#include <QPointer>
const QString TEXT_FOLLOWERS("Followers: %1"); const QString TEXT_FOLLOWERS("Followers: %1");
const QString TEXT_CREATED("Created: %1"); const QString TEXT_CREATED("Created: %1");
@@ -593,7 +594,7 @@ void UserInfoPopup::installEvents()
this->ui_.block->setEnabled(false); this->ui_.block->setEnabled(false);
getApp()->accounts->twitch.getCurrent()->unblockUser( getApp()->accounts->twitch.getCurrent()->unblockUser(
this->userId_, this->userId_, this,
[this, reenableBlockCheckbox, currentUser] { [this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage( this->channel_->addMessage(makeSystemMessage(
QString("You successfully unblocked user %1") QString("You successfully unblocked user %1")
@@ -620,7 +621,7 @@ void UserInfoPopup::installEvents()
this->ui_.block->setEnabled(false); this->ui_.block->setEnabled(false);
getApp()->accounts->twitch.getCurrent()->blockUser( getApp()->accounts->twitch.getCurrent()->blockUser(
this->userId_, this->userId_, this,
[this, reenableBlockCheckbox, currentUser] { [this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage( this->channel_->addMessage(makeSystemMessage(
QString("You successfully blocked user %1") QString("You successfully blocked user %1")