Trying to print info on a deleted node (SOLVED)



I’m having a bizarre bug that I don’t understand.

I only have one “gui.delete_node” in my whole script, and it’s here:

for k,v in ipairs(self.keyframes) do
		if k == self.uniquekeyframeidentifier then
			self.keyframes[k] = nil
			self.uniquekeyframeidentifier = nil

As i understand I delete the node and then the reference to the node in the table.

But later, when I try and print the table, I get an Deleted Node error message.

any help?



Okay this is definitely a bug.

I’ve added a line in “on_input” that says “pprint(self.keyframes)” and it works fine all the time

and if i run the code below

		self.keyframes[self.uniquekeyframeidentifier] = nil
		self.uniquekeyframeidentifier = nil
		for k,v in pairs(self.keyframes) do

that also works okay, no errors. But as soon as I move the mouse at all, and on_input is triggered, I get the error message saying that there’s a deleted node. I have no update and no other functions firing.

The project is very simple, just 274 lines of very simple code inside a GUI script called guiscript2.guiscript. And as I say, there’s only one gui.delete_node, so if anyone wants to have a look, it’s here:

auto (112.5 KB)



What am I supposed to do to get the problem in the attached example?



I believe that was all that was needed, right?



Ah! Sorry. The red diamonds that appear on the left of the screen represent keyframes on timelines. If you click on one of the ones in the middle then press backspace, you delete that node (and the reference to the node which is in the table). That’s when the problem starts. Thank you and sorry!



Ok, to help us debug I assigned an id to each of the keyframe nodes when they were created:

	gui.set_id(kfm, "kfm"..i)

Next I print the entire list of keyframes when I have selected one and at the moment when I press backspace. The list looks like this:

	DEBUG:SCRIPT: 1	box@(30, 30, 0)	hash: [kfm1]
	DEBUG:SCRIPT: 2	box@(40, 60, 0)	hash: [kfm2]
	DEBUG:SCRIPT: 3	box@(40, 60, 0)	hash: [kfm2]
	DEBUG:SCRIPT: 4	box@(30, 90, 0)	hash: [kfm3]
	DEBUG:SCRIPT: 5	box@(30, 120, 0)	hash: [kfm4]
	DEBUG:SCRIPT: 6	box@(30, 150, 0)	hash: [kfm5]
	DEBUG:SCRIPT: 7	box@(30, 180, 0)	hash: [kfm6]
	DEBUG:SCRIPT: 8	box@(30, 210, 0)	hash: [kfm7]
	DEBUG:SCRIPT: 9	box@(30, 240, 0)	hash: [kfm8]
	DEBUG:SCRIPT: 10	box@(30, 270, 0)	hash: [kfm9]
	DEBUG:SCRIPT: 11	box@(30, 300, 0)	hash: [kfm10]

And I’m trying to delete the entry at index 2. And the node at index 2 also exists at index 3! I’m guessing that you are manipulating the list when a keyframe node is selected and somehow insert the same node again?



okay, assigning IDs to the nodes is definitely the key here.

Thank you so much AGAIN britzl for your help with this problem.

1 Like