Skip to content

Transform your 3D texturing workflow with the power of generative AI, directly within Blender!

restore the run timestamp when a file saved during a masked edit loads

sakalondf463f9b99f63
diff --git a/stablegen/core/load_handlers.py b/stablegen/core/load_handlers.py
index c27d393..7e4c7b7 100644
--- a/stablegen/core/load_handlers.py
+++ b/stablegen/core/load_handlers.py
@@ -15,11 +15,13 @@ from .architectures import QWEN_ARCHITECTURES
@persistent
-def load_handler(dummy, file_loaded=True):
+def load_handler(dummy, _second=None, file_loaded=True):
"""Set default ControlNet/LoRA units and sync checkpoint cache on file load.
Server checks reuse it with file_loaded=False: a generation may be
- running then, so its status must not be reset.
+ running then, so its status must not be reset. Blender 5.1 calls load_post
+ handlers with two positional arguments (the file path and None), which
+ must not land in *file_loaded*.
"""
from ..ui.model_units import get_lora_models
from . import state as _state
@@ -30,6 +32,15 @@ def load_handler(dummy, file_loaded=True):
scene = bpy.context.scene
+ # A file saved while a Masked Edit ran kept the edit's own output folder as
+ # the run timestamp; Reproject and Regenerate then looked for the run there.
+ # No edit survives a load, so put the run back.
+ if file_loaded:
+ for each in bpy.data.scenes:
+ if '_sg_mask_run_timestamp' in each:
+ each.output_timestamp = each['_sg_mask_run_timestamp']
+ del each['_sg_mask_run_timestamp']
+
# Builds saved while Qwen-Image 2.1 shared the Qwen-Image-Edit enum need a
# one-time architecture migration. The filename is used only here for
# compatibility; new generations dispatch exclusively by architecture.
diff --git a/stablegen/texturing/masked_edit.py b/stablegen/texturing/masked_edit.py
index d9b11fa..fe014aa 100644
--- a/stablegen/texturing/masked_edit.py
+++ b/stablegen/texturing/masked_edit.py
@@ -1084,6 +1084,8 @@ class SG_OT_MaskedEdit(bpy.types.Operator):
self.saved_active = context.view_layer.objects.active
self.saved_selected = list(context.selected_objects)
self.saved_timestamp = self.scene.output_timestamp
+ # Kept in the scene too: a file saved during the edit restores it on load.
+ self.scene['_sg_mask_run_timestamp'] = self.saved_timestamp
self.saved_engine = self.scene.render.engine
self.scene['_sg_mask_original_engine'] = self.saved_engine
self.scene.output_timestamp = datetime.now().strftime('%Y-%m-%dT%H-%M-%S') + '-masked-' + uuid.uuid4().hex[:6]
@@ -1163,6 +1165,8 @@ class SG_OT_MaskedEdit(bpy.types.Operator):
self.timer = None
self.scene.camera = self.saved_camera
self.scene.output_timestamp = self.saved_timestamp
+ if '_sg_mask_run_timestamp' in self.scene:
+ del self.scene['_sg_mask_run_timestamp']
if not any(o.sg_mask_original for o in self.scene.objects):
self.scene.render.engine = self.saved_engine
for obj in context.view_layer.objects: