New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when dragging a condition into an OR, NOT, AND condition #40
Comments
Some news on this bug ? Seems that a gd::Instruction contained inside list is invalid (causing i->GetType() failure). |
The bug happen when dragging an instruction from a list into a OR/AND/NOT condition from the same list: as removing the dragged condition implies that the list is changed, every instruction are changed and so the pointer to the list where the condition is dropped become invalid.. Maybe I should prevent any drag'n'drop to a subcondition list for now. |
Or return NULL instead of the list. |
Should we convert instructions lists to instruction's pointers lists ? (Is this easy to do ?) |
Well, instead of having list of instructions represented as Currently, as they are stored by value, any change in a list has the potential to invalidate all the list (for example if the list is reallocated) so we can't keep any pointer (or iterator) on an element of the list. But in GDevelop instructions can have subinstructions, so in fact we are not dealing with simple arrays/lists but with a tree of instructions. If you try to move an instruction into a list of a subinstructions, you potentially risk, when you add/remove instructions, to invalidate all the pointers. This is what is happening and triggering the bug: dragging instructions in the events editor triggers change in a the instruction list of this instruction. If you try to drop the instruction in a list that changed boooom everything explodes. Makes sense? A bit hard to get surely at first. Put it another way, here is the current problem: You have a list of instructions and each instructions have a list of (sub)instructions:
When you want to drag for example Instruction1 and Instruction3 after Subinstruction2, who do you proceed? Knowing that any add/remove operation on a list will (potentially) reallocate it and make all pointers/reference/iterator to it invalid. |
I think we can create a template class SPtrList and use it for the EventsList and the InstructionsList. The problem is the copy ctor : they are not the same. EventsList uses CloneRememberingOriginalEvent to copy the event and InstructionsList will probably use the copy ctor of each Instruction. |
See the branch bugfix/instructions-list in my fork. |
Taking a look at it. I think that EventsList can be kept as it is now! :) |
Good job! The code looks great, good use of As I said EventsList can be kept separately, no need to bother with it I think - if we want to refactor it later it won't be much difficult as you class is generic. Great job, it's better than anything I was dreaming of. 😄 |
I don't see why you want to rewrite the d'n'd method as it's not crashing anymore with a list of shared_ptr. |
Ah oO Cool cool! I thought it could still be crashing because even if the implementation of the lists changed, the semantic and usage of lists is still the same (so it could have lead to the same issues with using deleted instructions). So that just perfect, thanks a lot! I'm waiting for the PR 😄 |
(http://forum.compilgames.net/viewtopic.php?f=20&t=5111)
The bug seems to happen in gd::EventEditorSelection::EndDragInstruction : at the end, when GD is trying to show (in std::cout) the list events type moved.
If I remove that part, GD crash somewhere else...
The text was updated successfully, but these errors were encountered: