Skip to content

Commit 3a0cafe

Browse files
[cuegui] Fix dependency wizard progress dialog hanging at 100% for grouped jobs (AcademySoftwareFoundation#1995)
**Link the Issue(s) this Pull Request is related to.** - AcademySoftwareFoundation#1994 **Summarize your change.** [cuegui] Fix dependency wizard progress dialog hanging at 100% for grouped jobs The progress dialog would get stuck at 100% completion when creating dependencies on grouped jobs (show-shot, show-shot-username). Users had to restart CueGUI or double-cancel to dismiss the dialog. Changes: - Enhanced completion detection with fallback progress bar check - Added safety timer to prevent indefinite hanging - Improved thread safety with proper Qt main thread cleanup - Added robust error handling for edge cases The dialog now automatically closes upon completion regardless of job grouping configuration. Fixes issue where dependency creation completed successfully but the progress dialog remained visible and unresponsive.
1 parent 77f91dd commit 3a0cafe

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

cuegui/cuegui/ProgressDialog.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ def __init__(self, title, function, work, concurrent, cancelTitle,
6565
self.__count = 0
6666
self.__isCompleted = False
6767

68+
# Add a safety timer to prevent hanging dialogs
69+
self.__safetyTimer = QtCore.QTimer(self)
70+
self.__safetyTimer.timeout.connect(self.__checkCompletion)
71+
self.__safetyTimer.start(1000) # Check every second
72+
6873
self.__bar = QtWidgets.QProgressBar(self)
6974
self.__bar.setRange(0, len(self.__work))
7075
self.__bar.setValue(0)
@@ -96,6 +101,7 @@ def closeEvent(self, event):
96101
"""Handle dialog close attempts"""
97102
if self.__isCompleted:
98103
# Work is done, allow closing
104+
self.__safetyTimer.stop()
99105
event.accept()
100106
super(ProgressDialog, self).closeEvent(event)
101107
else:
@@ -134,6 +140,7 @@ def cancel(self):
134140
self.__workLock.unlock()
135141
# Mark as completed and close the dialog when user confirms cancellation
136142
self.__isCompleted = True
143+
self.__safetyTimer.stop()
137144
self.close()
138145

139146
def __doWork(self):
@@ -154,6 +161,8 @@ def __doWork(self):
154161
except Exception as e:
155162
logger.warning("Work unit returned exception:")
156163
list(map(logger.warning, cuegui.Utils.exceptionOutput(e)))
164+
# Even if work fails, we need to ensure proper count management
165+
# The __doneWork callback will still be called by the threadpool
157166

158167
def __doneWork(self, work, result):
159168
"""Called when a work unit is done, updates progress, exits if done
@@ -173,14 +182,32 @@ def __doneWork(self, work, result):
173182
if self.__work:
174183
self._submitWork()
175184
else:
176-
if self.__count == 0:
185+
# Check if all work is completed - both no work left AND count is 0
186+
# or if progress bar shows 100% completion
187+
if self.__count <= 0 or self.__bar.value() >= self.__bar.maximum():
177188
if self.__cancelConfirmation:
178189
self.__cancelConfirmation.close()
179190
self.__isCompleted = True
180-
self.close()
191+
# Use QTimer to ensure proper cleanup in the main thread
192+
QtCore.QTimer.singleShot(0, self.close)
181193
finally:
182194
self.__workLock.unlock()
183195

196+
def __checkCompletion(self):
197+
"""Safety check to ensure dialog completion detection works properly"""
198+
if self.__isCompleted:
199+
self.__safetyTimer.stop()
200+
return
201+
202+
# Check if we should be completed based on progress
203+
if (not self.__work and self.__count <= 0) or self.__bar.value() >= self.__bar.maximum():
204+
logger.debug("Safety timer detected completion - closing dialog")
205+
if self.__cancelConfirmation:
206+
self.__cancelConfirmation.close()
207+
self.__isCompleted = True
208+
self.__safetyTimer.stop()
209+
self.close()
210+
184211
def _submitWork(self):
185212
"""Submits a new unit of work to threadpool"""
186213
self.__count += 1

0 commit comments

Comments
 (0)