I see a delay in getting view observer events in SU2019.
For some reason the observer doesn’t trigger immediately, but fires up after entering/leaving a group or component.
It looks like something is holding up all the onViewChanged() events and spilling them out afterwards.
Does anyone see similar thing? I set the view observer from C Ruby extension - I am calling Ruby function from there.
When I created a minimal sample in pure Ruby everything works fine, so I think it has to do with the call from C.
I have to spend more time on it to tell what is going on. Could it be related to linking with sketchup.lib? I have made a lot of changes in the code to migrate from C++ to C SDK, but I didn’t touch the observers in the process.
I also noticed that when I added a “minimal view observer” plugin, then my original function also started to receive the event immediately.
While chasing the issue, I found one thing that may be related.
I really do not understand why C API copies a behavior of Ruby function for getting an attribute dictionary. A “getter” should be just a function that gets something and does not create it when it is missing. It is especially dangerous in a case of live C API, that we are not supposed to use for modifying a live model.
Retrieves the attribute dictionary of an entity that has the given name.
If a dictionary with the given name does not exist, one is added to the entity.
If a developer is using it just to read the dictionary, as naturally expected, then it will be modifying the live model in many places, producing unnecessary dictionaries throughout a model.
There is SUEntityAddAttributeDictionary() so why adding this automatically??
Are there many things like this in C API?
It would have been better if the creator function created a dictionary if it did not exist, otherwise just returned it if it did, … rather than have a getter default to creation. (Ie, the getter often doubles as a query to see if a collection has a certain member.)