Fix T82493: PyDoc generation throws exception on exit
Since add-ons now unregister on exit
(as of fa566157a5
)
clearing functions in `bpy.app.handlers` caused an error on exit.
Resolve by restoring handlers before exiting.
This commit is contained in:
@@ -2188,9 +2188,20 @@ def setup_blender():
|
|||||||
|
|
||||||
# Remove handlers since the functions get included
|
# Remove handlers since the functions get included
|
||||||
# in the doc-string and don't have meaningful names.
|
# in the doc-string and don't have meaningful names.
|
||||||
for ls in bpy.app.handlers:
|
lists_to_restore = []
|
||||||
if isinstance(ls, list):
|
for var in bpy.app.handlers:
|
||||||
ls.clear()
|
if isinstance(var, list):
|
||||||
|
lists_to_restore.append((var[:], var))
|
||||||
|
var.clear()
|
||||||
|
|
||||||
|
return {
|
||||||
|
"lists_to_restore": lists_to_restore,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def teardown_blender(setup_data):
|
||||||
|
for var_src, var_dst in setup_data["lists_to_restore"]:
|
||||||
|
var_dst[:] = var_src
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -2199,7 +2210,7 @@ def main():
|
|||||||
setup_monkey_patch()
|
setup_monkey_patch()
|
||||||
|
|
||||||
# Perform changes to Blender it's self.
|
# Perform changes to Blender it's self.
|
||||||
setup_blender()
|
setup_data = setup_blender()
|
||||||
|
|
||||||
# eventually, create the dirs
|
# eventually, create the dirs
|
||||||
for dir_path in [ARGS.output_dir, SPHINX_IN]:
|
for dir_path in [ARGS.output_dir, SPHINX_IN]:
|
||||||
@@ -2305,6 +2316,8 @@ def main():
|
|||||||
shutil.copy(os.path.join(SPHINX_OUT_PDF, "contents.pdf"),
|
shutil.copy(os.path.join(SPHINX_OUT_PDF, "contents.pdf"),
|
||||||
os.path.join(REFERENCE_PATH, BLENDER_PDF_FILENAME))
|
os.path.join(REFERENCE_PATH, BLENDER_PDF_FILENAME))
|
||||||
|
|
||||||
|
teardown_blender(setup_data)
|
||||||
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user