Commit_operation bug
-
Ok, I have three types of observers:
Type 1 < AppObserver
Attached to Sketchup. It defines:
-onQuit, that asks the user to save certain structure of my plugin
-onNewModel, that does the same as onQuit plus hiding the plugin toolbar
-onOpenModel, that does the same as onNewModel
Type 2 < EntitiesObserver
This one is attached to Sketchup.active_model.entities at the beginning of the code. It defines:
-onElementModified, that checks if the modified entity is included in an internal list. In that case, shows a messagebox.
Type 3 < EntitiesObserver
This is attached to some special entities in my application. I have to save the transformations that the user performs on them. It defines:
-onElementModified, that saves the transformation and material of the modified entity
-onEraseEntities, that shows a messagebox
-onElementRemoved, that shows a messagebox
-
@adabyron said:
This one is attached to Sketchup.active_model.entities at the beginning of the code. It defines:
What if something is contained in a group/component?
@adabyron said:
-onElementModified, that saves the transformation and material of the modified entity
"Save" - saving a reference to the material object?
And all of these message boxes - all they do is display a message? Nothing that is done depending on how the user interacts with the messagebox?
-
@thomthom said:
What if something is contained in a group/component?
I don't understand what you mean. I have an internal list of entity IDs (they are groups), and if the modified entity ID is inside this list, I show a message box.
@thomthom said:
"Save" - saving a reference to the material object?
Yes, and the transformation one.
@thomthom said:
And all of these message boxes - all they do is display a message? Nothing that is done depending on how the user interacts with the messagebox?
Nothing. Just messages.
-
@adabyron said:
I don't understand what you mean. I have an internal list of entity IDs (they are groups), and if the modified entity ID is inside this list, I show a message box.
You monitor
model.entities
- but are you sure the entities you want to monitor is always in model.entities and not wrapped in some other group / component?
You don't have to monitor when the active context changes and hook your observer to model.active_entities? -
Yes, I'm sure. The entities I want to monitor are always added to Sketchup.active_model.entities.
-
@adabyron said:
Yes, I'm sure. The entities I want to monitor are always added to Sketchup.active_model.entities.
But if you attach your observer to the active context when a model is created/opened then you are attacking it to model.entities. But if the user creates a group or component where your entities are created - then your observer is not monitoring the correct entities collection.
For that you need to monitor when the active context changes and then add/remove your entities observer when it changes. -
I only want to monitor model.entities. If the user adds a group or component where new entities are created, then I don't care about them. It is the normal behavior of the plugin. It may sound absurd but makes sense in the context of the plugin functionality.
-
Manuela,
Add into your onQuit method, statements that detach your plugin's observers, then dispose of the observer instances by setting them to nil, and then call GC.start (Garbage Collection.)
See if that prevents the BugSplat!s when SU closes.
Advertisement