From f057077826b7499a54f7b21ef198a370446b53ad Mon Sep 17 00:00:00 2001 From: David Kocik <kocikdav@gmail.com> Date: Wed, 11 Dec 2019 17:02:12 +0100 Subject: [PATCH] eject button functionality --- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/RemovableDriveManager.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index fc25b4f29..8e450f497 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -273,7 +273,7 @@ bool GUI_App::on_init_inner() this->obj_manipul()->update_if_dirty(); - RemovableDriveManager::get_instance().update(wxGetLocalTime(), true); + //RemovableDriveManager::get_instance().update(wxGetLocalTime(), true); // Preset updating & Configwizard are done after the above initializations, diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 49bf59e11..dc8469d9a 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -96,14 +96,16 @@ void RemovableDriveManager::eject_drive(const std::string &path) return; } DWORD deviceControlRetVal(0); + DeviceIoControl(handle, FSCTL_LOCK_VOLUME, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr); + DeviceIoControl(handle, FSCTL_DISMOUNT_VOLUME, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr); BOOL error = DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr); - CloseHandle(handle); if (error == 0) { + CloseHandle(handle); std::cerr << "Ejecting " << mpath << " failed " << deviceControlRetVal << " " << GetLastError() << " \n"; return; } - + CloseHandle(handle); m_current_drives.erase(it); break; @@ -198,7 +200,7 @@ INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP DEVICE_NOTIFY_WINDOW_HANDLE // type of recipient handle ); break; - /* + case WM_DEVICECHANGE: { if(wParam == DBT_DEVICEREMOVECOMPLETE) @@ -207,7 +209,7 @@ INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP } } break; - */ + default: // Send all other messages on to the default windows handler. lRet = DefWindowProc(hWnd, message, wParam, lParam);