mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Catch any exception that happens while trying to eject
This should prevent crashes on eject on any platform. CURA-106 #done
This commit is contained in:
parent
1bcc82a22a
commit
de533b660e
2 changed files with 8 additions and 7 deletions
|
@ -37,7 +37,11 @@ class RemovableDrivePlugin(OutputDevicePlugin):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def ejectDevice(self, device):
|
def ejectDevice(self, device):
|
||||||
result = self.performEjectDevice(device)
|
try:
|
||||||
|
result = self.performEjectDevice(device)
|
||||||
|
except Exception as e:
|
||||||
|
result = False
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
message = Message(catalog.i18nc("@info:status", "Ejected {0}. You can now safely remove the drive.").format(device.getName()))
|
message = Message(catalog.i18nc("@info:status", "Ejected {0}. You can now safely remove the drive.").format(device.getName()))
|
||||||
message.show()
|
message.show()
|
||||||
|
|
|
@ -88,13 +88,10 @@ class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
# Then, try and tell it to eject
|
# Then, try and tell it to eject
|
||||||
try:
|
if not windll.kernel32.DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, None, None, None, None, None, None):
|
||||||
if not windll.kernel32.DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, None, None, None, None, None, None):
|
|
||||||
result = False
|
|
||||||
else:
|
|
||||||
result = True
|
|
||||||
except Exception as e:
|
|
||||||
result = False
|
result = False
|
||||||
|
else:
|
||||||
|
result = True
|
||||||
|
|
||||||
# Finally, close the handle
|
# Finally, close the handle
|
||||||
windll.kernel32.CloseHandle(handle)
|
windll.kernel32.CloseHandle(handle)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue