Quantum Debugging - bugs that only happen when you don't look.

I’m getting a weird issue where it seems as if an object isn’t being added to a dictionary, causing a problem where there’s a loss in content in my game. HOWEVER. If I put a debug log the exact line before it gets added, it does get added and my game functions as expected.

Anyone else run into this issue?

foreach(KeyValuePair<string, DialogueNode> entry in tempDictionary){
				if(entry.Value.GetType() == typeof(DialogueStatement)) Debug.Log("entry was : " + (entry.Value as DialogueStatement).statement);
				statements[entry.Key] = entry.Value;
			}

“statements” is a <string, DialogueNode> dictionary as well. The reason why I’m copying one dictionary to another like this? well, lets not get into that right now… but regardless - This works in the editor, either way, but if that debug.log line isn’t present, i’m getting an error consistently in the standalone build.

Maybe it’s because I didn’t sacrifice the goat before I built.

Maybe it gets removed after being added?

What error are you getting? A NullReferenceException? Index not found?

Is there a property getter that is changing the dictionary?

Does using curly braces in your if block change anything? I don’t know if that if statement is part of your debugging or supposed to affect if your value gets assigned to your key.

You’re not giving enough information. Putting that Debug line there causes statements[entry.Key] = entry.Value; to occur each iteration while otherwise when removed it will not. You’re not giving enough information to even guess here though.

Thanks for the suggestions guys.

lordofduct - I don’t think so. This is the very end of a function that basically build a “conversation” object. Once it’s been constructed, it shouldn’t matter. In fact, the dictionary I used to build the conversation is essentially garbage at this pointtttttttttttttttttttttttttttt allthough…

You know, I’m using the dictionary to manipulate a bunch of DialogueNode objects, which are added to my Conversation object but also stored to the dictionary as references. Could it be that somehow garbage collection is junking certain DialogueNodes when it clears up the dictionary???

Garth - No error – just one of the dialogue nodes magically doesn’t exist when the dialogue plays, so the game skips over where it would be. No property getters are screwing with it… truth be told, I’m not using them in this area of my code (i’m still a noob, really). And no, using Curly braces doesn’t change anything. the if statement is just part of my debugging.

On a side note, everything works, this way, so I’m fine… it’s just bloody interesting.

You know this isn’t a deep copy right?
If you do anything to the values in tempDictionary later, it will affect them in statements too.
May as well just write
statements = tempDictionary