Fix T51877: Deleting a scene uses freed memory

At the moment libblock_remap_data_preprocess is using
FOREACH_SCENE_OBJECT to iterate over all the objects of the scene and
unlink them.

However we were storing a reference to the Base of the removed object.
Anyways, the loop is now sanitized so that this crash no longer happens.

Also now we have an unittest for this.
This commit is contained in:
Dalai Felinto
2017-06-30 18:59:29 +02:00
parent b43cdc91ce
commit 49a35033be
3 changed files with 45 additions and 5 deletions

View File

@@ -0,0 +1,39 @@
# ############################################################
# Importing - Same For All Render Layer Tests
# ############################################################
import unittest
import os
import sys
from render_layer_common import *
# ############################################################
# Testing
# ############################################################
class UnitTesting(RenderLayerTesting):
def test_scene_delete(self):
"""
See if a scene can be properly deleted
"""
import bpy
scene = bpy.context.scene
bpy.data.scenes.new('New')
bpy.data.scenes.remove(scene)
# ############################################################
# Main - Same For All Render Layer Tests
# ############################################################
if __name__ == '__main__':
import sys
extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
UnitTesting._extra_arguments = extra_arguments
unittest.main()