From 3234823a1ac92917b678cdbc5c6d111210f99add Mon Sep 17 00:00:00 2001 From: bubnikv <bubnikv@gmail.com> Date: Fri, 13 Mar 2020 19:30:41 +0100 Subject: [PATCH] Windows do not send an update on insert / eject of an SD card into an external SD card reader. Windows also do not send an update on software eject of a FLASH drive. We can likely use the Windows WMI API, but it will be quite time consuming to implement, therefore we lower the polling interval back to two seconds. https://www.codeproject.com/Articles/10539/Making-WMI-Queries-In-C https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page https://docs.microsoft.com/en-us/windows/win32/wmisdk/com-api-for-wmi https://docs.microsoft.com/en-us/windows/win32/wmisdk/example--receiving-event-notifications-through-wmi- --- src/slic3r/GUI/RemovableDriveManager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 17aa60997..cdb1c1d45 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -450,9 +450,14 @@ void RemovableDriveManager::thread_proc() { std::unique_lock<std::mutex> lck(m_thread_stop_mutex); #ifdef _WIN32 - // Wait 30 seconds for the stop signal, wake up time to time to remove those devices that the user ejected in file explorer - // or another application (for example in Cura). This is a workaround, as Windows does not send an event on software eject of a drive. - m_thread_stop_condition.wait_for(lck, std::chrono::seconds(30), [this]{ return m_stop || m_wakeup; }); + // Windows do not send an update on insert / eject of an SD card into an external SD card reader. + // Windows also do not send an update on software eject of a FLASH drive. + // We can likely use the Windows WMI API, but it will be quite time consuming to implement. + // https://www.codeproject.com/Articles/10539/Making-WMI-Queries-In-C + // https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page + // https://docs.microsoft.com/en-us/windows/win32/wmisdk/com-api-for-wmi + // https://docs.microsoft.com/en-us/windows/win32/wmisdk/example--receiving-event-notifications-through-wmi- + m_thread_stop_condition.wait_for(lck, std::chrono::seconds(2), [this]{ return m_stop || m_wakeup; }); #else m_thread_stop_condition.wait_for(lck, std::chrono::seconds(2), [this]{ return m_stop; }); #endif