Skip to content

Commit 57001ce

Browse files
committed
Fix wrong style selected when loading a document while not connected
* instead of falling back to a default style, keep the one from the document * if the server doesn't have the document's checkpoint this will produce an error when trying to generate which is ok
1 parent 5d6e2a8 commit 57001ce

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

ai_diffusion/model.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,6 @@ def set_workspace(self, workspace: Workspace):
816816

817817
def set_style(self, style: Style):
818818
if style is not self._style:
819-
if client := self._connection.client_if_connected:
820-
styles = filter_supported_styles(Styles.list().filtered(), client)
821-
if style not in styles:
822-
return
823819
if self._style_connection:
824820
QObject.disconnect(self._style_connection)
825821
self._style = style

ai_diffusion/ui/widget.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,14 @@ def update_styles(self):
338338
return
339339
client = root.connection.client_if_connected
340340
self._styles = filter_supported_styles(Styles.list().filtered(), client)
341+
if self._value not in self._styles:
342+
self._styles.insert(0, self._value)
341343
with SignalBlocker(self._combo):
342344
self._combo.clear()
343345
for style in self._styles:
344346
icon = theme.checkpoint_icon(resolve_arch(style, client))
345347
self._combo.addItem(icon, style.name, style.filename)
346-
if self._value in self._styles:
347-
self._combo.setCurrentText(self._value.name)
348-
elif len(self._styles) > 0:
349-
self._value = self._styles[0]
350-
self._combo.setCurrentIndex(0)
348+
self._combo.setCurrentText(self._value.name)
351349

352350
def change_style(self):
353351
style = self._styles[self._combo.currentIndex()]
@@ -372,7 +370,10 @@ def value(self):
372370
def value(self, style: Style):
373371
if style != self._value:
374372
self._value = style
375-
self._combo.setCurrentText(style.name)
373+
if style not in self._styles:
374+
self.update_styles()
375+
else:
376+
self._combo.setCurrentText(style.name)
376377

377378

378379
class ResizeHandle(QWidget):

0 commit comments

Comments
 (0)