Page MenuHome

Handler save_pre doesn't get called for session recovery save
Open, Confirmed, LowPublic


System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 980M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 389.12

Blender Version
Broken: version: 2.80 (sub 74), branch: master, commit date: 2019-07-11 13:50, hash: rB06312c6d2db8
Worked: (optional)

Short description of error
The Python handler save_pre does not get executed when Blender saves the session recovery file on exit. When add-on's are actively using this handler, they are very likely generating or finalizing data that will be saved along with the file. Skipping over this event while such add-ons are active is likely to cause data loss or strange bugs that will be difficult to track down.

Exact steps for others to reproduce the error
Write a simple script that prints something to the console when save_pre is called, then exit Blender with it active. You can launch Blender from a console window to keep the window open after it exits.

Event Timeline

Philipp Oeser (lichtwerk) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Nov 13 2019, 12:31 PM

Can confirm on first sight, not sure if these should be running in these situations, checking...

@Robert Moats (CodeRunner), what are you using this for? It may help is finding a solution.

This is similar to auto-save which also doesn't run the write callbacks.

It's not obvious that it should since there are actions you may only want to run when the user saves their own data (write other files to disk for e.g.) which you wouldn't want to run on auto-save or exit.

While we could have save_for_recovery, save_for_autosave _pre/post, I'd like to know the purpose of adding additional callbacks.

Setting this as a design task.

Campbell Barton (campbellbarton) lowered the priority of this task from Confirmed, Medium to Confirmed, Low.
Campbell Barton (campbellbarton) changed Type from Bug to Design.

I'm personally using the callback to move global property data from the add-on preferences group to scene data, so such data will be saved inside the *.blend file.

That aside, I can't imagine a lot of uses for save_pre that would not involve manipulating part of the scene for some purpose that is intended to be saved with it. I would think save_post would be better suited for other types of actions. However, if it is easy to add new callbacks for the specific purpose of manipulating scene data for a save, I can't think of any reason not to.

There appear to be only a couple built-in add-ons using save_pre (blenderkit and measureit), and they both seem to be using it to clean data. I haven't looked very closely at blenderkit, but measureit appears to be manipulating scene data in the handler. However, I'm not very familiar with it, so I'm not sure how critical it would be to skip over the code during the recovery file save. If it is only cleaning unused data, I'm assuming it would not be very noticeable - just accumulated garbage memory/scene-data.