Good news or the bad news? ;-)
Let's start with the good..
I found a way around that crash by adding a call to ClearSelection() in the SelectGadget() method of the GadgetPropGrid. That makes sure that if there is a current "editor" open, it closes it and posts the change.
However... the bad news...
An OnPropertyGridChanged event is raised, obviously, as there has been data changed, which in turn calls SetFieldValue on the gadget you think is being edited. But we've clicked on a new gadget now, which isn't the same one. The crash now occurs in the reflection module... I guess because you are telling it to change a TField on the wrong Object... (maybe not, but that's where it bombs).
So... what now?
I think you might need to change your logic a little.
When you click on a different gadget, *before* you start processing it, you might want to ClearSelection() on the grid - which will force the update of fields etc.
*then* carry on as you did before, hiding categories and whatnot.
When there isn't an active editor there are no issues.
Let's start with the good..
I found a way around that crash by adding a call to ClearSelection() in the SelectGadget() method of the GadgetPropGrid. That makes sure that if there is a current "editor" open, it closes it and posts the change.
However... the bad news...
An OnPropertyGridChanged event is raised, obviously, as there has been data changed, which in turn calls SetFieldValue on the gadget you think is being edited. But we've clicked on a new gadget now, which isn't the same one. The crash now occurs in the reflection module... I guess because you are telling it to change a TField on the wrong Object... (maybe not, but that's where it bombs).
So... what now?
I think you might need to change your logic a little.
When you click on a different gadget, *before* you start processing it, you might want to ClearSelection() on the grid - which will force the update of fields etc.
*then* carry on as you did before, hiding categories and whatnot.
When there isn't an active editor there are no issues.