Browse Source

Fix access violation in node socket updates

As it turns out, enumerating a collection that can be modified is a bad
idea. Indeed, Blender expects that we won't do this. Sometimes, it
appears to work, however, other times, Blender is unable to handle it
and the internal data gets corrupted, causing a crash.
pull/94/head
Adam Johnson 7 years ago
parent
commit
e17ada3fca
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 10
      korman/nodes/node_core.py

10
korman/nodes/node_core.py

@ -170,7 +170,13 @@ class PlasmaNodeBase:
input_defs, output_defs = self._socket_defs
for defs, sockets in ((input_defs, self.inputs), (output_defs, self.outputs)):
done = set()
for i, socket in enumerate(sockets):
# Need to enumerate by hand because blendsucks has major (crashing) issues if we modify
# this swhizzle while stuff is going down.
i = 0
while i < len(sockets):
socket = sockets[i]
options = defs.get(socket.alias, None)
if options is None or socket.bl_idname != options["type"]:
sockets.remove(socket)
@ -227,6 +233,8 @@ class PlasmaNodeBase:
sockets.remove(empty_sockets.pop())
done.add(socket.alias)
i += 1
# Create any new sockets
for alias in (j for j in defs if j not in done):
options = defs[alias]

Loading…
Cancel
Save