| 349 | } |
| 350 | |
| 351 | void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt)) |
| 352 | { |
| 353 | auto result = ProgressResult::Success; |
| 354 | { |
| 355 | // Make sure the progress dialog is deleted before we call EndModal() or |
| 356 | // we will leave the project window in an unusable state on OSX. |
| 357 | // See bug #1192. |
| 358 | std::unique_ptr<ProgressDialog> dialog; |
| 359 | wxArrayString last3; |
| 360 | auto updateProgress = [&](int num, int denom, const wxString& msg) |
| 361 | { |
| 362 | last3.insert(last3.begin(), msg); |
| 363 | if(last3.size() > 3) |
| 364 | last3.pop_back(); |
| 365 | if(!dialog) |
| 366 | { |
| 367 | dialog = std::make_unique<ProgressDialog>( |
| 368 | Verbatim( GetTitle() ), |
| 369 | TranslatableString {}, |
| 370 | pdlgHideStopButton |
| 371 | ); |
| 372 | dialog->CenterOnParent(); |
| 373 | } |
| 374 | result = dialog->Update( |
| 375 | num, |
| 376 | denom, |
| 377 | TranslatableString(wxJoin(last3, '\n'), {}) |
| 378 | ); |
| 379 | return result == ProgressResult::Success; |
| 380 | }; |
| 381 | auto onError = [](const TranslatableString& error) { |
| 382 | AudacityMessageBox(error); |
| 383 | }; |
| 384 | |
| 385 | mPluginsModel->ApplyChanges(updateProgress, onError); |
| 386 | } |
| 387 | if(result == ProgressResult::Success) |
| 388 | EndModal(wxID_OK); |
| 389 | else |
| 390 | ReloadModel(); |
| 391 | |
| 392 | } |
| 393 | |
| 394 | void PluginRegistrationDialog::OnCancel(wxCommandEvent & WXUNUSED(evt)) |
| 395 | { |
nothing calls this directly
no test coverage detected