1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

InAppPurchasesDemo: Fix leaky ListBoxModel implementation

This commit is contained in:
reuk 2022-01-28 14:32:49 +00:00
parent 4cf74dfff6
commit 4a7b556463

View file

@ -442,15 +442,17 @@ public:
Component* refreshComponentForRow (int row, bool selected, Component* existing) override
{
auto safePtr = rawToUniquePtr (existing);
if (isPositiveAndBelow (row, voiceProducts.size()))
{
if (existing == nullptr)
existing = new VoiceRow (purchases);
if (safePtr == nullptr)
safePtr = std::make_unique<VoiceRow> (purchases);
if (auto* voiceRow = dynamic_cast<VoiceRow*> (existing))
if (auto* voiceRow = dynamic_cast<VoiceRow*> (safePtr.get()))
voiceRow->update (row, selected);
return existing;
return safePtr.release();
}
return nullptr;