Page MenuHome

Save dirty file before reloading with scripts
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Jun 3 2019, 3:58 PM.

Diff Detail

Repository
rB Blender

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Jun 3 2019, 6:30 PM

Silently saving the file is not ideal either.

If the file has modifications, then I think it would be fine to free all the dependency graphs and force a full refresh that way. Basically calling BKE_scene_free_depsgraph_hash for every scene in main.

The reason we need to reload files is if any scripts were supposed to run on startup. But if it's later on that should not be a problem.

  • reset depsgraphs instead of save+reload

That is a bit weird have different behavior based on save state.

Quite often you open a production file, but then realize drivers are disabled, you click "Allow Execution" and you wait for the entire file to load again. Unless (after this change) you somehow managed to mark file dirty and then allow execution.

If it's for the handlers, can we simply run BLI_CB_EVT_LOAD_POST after all dependency graphs were freed (and possibly re-evaluated) ?

I don't think running BLI_CB_EVT_LOAD_POST, when we the file was not actually loaded, is a good idea. It could cause problems in addons.

I think it's mainly for scripts that run on startup (marked "Register" in the text editor). And those might add some on load handler, but add-ons might have already run their handler and running it again might cause problems.

I wouldn't mind if we can improve the on load case as well. But I don't think we have time for that now.

This revision is now accepted and ready to land.Jun 4 2019, 1:04 PM
This revision was automatically updated to reflect the committed changes.