diff --git a/extras/Projucer/Source/Application/jucer_AutoUpdater.cpp b/extras/Projucer/Source/Application/jucer_AutoUpdater.cpp index b16ed71e6a..ba3dfe173c 100644 --- a/extras/Projucer/Source/Application/jucer_AutoUpdater.cpp +++ b/extras/Projucer/Source/Application/jucer_AutoUpdater.cpp @@ -240,10 +240,9 @@ void LatestVersionCheckerAndUpdater::askUserForLocationToDownload (const Version { chooser = std::make_unique ("Please select the location into which you would like to install the new version", File { getAppSettings().getStoredPath (Ids::jucePath, TargetOS::getThisOS()).get() }); - auto flags = FileBrowserComponent::openMode - | FileBrowserComponent::canSelectDirectories; - chooser->launchAsync (flags, [this, asset] (const FileChooser& fc) + chooser->launchAsync (FileBrowserComponent::openMode | FileBrowserComponent::canSelectDirectories, + [weakThis = WeakReference { this }, asset] (const FileChooser& fc) { auto targetFolder = fc.getResult(); @@ -264,14 +263,13 @@ void LatestVersionCheckerAndUpdater::askUserForLocationToDownload (const Version auto targetFolderPath = targetFolder.getFullPathName(); - WeakReference parent { this }; - auto callback = ModalCallbackFunction::create ([parent, asset, targetFolder] (int result) + const auto onResult = [weakThis, asset, targetFolder] (int result) { - if (parent == nullptr || result == 0) + if (weakThis == nullptr || result == 0) return; - parent->downloadAndInstall (asset, targetFolder); - }); + weakThis->downloadAndInstall (asset, targetFolder); + }; if (willOverwriteJuceFolder) { @@ -291,7 +289,7 @@ void LatestVersionCheckerAndUpdater::askUserForLocationToDownload (const Version {}, {}, nullptr, - callback); + ModalCallbackFunction::create (onResult)); return; } @@ -303,11 +301,12 @@ void LatestVersionCheckerAndUpdater::askUserForLocationToDownload (const Version {}, {}, nullptr, - callback); + ModalCallbackFunction::create (onResult)); return; } - downloadAndInstall (asset, targetFolder); + if (weakThis != nullptr) + weakThis->downloadAndInstall (asset, targetFolder); }); } diff --git a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElement.cpp b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElement.cpp index 387d14aeee..1bc900cd25 100644 --- a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElement.cpp +++ b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElement.cpp @@ -670,7 +670,7 @@ void PaintElement::showPopupMenu() m.addCommandItem (commandManager, JucerCommandIDs::toBack); m.addSeparator(); - if (owner->getSelectedElements().getNumSelected() > 1) + if (owner != nullptr && owner->getSelectedElements().getNumSelected() > 1) { m.addCommandItem (commandManager, JucerCommandIDs::alignTop); m.addCommandItem (commandManager, JucerCommandIDs::alignRight);