Skip to content

Commit 6b1b31f

Browse files
committed
Fix document poller not running after opening an existing document #2469 #2474
* for a brief time after opening, the document is not yet part of Krita's documents list * change detection whether document is discarded to check first if it was valid at any point before
1 parent 4f9928c commit 6b1b31f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

ai_diffusion/document.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def __init__(self, krita_document: krita.Document, id: str | None):
133133
self._selection_bounds: Bounds | None = None
134134
self._current_time: int = 0
135135

136+
self._was_valid = False
136137
self._poller = QTimer()
137138
self._poller.setInterval(20)
138139
self._poller.timeout.connect(self._poll)
@@ -294,6 +295,7 @@ def is_active(self):
294295

295296
def _poll(self):
296297
if self.is_valid:
298+
self._was_valid = True
297299
selection = self._doc.selection()
298300
selection_bounds = _selection_bounds(selection) if selection else None
299301
if selection_bounds != self._selection_bounds:
@@ -304,7 +306,7 @@ def _poll(self):
304306
if current_time != self._current_time:
305307
self._current_time = current_time
306308
self.current_time_changed.emit()
307-
else:
309+
elif self._was_valid:
308310
self._poller.stop()
309311

310312
def __eq__(self, other):

0 commit comments

Comments
 (0)