From 7fe017d2ef9d39dc11f78a5199aebfd7d2ebaceb Mon Sep 17 00:00:00 2001 From: Dima Buzdyk <46728448+buzzhuzz@users.noreply.github.com> Date: Fri, 29 Mar 2024 08:12:37 +0500 Subject: [PATCH] gui: fix media eject on linux (#4700) (#4701) * gui: fix media eject on linux (#4700) Removable media is not ejected on linux platform Make get_removable_drive_from_path() check if path is a dir or not. Trim last component in latter case only. * Revert unnecessary style changes --- src/slic3r/GUI/RemovableDriveManager.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index fcddcbd61e9..a26e13448da 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -370,12 +370,13 @@ std::string RemovableDriveManager::get_removable_drive_path(const std::string &p std::string RemovableDriveManager::get_removable_drive_from_path(const std::string& path) { - std::size_t found = path.find_last_of("/"); - std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path; - // trim the filename - found = new_path.find_last_of("/"); - new_path = new_path.substr(0, found); - + std::string new_path(path); + if (!boost::filesystem::is_directory(path)) { + std::size_t found = path.find_last_of("/"); + if (found != std::string::npos) + new_path.erase(found); + } + // check if same filesystem std::scoped_lock lock(m_drives_mutex); for (const DriveData &drive_data : m_current_drives)