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

PluginListComponent: Fix potential use-after-free on modal component dismiss

This commit is contained in:
reuk 2025-08-27 15:24:48 +01:00
parent f9b70f1d39
commit 6473deb155
No known key found for this signature in database
2 changed files with 14 additions and 7 deletions

View file

@ -154,7 +154,8 @@ public:
};
//==============================================================================
class PluginListComponent::Scanner final : private Timer
class PluginListComponent::Scanner final : public std::enable_shared_from_this<Scanner>,
private Timer
{
public:
Scanner (PluginListComponent& plc, AudioPluginFormat& format, const StringArray& filesOrIdentifiers,
@ -321,9 +322,10 @@ private:
progressWindow.addButton (TRANS ("Cancel"), 0, KeyPress (KeyPress::escapeKey));
progressWindow.addProgressBarComponent (progress);
progressWindow.enterModalState (true, ModalCallbackFunction::create ([this] (auto)
progressWindow.enterModalState (true, ModalCallbackFunction::create ([weak = weak_from_this()] (auto)
{
flags |= stopRequested;
if (const auto strong = weak.lock())
strong->flags |= stopRequested;
}));
if (numThreads > 0)
@ -650,9 +652,14 @@ void PluginListComponent::scanFor (AudioPluginFormat& format)
void PluginListComponent::scanFor (AudioPluginFormat& format, const StringArray& filesOrIdentifiersToScan)
{
currentScanner.reset (new Scanner (*this, format, filesOrIdentifiersToScan, propertiesToUse, allowAsync, numThreads,
dialogTitle.isNotEmpty() ? dialogTitle : TRANS ("Scanning for plug-ins..."),
dialogText.isNotEmpty() ? dialogText : TRANS ("Searching for all possible plug-in files...")));
currentScanner = std::make_shared<Scanner> (*this,
format,
filesOrIdentifiersToScan,
propertiesToUse,
allowAsync,
numThreads,
dialogTitle.isNotEmpty() ? dialogTitle : TRANS ("Scanning for plug-ins..."),
dialogText.isNotEmpty() ? dialogText : TRANS ("Searching for all possible plug-in files..."));
}
bool PluginListComponent::isScanning() const noexcept

View file

@ -137,7 +137,7 @@ private:
std::unique_ptr<TableListBoxModel> tableModel;
class Scanner;
std::unique_ptr<Scanner> currentScanner;
std::shared_ptr<Scanner> currentScanner;
ScopedMessageBox messageBox;