88#include " CommonFramework/Globals.h"
99#include " CommonFramework/Exceptions/OperationFailedException.h"
1010#include " Common/Cpp/Filesystem.h"
11+ #include " Common/Cpp/ScopeExit.h"
1112#include " CommonFramework/Tools/FileDownloader.h"
1213#include " CommonFramework/Tools/FileUnzip.h"
1314#include " CommonFramework/Tools/FileHash.h"
@@ -51,14 +52,9 @@ void DownloadThread::start_download_thread(){
5152 }
5253
5354 // runs when lambda is finished
54- // updates action state, removes self from download queue
55- struct ScopeGuard {
56- DownloadThread* thread_ptr;
57- bool & success_ref;
58- ~ScopeGuard () {
59- thread_ptr->m_hooks .on_finished (success_ref);
60- }
61- } guard{this , success};
55+ ScopeExit on_exit ([&, this ]{
56+ m_hooks.on_finished (success);
57+ });
6258
6359 try {
6460 // std::this_thread::sleep_for(std::chrono::seconds(7));
@@ -78,10 +74,10 @@ void DownloadThread::start_download_thread(){
7874 }catch (const std::exception& e) {
7975 std::cout << " Standard exception: " << e.what () << std::endl;
8076 success = false ;
81- m_hooks.report_exception_caught (" ResourceDownloadButton::start_download " );
77+ m_hooks.report_exception_caught (" DownloadThread::start_download_thread " );
8278 } catch (...){
8379 success = false ;
84- m_hooks.report_exception_caught (" ResourceDownloadButton::start_download " );
80+ m_hooks.report_exception_caught (" DownloadThread::start_download_thread " );
8581 }
8682
8783 }
0 commit comments