@@ -196,11 +196,13 @@ class ToolchainInstaller final : public Component
196196 auto success = Decompress::extractTarXz ((uint8_t const *)toolchainData.getData (), toolchainData.getSize (), toolchainDir.getParentDirectory (), expectedSize);
197197
198198 if (!success || statusCode >= 400 ) {
199- MessageManager::callAsync ([this ] {
200- installButton.topText = " Try Again" ;
201- errorMessage = " Error: Could not extract downloaded package" ;
202- repaint ();
203- stopTimer ();
199+ MessageManager::callAsync ([_this = SafePointer (this )] {
200+ if (!_this)
201+ return ;
202+ _this->installButton .topText = " Try Again" ;
203+ _this->errorMessage = " Error: Could not extract downloaded package" ;
204+ _this->repaint ();
205+ _this->stopTimer ();
204206 });
205207 return ;
206208 }
@@ -210,8 +212,9 @@ class ToolchainInstaller final : public Component
210212 File driverSpec = toolchainDir.getChildFile (" etc" ).getChildFile (" usb_driver" ).getChildFile (" DFU_in_FS_Mode.inf" );
211213
212214 // Since we interact with ComponentPeer, better call it from the message thread
213- MessageManager::callAsync ([this , usbDriverInstaller, driverSpec]() mutable {
214- OSUtils::runAsAdmin (usbDriverInstaller.getFullPathName ().toStdString (), (" install --inf=" + driverSpec.getFullPathName ()).toStdString (), editor->getPeer ());
215+ MessageManager::callAsync ([_this = SafePointer (this ), usbDriverInstaller, driverSpec]() mutable {
216+ if (_this)
217+ OSUtils::runAsAdmin (usbDriverInstaller.getFullPathName ().toStdString (), (" install --inf=" + driverSpec.getFullPathName ()).toStdString (), _this->editor ->getPeer ());
215218 });
216219#endif
217220
@@ -239,9 +242,11 @@ class ToolchainInstaller final : public Component
239242 installProgress = 0 .0f ;
240243 stopTimer ();
241244
242- MessageManager::callAsync ([this ] {
243- dialog->setBlockFromClosing (false );
244- toolchainInstalledCallback ();
245+ MessageManager::callAsync ([_this = SafePointer (this )] {
246+ if (!_this)
247+ return ;
248+ _this->dialog ->setBlockFromClosing (false );
249+ _this->toolchainInstalledCallback ();
245250 });
246251 }
247252
0 commit comments