From 547cc4dbf69bf53f49f50ef1f44c46a74821b51a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 29 Aug 2020 22:19:09 +1000 Subject: [PATCH] Qt: Clear OSD messages on system stop --- src/duckstation-qt/qthostinterface.cpp | 1 + src/frontend-common/common_host_interface.cpp | 6 ++++++ src/frontend-common/common_host_interface.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index df1f4b6aa..a1b60a00b 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -641,6 +641,7 @@ void QtHostInterface::OnSystemDestroyed() { CommonHostInterface::OnSystemDestroyed(); + ClearOSDMessages(); startBackgroundControllerPollTimer(); emit emulationStopped(); } diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 73b7a87d3..26bbc4315 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -830,6 +830,12 @@ void CommonHostInterface::AddOSDMessage(std::string message, float duration /*= m_osd_messages.push_back(std::move(msg)); } +void CommonHostInterface::ClearOSDMessages() +{ + std::unique_lock lock(m_osd_messages_lock); + m_osd_messages.clear(); +} + void CommonHostInterface::DrawOSDMessages() { constexpr ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h index 78007c3f3..cc2218d65 100644 --- a/src/frontend-common/common_host_interface.h +++ b/src/frontend-common/common_host_interface.h @@ -128,6 +128,7 @@ public: /// Adds OSD messages, duration is in seconds. void AddOSDMessage(std::string message, float duration = 2.0f) override; + void ClearOSDMessages(); /// Displays a loading screen with the logo, rendered with ImGui. Use when executing possibly-time-consuming tasks /// such as compiling shaders when starting up.