Skip to content

Commit

Permalink
fix: adapt tryGetApp in our changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Jan 5, 2025
1 parent 003cd96 commit c2d1c32
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/providers/seventv/SeventvEventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,13 @@ void SeventvEventAPI::onEmoteSetUpdate(const Dispatch &dispatch)

if (this->lastPersonalEmoteAssignment_->emoteSetID == dispatch.id)
{
auto *app = tryGetApp();
if (!app)
{
return;
}
auto emoteSet =
getApp()->getSeventvPersonalEmotes()->getEmoteSetByID(dispatch.id);
app->getSeventvPersonalEmotes()->getEmoteSetByID(dispatch.id);
if (emoteSet)
{
qCDebug(chatterinoSeventvEventAPI) << "Flushed last emote set";
Expand Down Expand Up @@ -414,7 +419,7 @@ void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
}
break;
case CosmeticKind::Paint: {
getApp()->getSeventvPaints()->addPaint(cosmetic.data);
app->getSeventvPaints()->addPaint(cosmetic.data);
}
break;
default:
Expand All @@ -440,7 +445,7 @@ void SeventvEventAPI::onEntitlementCreate(
}
break;
case CosmeticKind::Paint: {
getApp()->getSeventvPaints()->assignPaintToUser(
app->getSeventvPaints()->assignPaintToUser(
entitlement.refID, UserName{entitlement.userName});
}
break;
Expand All @@ -449,7 +454,7 @@ void SeventvEventAPI::onEntitlementCreate(
<< "Assign user" << entitlement.userID << "to emote set"
<< entitlement.refID;
if (auto set =
getApp()->getSeventvPersonalEmotes()->assignUserToEmoteSet(
app->getSeventvPersonalEmotes()->assignUserToEmoteSet(
entitlement.refID, entitlement.userID))
{
if ((*set)->empty())
Expand Down Expand Up @@ -495,7 +500,7 @@ void SeventvEventAPI::onEntitlementDelete(
}
break;
case CosmeticKind::Paint: {
getApp()->getSeventvPaints()->clearPaintFromUser(
app->getSeventvPaints()->clearPaintFromUser(
entitlement.refID, UserName{entitlement.userName});
}
break;
Expand All @@ -506,8 +511,6 @@ void SeventvEventAPI::onEntitlementDelete(

void SeventvEventAPI::onEmoteSetCreate(const Dispatch &dispatch)
{
// We're using `Application::instance` instead of getApp(), because we're not in the GUI thread.
// `seventvBadges` and `seventvPaints` do their own locking.
EmoteSetCreateDispatch createDispatch(dispatch.body["object"].toObject());
if (!createDispatch.validate())
{
Expand All @@ -516,12 +519,18 @@ void SeventvEventAPI::onEmoteSetCreate(const Dispatch &dispatch)
return;
}

auto *app = tryGetApp();
if (!app)
{
return; // shutting down
}

// other flags are "immutable" and "privileged"
if (createDispatch.isPersonalOrCommercial)
{
qCDebug(chatterinoSeventvEventAPI)
<< "Create emote set" << createDispatch.emoteSetID;
getApp()->getSeventvPersonalEmotes()->createEmoteSet(
app->getSeventvPersonalEmotes()->createEmoteSet(
createDispatch.emoteSetID);
}
else
Expand Down

0 comments on commit c2d1c32

Please sign in to comment.