View Issue Details

IDProjectCategoryView StatusLast Update
0004861DarkRadiantGeneralpublic08.11.2020 18:36
ReporterSpooks Assigned Togreebo  
PrioritynormalSeveritynormalReproducibilityhave not tried
Status closedResolutionfixed 
Product Version2.0.3 
Target Version2.7.0Fixed in Version2.7.0 
Summary0004861: Undo/Redo Does Not Restore Light Color
DescriptionTitle. It is possible that this is also a problem with other entities that have the _color keyword. Have seen this happen in 2.0.5 too.
Steps To ReproduceChange a light's color using the Light Inspector, several times
Undo/Redo a bunch to see if the light color updates in the 3d viewport
Clicking on the light and going into Light Properties will show its color is not changed
TagsNo tags attached.

Activities

greebo

greebo

17.09.2018 12:53

administrator   ~0010760

This indeed happens in older versions as well, only checked the old 2.0.3 release and it's doing that too.
greebo

greebo

18.09.2018 05:51

administrator   ~0010761

It appears that this behaviour can only be observed when doing the colour change through the Light Inspector. It must be something related to the way the entity properties are set by the Inspector, which triggers this odd behaviour in the UndoSystem.
greebo

greebo

20.09.2018 09:00

administrator   ~0010763

Ok, got the problem narrowed down to this: when undoing an operation where entity key values are added/removed *and* keyvalues of the same entity are changed, the whole EntityKeyValues list is imported back into the Entity class.
In the Entity::importState() method, all the key values are removed and re-inserted from the snapshot, which is when they are disconnected and re-connected to the UndoSystem.
After the call to UndoSystem::getStateSaver(), the KeyValue ends up with a state saver pointing to a nullptr Stack, that's why the _color keyvalue can't save its state before it's importing the old value.
So when redoing the step, the previous _color information is lost as it hasn't been saved to the UndoSystem - because the keyvalue has been newly connected to the undosystem when the parent entity had been importing its own keyvalue pair list from the snapshot.

# Some chronological notes I made during debugging:

Undo: setLightProperties

# EntityKeyValues are imported from UndoSystem
Saving undoable's state of observed object 'EntityKeyValues'
Exporting state of observed object 'EntityKeyValues' # entity state is saved now
Importing state of observed object 'EntityKeyValues'
Importing state into entity light_1, got 10 key values

# Stack of _color keyvlue points to RedoStack
Disconnecting key value from undo system _color
[000000000EE67690] Disconnecting KeyValue with value '0.000 0.000 0.000' from undosystem
# _color Keyvalue is disconnected from undo systemConnecting new key value to undo system _color

[000000000EE67690] Connecting KeyValue with value '0.000 0.000 0.000' to undosystem
# _color keyvalue is connected, but its stack points to nullptr now, due to new getStateSaver() call

Saving undoable's state of observed object 'KeyValue'
# ObservedUndoable cannot save its state due to stack == nullptr, old value not saved to stackImporting state of observed object 'KeyValue'

[000000000EE67690] Importing value from undo system 1.000 0.000 0.000 (old value: 0.000 0.000 0.000)

# Redo will now import the entity key value list only, the old value of the _color key is lost.
greebo

greebo

20.09.2018 09:36

administrator   ~0010764

Fix committed in bf034c7.

Related Changesets

DarkRadiant: master f7ba7c3f

20.09.2018 08:06

greebo


Details Diff
Debug commit with regards to inspecting issue 0004861.
Committing the EntityKeyValues struct to the UndoStack right before sending a single key value might break the undo/redo functionality.
Affected Issues
0004861
mod - libs/ObservedUndoable.h Diff File
mod - plugins/entity/Doom3Entity.cpp Diff File
mod - plugins/entity/KeyValue.cpp Diff File
mod - radiant/ui/lightinspector/LightInspector.cpp Diff File
mod - radiant/undo/UndoSystem.cpp Diff File

DarkRadiant: master bf034c74

20.09.2018 11:33

greebo


Details Diff
Fix 0004861: If an Undoable object connects to the UndoSystem in the middle of an operation (stack != nullptr) then assign the stack to the UndoStackFiller on the fly. Affected Issues
0004861
mod - libs/ObservedUndoable.h Diff File
mod - plugins/entity/Doom3Entity.cpp Diff File
mod - plugins/entity/KeyValue.cpp Diff File
mod - radiant/undo/UndoSystem.cpp Diff File
mod - radiant/undo/UndoSystem.h Diff File

Issue History

Date Modified Username Field Change
10.07.2018 22:37 Spooks New Issue
12.07.2018 04:03 greebo Status new => acknowledged
17.09.2018 11:45 greebo Status acknowledged => confirmed
17.09.2018 12:53 greebo Note Added: 0010760
17.09.2018 12:53 greebo Product Version 2.6.0 => 2.0.3
18.09.2018 05:51 greebo Note Added: 0010761
20.09.2018 09:00 greebo Note Added: 0010763
20.09.2018 09:36 greebo Assigned To => greebo
20.09.2018 09:36 greebo Status confirmed => assigned
20.09.2018 09:36 greebo Target Version => 2.7.0
20.09.2018 09:36 greebo Note Added: 0010764
20.09.2018 09:36 greebo Status assigned => resolved
20.09.2018 09:36 greebo Fixed in Version => 2.7.0
20.09.2018 09:36 greebo Resolution open => fixed
20.09.2018 09:37 greebo Steps to Reproduce Updated
09.01.2020 19:25 greebo Changeset attached => DarkRadiant master bf034c74
09.01.2020 19:25 greebo Changeset attached => DarkRadiant master f7ba7c3f
08.11.2020 18:36 greebo Status resolved => closed