diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 8a5e365f..1da5b97f 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -255,6 +255,9 @@ int main( int argc, char** argv ) std::thread loadThread; tracy::UdpListen* broadcastListen = nullptr; + enum class ViewShutdown { False, True, Join }; + ViewShutdown viewShutdown = ViewShutdown::False; + std::mutex resolvLock; tracy::flat_hash_map resolvMap; ResolvService resolv; @@ -554,7 +557,11 @@ int main( int argc, char** argv ) view->NotifyRootWindowSize( display_w, display_h ); if( !view->Draw() ) { - view.reset(); + viewShutdown = ViewShutdown::True; + loadThread = std::thread( [&viewShutdown, view = std::move( view )] () mutable { + view.reset(); + viewShutdown = ViewShutdown::Join; + } ); } } auto& progress = tracy::Worker::GetLoadProgress(); @@ -624,6 +631,27 @@ int main( int argc, char** argv ) } ImGui::EndPopup(); } + switch( viewShutdown ) + { + case ViewShutdown::True: + ImGui::OpenPopup( "Capture cleanup..." ); + break; + case ViewShutdown::Join: + loadThread.join(); + viewShutdown = ViewShutdown::False; + break; + default: + break; + } + if( ImGui::BeginPopupModal( "Capture cleanup...", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) + { + if( viewShutdown != ViewShutdown::True ) ImGui::CloseCurrentPopup(); + tracy::TextCentered( ICON_FA_BROOM ); + time += io.DeltaTime; + tracy::DrawWaitingDots( time ); + ImGui::Text( "Please wait, cleanup is in progress" ); + ImGui::EndPopup(); + } // Rendering ImGui::Render();