Skip to content

Commit

Permalink
fix some Windows crashes in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ahtn committed May 17, 2018
1 parent 7cbe594 commit ee9843d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
0.3.3 (unreleased)
0.3.4 (unreleased)
==================

* `keyplus-flasher` switch from pyside to PyQt5 for GUI. This means Windows
flasher will work with Python3.
0.3.3
==================

* `keyplus-flasher` switch from pyside to PyQt5 for GUI. This makes it possible
to run the Windows version with Python3 instead of Python2.7. It should
also make it easier to run on MacOS.
* `keyplus-flasher` fix some crashes on Windows

0.3.2
==================
Expand Down
2 changes: 1 addition & 1 deletion host-software/keyplus/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__='0.3.3pre'
__version__='0.3.3'
50 changes: 31 additions & 19 deletions host-software/keyplus_flasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
DEFAULT_FIRMWARE_FILE = ""
DEFAULT_DEVICE_ID = ''

class KeyplusFlasherError(Exception):
pass

def error_msg_box(msg, title="Error"):
errorBox = QMessageBox()
errorBox.setWindowTitle(title)
Expand Down Expand Up @@ -220,7 +223,7 @@ def setup_xusb_bootloader_label(self):
bootloader_info = xusbboot.get_boot_info(self.device)
except easyhid.HIDException as err:
# Incase opening the device fails
raise Exception ("Error Opening Device: {} | {}:{}"
raise KeyplusFlasherError ("Error Opening Device: {} | {}:{}"
.format(
self.device.path,
self.device.vendor_id,
Expand Down Expand Up @@ -248,7 +251,7 @@ def setup_kp_boot_32u4_label(self):
boot_dev = kp_boot_32u4.BootloaderDevice(self.device)
except easyhid.HIDException as err:
# Incase opening the device fails
raise Exception ("Error Opening Device: {} | {}:{}"
raise KeyplusFlasherError ("Error Opening Device: {} | {}:{}"
.format(
self.device.path,
self.device.vendor_id,
Expand All @@ -274,7 +277,7 @@ def setup_efm8_boot_label(self):
boot_dev = efm8boot.EFM8BootloaderHID(self.device)
except easyhid.HIDException as err:
# Incase opening the device fails
raise Exception ("Error Opening Device: {} | {}:{}"
raise KeyplusFlasherError ("Error Opening Device: {} | {}:{}"
.format(
self.device.path,
self.device.vendor_id,
Expand Down Expand Up @@ -337,7 +340,7 @@ def updateLabel(self):
self.setup_nrf24lu1p_label()
else:
self.device.close()
raise Exception("Unsupported USB device {}:{}".format(
raise KeyplusFlasherError("Unsupported USB device {}:{}".format(
self.device.vendor_id, self.device.product_id))
self.device.close()
self.updateStyle()
Expand Down Expand Up @@ -931,6 +934,17 @@ def abort_update(self, target_device):
def abort_update2(self):
self.deviceListWidget.updateList()

def update_device_list(self):
"""
Update the device list.
"""
for widget in self.deviceListWidget.deviceWidgets[:]: # Use [:] to copy list
try:
widget.updateLabel()
except (easyhid.HIDException, KeyplusFlasherError):
# If communication with a USB device fails, remove it from the list.
self.deviceListWidget.deviceWidgets.remove(widget)

def check_version(self, kb):
if not kb.firmware_info.has_at_least_version(keyplus.__version__):
version = kb.firmware_info.get_version_str()
Expand Down Expand Up @@ -1001,14 +1015,13 @@ def programDeviceHandler(self, device_path):
with kb:
kb.update_settings_section(settings_data, keep_rf=True)
kb.update_layout_section(layout_data)
kb.reset(reset_type=RESET_TYPE_SOFTWARE)
kb.disconnect()

for widget in self.deviceListWidget.deviceWidgets:
try:
widget.updateLabel()
kb.reset(reset_type=RESET_TYPE_SOFTWARE)
except easyhid.HIDException:
pass
pass # may fail if HID device re-enumerates differently
kb.disconnect()

self.update_device_list()

if warnings != []:
error_msg_box(
Expand Down Expand Up @@ -1067,17 +1080,15 @@ def programDeviceHandler(self, device_path):
return

with kb:
old_name = copy.copy(kb.name)
kb.update_settings_section(settings_data, keep_rf=False)
kb.update_layout_section(layout_data)
kb.reset(reset_type=RESET_TYPE_SOFTWARE)
kb.disconnect()

for widget in self.deviceListWidget.deviceWidgets:
try:
widget.updateLabel()
kb.reset(reset_type=RESET_TYPE_SOFTWARE)
except easyhid.HIDException:
pass
pass # may fail if HID device re-enumerates differently
kb.disconnect()

self.update_device_list()

if warnings != []:
error_msg_box(
Expand Down Expand Up @@ -1394,10 +1405,11 @@ def USBUpdate(self):
self.deviceListWidget.updateList()

def showAboutDialog(self):
QMessageBox.about(self, "About keyplus Loader",
QMessageBox.about(self, "About keyplus Loader.",
"""
The keyplus layout and firmware loader.
""")
keyplus version: """ + keyplus.__version__
)

def showHelpDialog(self):
QMessageBox.about(self, "keyplus Loader Help",
Expand Down
2 changes: 1 addition & 1 deletion src/core/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
#define KEYPLUS_VERSION_PATCH 3

// Only set this to 1 for release builds
#define KEYPLUS_VERSION_IS_STABLE 0
#define KEYPLUS_VERSION_IS_STABLE 1

0 comments on commit ee9843d

Please sign in to comment.