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:
Arjen Hiemstra 2015-09-29 16:27:13 +02:00
parent 1bcc82a22a
commit de533b660e
2 changed files with 8 additions and 7 deletions

View file

@ -88,13 +88,10 @@ class WindowsRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
result = None
# Then, try and tell it to eject
try:
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:
if not windll.kernel32.DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, None, None, None, None, None, None):
result = False
else:
result = True
# Finally, close the handle
windll.kernel32.CloseHandle(handle)