Skip to content

Commit

Permalink
Fixed crash on JLS file not found #264
Browse files Browse the repository at this point in the history
  • Loading branch information
mliberty1 committed May 10, 2024
1 parent e83dc96 commit b31c5b3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This file contains the list of changes made to pyjoulescope_ui.
* Added Flyout widget click & drag right to resize #267
* Deferred data directory creation #266
* Updated pyjls from 0.9.2 to 0.9.4 to fix unicode path handling.
* Fixed crash on JLS file not found #264


## 1.1.6
Expand Down
7 changes: 5 additions & 2 deletions joulescope_ui/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,13 +1056,14 @@ def register(self, obj, unique_id: str = None, parent=None):
For instances, a randomly generated value.
:type unique_id: str, optional
:param parent: The optional parent unique_id, topic, or object.
:return: False on failure, True on success.
"""
pubsub_attr = _pubsub_attr_name(obj)
if pubsub_attr in obj.__dict__ and len(obj.__dict__[pubsub_attr]):
self._log.info('Duplicate registration for %s', obj)
if parent is not None:
self._parent_add(obj, parent)
return
return False
if unique_id is None:
if isinstance(obj, type):
# Use the unqualified class name
Expand Down Expand Up @@ -1142,10 +1143,12 @@ def register(self, obj, unique_id: str = None, parent=None):
self._log.info('register(unique_id=%s) done %s', unique_id, 'ABORT' if register_abort else '')
if register_abort:
self.unregister(obj, delete=True)
raise RuntimeError(f'register(unique_id={unique_id}) aborted')
self._log.error(f'register(unique_id={unique_id}) aborted')
return False
else:
getattr(obj, pubsub_attr)['is_registered'] = True
self._registry_add(unique_id)
return True

def _parent_add(self, obj, parent=None):
if parent is None:
Expand Down
3 changes: 2 additions & 1 deletion joulescope_ui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def on_action_widget_open(self, value):
if obj is None:
_log.warning('Could not open %s', spec)
return
pubsub_singleton.register(obj, unique_id=unique_id, parent=self)
if not pubsub_singleton.register(obj, unique_id=unique_id, parent=self):
return None
unique_id = obj.unique_id
obj.setObjectName(unique_id)
obj.destroyed.connect(self._on_destroyed)
Expand Down
2 changes: 2 additions & 0 deletions joulescope_ui/widgets/waveform/waveform_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ def on_pubsub_register(self):
self._trace_widget.on_pubsub_register(self.pubsub)
source_filter = self._source_filter_set()
is_device = source_filter in [None, '', 'JsdrvStreamBuffer:001']
if not is_device and get_topic_name(source_filter) not in self.pubsub:
raise RuntimeError(f'Source not found {source_filter}')
if self.state is None:
self.state = copy.deepcopy(_STATE_DEFAULT)
if not is_device:
Expand Down

0 comments on commit b31c5b3

Please sign in to comment.