Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions cuegui/cuegui/plugins/StuckFramePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from qtpy import QtCore
from qtpy import QtWidgets

import opencue.exception
import opencue.wrappers.frame

import cuegui.AbstractDockWidget
Expand Down Expand Up @@ -159,8 +160,9 @@ class StuckFrameControls(QtWidgets.QWidget):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)

self.__current_show = opencue.api.findShow(os.getenv("SHOW", "pipe"))
self.__show_combo = ShowCombo(self.__current_show.data.name, self)
self.__current_show = self.__resolveInitialShow()
initial_show_name = self.__current_show.data.name if self.__current_show else ""
self.__show_combo = ShowCombo(initial_show_name, self)
self.__show_label = QtWidgets.QLabel("Show:", self)
self.__show_label.setToolTip("The show you want to find stuck frames for.")

Expand Down Expand Up @@ -280,6 +282,32 @@ def __init__(self, parent=None):
QtCore.SIGNAL("clicked()"),
self.hideButtonRequest)

@staticmethod
def __resolveInitialShow():
"""Returns a sensible default show to start with.

Uses the SHOW environment variable when it points to an existing show,
otherwise falls back to the first active show. Returns None when no
show can be resolved so the plugin still renders instead of failing to
load with a blank page."""
show_name = os.getenv("SHOW", "")
if show_name:
try:
return opencue.api.findShow(show_name)
except opencue.exception.CueException:
logger.warning(
"Configured SHOW '%s' was not found; falling back to an active show.",
show_name)
try:
shows = opencue.api.getActiveShows()
except opencue.exception.CueException:
shows = []
if shows:
shows.sort(key=lambda s: s.data.name)
return shows[0]
logger.warning("No active shows were found; the Stuck Frame show selector will be empty.")
return None

def addFilter(self):
"""Adds new filter."""
newFilter = StuckFrameBar(self)
Expand All @@ -288,7 +316,13 @@ def addFilter(self):

def showChanged(self, show):
"""Sets current show the one provided."""
self.__current_show = opencue.api.findShow(str(show))
show = str(show).strip()
if not show:
return
try:
self.__current_show = opencue.api.findShow(show)
except opencue.exception.CueException:
logger.warning("Unable to find show '%s'.", show)
Comment on lines +319 to +325

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Clear stale show state on invalid selection paths.

On Line 320 (empty input) and Line 324 (lookup failure), self.__current_show is left unchanged. That can keep querying a previously selected show even when the current selection is invalid/empty.

💡 Suggested fix
 def showChanged(self, show):
     """Sets current show the one provided."""
     show = str(show).strip()
     if not show:
+        self.__current_show = None
         return
     try:
         self.__current_show = opencue.api.findShow(show)
     except opencue.exception.CueException:
         logger.warning("Unable to find show '%s'.", show)
+        self.__current_show = None
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
show = str(show).strip()
if not show:
return
try:
self.__current_show = opencue.api.findShow(show)
except opencue.exception.CueException:
logger.warning("Unable to find show '%s'.", show)
show = str(show).strip()
if not show:
self.__current_show = None
return
try:
self.__current_show = opencue.api.findShow(show)
except opencue.exception.CueException:
logger.warning("Unable to find show '%s'.", show)
self.__current_show = None
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cuegui/cuegui/plugins/StuckFramePlugin.py` around lines 319 - 325, The
`self.__current_show` variable is not being cleared when the show input is empty
or when the show lookup fails, which allows the code to continue querying a
previously selected show. Add a statement to set `self.__current_show` to None
before the return statement when the show string is empty (after the `if not
show:` check), and also add a statement to set `self.__current_show` to None in
the except block when the opencue.exception.CueException is caught during the
opencue.api.findShow call. This ensures stale state is cleared whenever an
invalid selection path is encountered.


def getFilterBar(self):
"""Returns filter bar."""
Expand Down
Loading