fix: save Modified attribute and SSE retry reset

- silo_origin.py: use Gui.Document.Modified instead of App.Document.Modified
  (re-applies fix from #13 that was lost in rebase)
- silo_origin.py: add traceback logging to saveDocument error handler
- silo_commands.py: reset SSE retry counter after connections lasting >30s
  so transient disconnects don't permanently kill the listener
This commit is contained in:
Zoe Forbes
2026-02-10 19:00:13 -06:00
parent 6c9789fdf3
commit ab801601c9
2 changed files with 16 additions and 4 deletions

View File

@@ -2350,23 +2350,30 @@ class SiloEventListener(QtCore.QThread):
# -- thread entry -------------------------------------------------------
def run(self):
import time
retries = 0
last_error = ""
while not self._stop_flag:
t0 = time.monotonic()
try:
self._listen()
# _listen returns normally only on clean EOF / stop
if self._stop_flag:
return
retries += 1
last_error = "connection closed"
except _SSEUnsupported:
self.connection_status.emit("unsupported", 0, "")
return
except Exception as exc:
retries += 1
last_error = str(exc) or "unknown error"
# Reset retries if the connection was up for a while
elapsed = time.monotonic() - t0
if elapsed > 30:
retries = 0
retries += 1
if retries > self._MAX_RETRIES:
self.connection_status.emit("gave_up", retries - 1, last_error)
return

View File

@@ -392,12 +392,17 @@ class SiloOrigin:
obj.SiloPartNumber, str(file_path), properties, comment=""
)
# Clear modified flag
doc.Modified = False
# Clear modified flag (Modified is on Gui.Document, not App.Document)
gui_doc = FreeCADGui.getDocument(doc.Name)
if gui_doc:
gui_doc.Modified = False
return True
except Exception as e:
import traceback
FreeCAD.Console.PrintError(f"Silo save failed: {e}\n")
FreeCAD.Console.PrintError(traceback.format_exc())
return False
def saveDocumentAs(self, doc, newIdentity: str) -> bool: