diff options
author | bubnikv <bubnikv@gmail.com> | 2020-03-09 13:47:20 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2020-03-09 13:47:20 +0300 |
commit | aac691c0e7aa19e697d00ac0e92bf4bdb8d121f5 (patch) | |
tree | b1bfed26cb63fbe0fe98d9313d978d33839d8898 /src/slic3r | |
parent | e83fb4582c1de8477fd10d8675e3b0a1e5ef9767 (diff) |
Forced SD card / USB drive eject now sends out the event immediately
on Windows as well as on Unix platforms including OSX.
Diffstat (limited to 'src/slic3r')
-rw-r--r-- | src/slic3r/GUI/RemovableDriveManager.cpp | 21 | ||||
-rw-r--r-- | src/slic3r/GUI/RemovableDriveManager.hpp | 6 |
2 files changed, 7 insertions, 20 deletions
diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 5054d061e..0c4c417b2 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -103,7 +103,10 @@ void RemovableDriveManager::eject_drive() return; } CloseHandle(handle); - m_drive_data_last_eject = *it_drive_data; + assert(m_callback_evt_handler); + if (m_callback_evt_handler) + wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::move(*it_drive_data))); + m_current_drives.erase(it_drive_data); } } @@ -476,19 +479,9 @@ void RemovableDriveManager::update() tbb::mutex::scoped_lock lock(m_drives_mutex); std::sort(current_drives.begin(), current_drives.end()); if (current_drives != m_current_drives) { -#ifdef WIN32 - if (! m_drive_data_last_eject.empty() && std::find(current_drives.begin(), current_drives.end(), m_drive_data_last_eject) == current_drives.end()) { - assert(m_callback_evt_handler); - if (m_callback_evt_handler) - wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::move(m_drive_data_last_eject))); - m_drive_data_last_eject.clear(); - } else -#endif // WIN32 - { - assert(m_callback_evt_handler); - if (m_callback_evt_handler) - wxPostEvent(m_callback_evt_handler, RemovableDrivesChangedEvent(EVT_REMOVABLE_DRIVES_CHANGED)); - } + assert(m_callback_evt_handler); + if (m_callback_evt_handler) + wxPostEvent(m_callback_evt_handler, RemovableDrivesChangedEvent(EVT_REMOVABLE_DRIVES_CHANGED)); } m_current_drives = std::move(current_drives); } diff --git a/src/slic3r/GUI/RemovableDriveManager.hpp b/src/slic3r/GUI/RemovableDriveManager.hpp index 7ada13e5a..8b661d19c 100644 --- a/src/slic3r/GUI/RemovableDriveManager.hpp +++ b/src/slic3r/GUI/RemovableDriveManager.hpp @@ -101,12 +101,6 @@ private: // m_current_drives is guarded by m_drives_mutex // sorted ascending by path std::vector<DriveData> m_current_drives; - // When user requested an eject, the drive to be forcefuly ejected is stored here, so the next update will - // recognize that the eject was finished with success and an eject event is sent out. - // guarded with m_drives_mutex -#ifdef WIN32 - DriveData m_drive_data_last_eject; -#endif // WIN32 mutable tbb::mutex m_drives_mutex; // Returns drive path (same as path in DriveData) if exists otherwise empty string. |