mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 05:37:52 -06:00
Win32 specific: Using SHChangeNotifyRegister to get notifications
on removable media insert / eject events. From now on we no more poll for removable media on Windows. Thanks @mjgtp from prusaprinters.org See the following discussion: https://forum.prusaprinters.org/forum/prusaslicer/prusaslicer-trying-to-access-my-floppy-disk-a The final working code sample was taken from Chromium source code, volume_mount_watcher_win.cc
This commit is contained in:
parent
3fdd643f49
commit
58192ba6c2
4 changed files with 73 additions and 11 deletions
|
@ -452,14 +452,8 @@ void RemovableDriveManager::thread_proc()
|
|||
{
|
||||
std::unique_lock<std::mutex> lck(m_thread_stop_mutex);
|
||||
#ifdef _WIN32
|
||||
// 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; });
|
||||
// Reacting to updates by WM_DEVICECHANGE and WM_USER_MEDIACHANGED
|
||||
m_thread_stop_condition.wait(lck, [this]{ return m_stop || m_wakeup; });
|
||||
#else
|
||||
m_thread_stop_condition.wait_for(lck, std::chrono::seconds(2), [this]{ return m_stop; });
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue