Browse Source

InAppPurchasesDemo: Fix leaky ListBoxModel implementation

v6.1.6
reuk 3 years ago
parent
commit
4a7b556463
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      examples/Utilities/InAppPurchasesDemo.h

+ 6
- 4
examples/Utilities/InAppPurchasesDemo.h 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;


Loading…
Cancel
Save