Skip to content

Commit

Permalink
Also catch RuntimeError exceptions
Browse files Browse the repository at this point in the history
MaddyGuthridge committed Jun 23, 2024

Verified

This commit was signed with the committer’s verified signature.
arvindh123 Arvindh
1 parent ba3fadd commit f278a2e
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/common/activity_state.py
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ def _forcePlugUpdate(self) -> None:
self._plugin = plugin
try:
self._plugin_name = plugins.getPluginName(*plugin)
except TypeError:
except (TypeError, RuntimeError):
self._plugin_name = ""
if len(plugin) == 1:
self._generator = plugin
@@ -116,7 +116,7 @@ def tick(self) -> None:
try:
if self._plugin_name != plugins.getPluginName(*self._plugin):
self._do_update = True
except TypeError:
except (TypeError, RuntimeError):
pass
if self._do_update:
# Manually update plugin using selection
@@ -136,7 +136,7 @@ def tick(self) -> None:
self._plugin = plugin
try:
self._plugin_name = plugins.getPluginName(*plugin)
except TypeError:
except (TypeError, RuntimeError):
self._plugin_name = ""
# Ignore typing because len(plugin) doesn't narrow types in
# mypy
4 changes: 2 additions & 2 deletions src/common/states/main_state.py
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ def tick(self) -> None:
if isinstance(plug_idx, tuple):
try:
plug_id = plugins.getPluginName(*plug_idx)
except TypeError:
except (TypeError, RuntimeError):
# Plugin not valid
plug_id = ""
plug = common.ExtensionManager.plugins.get(
@@ -146,7 +146,7 @@ def processEvent(self, event: FlMidiMsg) -> None:
if isinstance(plug_idx, tuple):
try:
plug_id = plugins.getPluginName(*plug_idx)
except TypeError:
except (TypeError, RuntimeError):
# Plugin not valid
plug_id = ""
plug = common.ExtensionManager.plugins.get(
4 changes: 2 additions & 2 deletions src/common/util/api_fixes.py
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ def isPluginVst(index: PluginIndex) -> bool:
"""
try:
return plugins.getParamCount(*index) > PARAM_CC_START
except TypeError:
except (TypeError, RuntimeError):
return False


@@ -139,7 +139,7 @@ def catchUnsafeOperation(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except TypeError as e:
except (TypeError, RuntimeError) as e:
if e.args != ("Operation unsafe at current time",):
raise e
return wrapper
2 changes: 1 addition & 1 deletion src/plugs/mapping_strategies/note_strategy.py
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ def noteCallback(
) -> bool:
try:
i = channels.getChannelIndex(*getContext().activity.getGenerator())
except TypeError:
except (TypeError, RuntimeError):
# Index out of range - we're using a plugin from a different group
i = channels.channelNumber()
channels.midiNoteOn(
8 changes: 4 additions & 4 deletions src/plugs/special/activity_switcher.py
Original file line number Diff line number Diff line change
@@ -51,14 +51,14 @@ def getActivityColor(activity: SafeIndex) -> Color:
# Generator -> channel color
try:
return Color.fromInteger(channels.getChannelColor(*activity))
except TypeError:
except (TypeError, RuntimeError):
# Prevent issues if we deleted stuff
return Color.BLACK
else:
# Effect -> track color
try:
return Color.fromInteger(mixer.getTrackColor(activity[0]))
except TypeError:
except (TypeError, RuntimeError):
return Color.BLACK


@@ -78,7 +78,7 @@ def getActivityName(activity: SafeIndex) -> str:
if len(activity) == 1:
try:
return channels.getChannelName(*activity)
except TypeError:
except (TypeError, RuntimeError):
# Prevent issues if we deleted stuff
return ""
else:
@@ -88,7 +88,7 @@ def getActivityName(activity: SafeIndex) -> str:
f"{mixer.getTrackName(activity[0])}: " # type: ignore
f"{plugins.getPluginName(*activity, True)}"
)
except TypeError:
except (TypeError, RuntimeError):
# Prevent issues if we deleted stuff
return ""

2 changes: 1 addition & 1 deletion src/plugs/windows/channel_rack/omni.py
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ def drumPads(
idx = channels.getChannelIndex(
coordToIndex(control.getShadow())
)
except TypeError: # Index out of range
except (TypeError, RuntimeError): # Index out of range
return True
channels.midiNoteOn(
idx,

0 comments on commit f278a2e

Please sign in to comment.