fix: keep residual release controls aligned with live queue state
This commit is contained in:
1 parent
fdd07224aa
commit
42e8719026
4 files changed
+534
-9
No files matched your search
@@ -419,8 +419,9 @@ class MainWindow(QWidget):
|
||||
self.backup_restore_button.setEnabled(ready and bool(
|
||||
self._eligible_names(checked_only=bool(self.selected_records()))))
|
||||
self.release_library_button.setEnabled(not self.busy and bool(self.lmc_edit.text().strip()))
|
||||
self.queue_release_button.setVisible(self._queue_wait_library is not None)
|
||||
self.queue_release_button.setEnabled(self._queue_wait_library is not None and not self._closing)
|
||||
waiting_library = self._queued_release_library()
|
||||
self.queue_release_button.setVisible(waiting_library is not None)
|
||||
self.queue_release_button.setEnabled(waiting_library is not None and not self._closing)
|
||||
reasons = []
|
||||
for operation, widget in (('add', self.add_button), ('update', self.update_button), ('remove', self.remove_button)):
|
||||
reason = self._management_block_reason(operation)
|
||||
@@ -492,8 +493,26 @@ class MainWindow(QWidget):
|
||||
self.output.append(f'未完成会话:{session.get("block") or ""} · '
|
||||
f'{phase} · {session.get("detail", "")}\n{session["path"]}')
|
||||
|
||||
def _queued_release_library(self):
|
||||
from cbb_refresh_verify.session_record import library_available
|
||||
if self._queue_wait_library is not None and library_available(self._queue_wait_library):
|
||||
self._queue_wait_library = None
|
||||
return self._queue_wait_library
|
||||
|
||||
def _queue_waiting(self, event):
|
||||
from cbb_refresh_verify.session_record import library_available
|
||||
library = event.get('library')
|
||||
if event.get('retained') and library and not library_available(library):
|
||||
self._queue_wait_library = library
|
||||
self._update()
|
||||
|
||||
def check_library_release(self, checked=False, *, queued=False):
|
||||
allowed_queue = queued and self._queue_wait_library is not None
|
||||
if self._closing:
|
||||
return
|
||||
allowed_queue = queued and self._queued_release_library() is not None
|
||||
if queued and not allowed_queue:
|
||||
self._update()
|
||||
return
|
||||
if (self.busy and not allowed_queue) or not self.lmc_edit.text().strip():
|
||||
return
|
||||
from shiboken6 import isValid
|
||||
@@ -819,7 +838,10 @@ class MainWindow(QWidget):
|
||||
def _queued_action(self, action):
|
||||
from cbb_refresh_verify.session_record import library_available, library_wait_reason
|
||||
library = getattr(self, 'mentor_lmc_path', None) or self.lmc_edit.text()
|
||||
return lambda: self.native_queue.run(action, stop=self.stop,
|
||||
def execute():
|
||||
self.signals.event.emit({'stage': 'native_slot_acquired', 'library': str(library)})
|
||||
return action()
|
||||
return lambda: self.native_queue.run(execute, stop=self.stop,
|
||||
ready=lambda: library_available(library),
|
||||
wait_state=lambda: library_wait_reason(library),
|
||||
waiting=lambda: self.signals.event.emit({'stage': 'waiting_native_slot',
|
||||
@@ -887,10 +909,8 @@ class MainWindow(QWidget):
|
||||
self.icdb_phase.setText(f'{name} · '+({'icdb_check_start': '正在检查',
|
||||
'icdb_startup_check': '正在打开工程'}.get(stage, detail)))
|
||||
if stage == 'waiting_native_slot':
|
||||
self._queue_wait_library = event.get('library') if event.get('retained') else None
|
||||
self._update()
|
||||
self._queue_waiting(event)
|
||||
elif stage == 'icdb_check_start':
|
||||
self._queue_wait_library = None
|
||||
self._update()
|
||||
if not self.busy: self.status_label.setText('后台 ICDB 检查:'+self.icdb_phase.text())
|
||||
if self.logging_context:
|
||||
@@ -927,6 +947,11 @@ class MainWindow(QWidget):
|
||||
|
||||
def _icdb_done(self, task):
|
||||
from cbb_refresh_verify.icdb_maintenance import maintenance_counts
|
||||
task_keys = _library_path_keys(task.requests[0].lmc_file, task.path_lease)
|
||||
if (task_keys & _library_path_keys(self._queue_wait_library, task.path_lease)
|
||||
and (not self.busy or not task_keys & _library_path_keys(
|
||||
self.mentor_lmc_path or self.loaded_path, self.library_lease))):
|
||||
self._queue_wait_library = None
|
||||
counts = maintenance_counts(task.results)
|
||||
lease = task.path_lease
|
||||
if lease is not None:
|
||||
@@ -1447,8 +1472,10 @@ class MainWindow(QWidget):
|
||||
if not isValid(self) or not isValid(self.cbb_table):
|
||||
return
|
||||
if event.get('stage') == 'waiting_native_slot':
|
||||
self._queue_wait_library = event.get('library') if event.get('retained') else None
|
||||
self.status_label.setText(event.get('detail', '已排队,等待执行'))
|
||||
self._queue_waiting(event)
|
||||
elif event.get('stage') == 'native_slot_acquired':
|
||||
self.status_label.setText('正在执行当前任务…')
|
||||
self._update()
|
||||
if event.get('stage') in ('session_handoff', 'save_stop_requested'):
|
||||
self.status_label.setText(event.get('detail', '当前状态无法确认'))
|
||||
@@ -1653,7 +1680,11 @@ class MainWindow(QWidget):
|
||||
if self.version_dialog is not None:
|
||||
self.version_dialog.reject()
|
||||
self.version_dialog = None
|
||||
self._queue_wait_library = None
|
||||
# Foreground completion must not erase an independent check's wait.
|
||||
if not (self._icdb_active() and not self.icdb_task.stop.is_set()
|
||||
and _library_path_keys(self._queue_wait_library, self.icdb_task.path_lease)
|
||||
& _library_path_keys(self.icdb_task.requests[0].lmc_file, self.icdb_task.path_lease)):
|
||||
self._queue_wait_library = None
|
||||
self.busy = False; self._update()
|
||||
|
||||
def open_logs(self):
|
||||
|
||||
Reference in new issue
Block a user