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

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

Merged
merged 4 commits into from
Jul 1, 2023

Conversation

pajlada
Copy link
Member

@pajlada pajlada commented Jul 1, 2023

Description

  • Fix crash that could occurr if closing the usercard quickly after blocking or unblocking
  • Add unrelated -DUSE_ALTERNATE_LINKER cmake option

…cking or unblocking

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
@pajlada
Copy link
Member Author

pajlada commented Jul 1, 2023

image

@pajlada pajlada enabled auto-merge (squash) July 1, 2023 11:10
@pajlada pajlada merged commit d2f1516 into master Jul 1, 2023
@pajlada pajlada deleted the fix/block-crash-if-closing-user-info-popup branch July 1, 2023 12:01
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -121,11 +121,12 @@ void TwitchAccount::loadBlocks()
});
}

void TwitchAccount::blockUser(QString userId, std::function<void()> onSuccess,
void TwitchAccount::blockUser(QString userId, const QObject *caller,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'userId' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
void TwitchAccount::blockUser(QString userId, const QObject *caller,
void TwitchAccount::blockUser(const QString& userId, const QObject *caller,

src/providers/twitch/TwitchAccount.hpp:74:

-     void blockUser(QString userId, const QObject *caller,
+     void blockUser(const QString& userId, const QObject *caller,

@@ -121,11 +121,12 @@
});
}

void TwitchAccount::blockUser(QString userId, std::function<void()> onSuccess,
void TwitchAccount::blockUser(QString userId, const QObject *caller,
std::function<void()> onSuccess,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'onSuccess' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
std::function<void()> onSuccess,
const std::function<void()>& onSuccess,

src/providers/twitch/TwitchAccount.hpp:75:

-                    std::function<void()> onSuccess,
+                    const std::function<void()>& onSuccess,

@@ -141,11 +142,12 @@
std::move(onFailure));
}

void TwitchAccount::unblockUser(QString userId, std::function<void()> onSuccess,
void TwitchAccount::unblockUser(QString userId, const QObject *caller,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'userId' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
void TwitchAccount::unblockUser(QString userId, const QObject *caller,
void TwitchAccount::unblockUser(const QString& userId, const QObject *caller,

src/providers/twitch/TwitchAccount.hpp:77:

-     void unblockUser(QString userId, const QObject *caller,
+     void unblockUser(const QString& userId, const QObject *caller,

@@ -141,11 +142,12 @@
std::move(onFailure));
}

void TwitchAccount::unblockUser(QString userId, std::function<void()> onSuccess,
void TwitchAccount::unblockUser(QString userId, const QObject *caller,
std::function<void()> onSuccess,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: the parameter 'onSuccess' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
std::function<void()> onSuccess,
const std::function<void()>& onSuccess,

src/providers/twitch/TwitchAccount.hpp:78:

-                      std::function<void()> onSuccess,
+                      const std::function<void()>& onSuccess,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant