-
Notifications
You must be signed in to change notification settings - Fork 6
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
Prevent a Rhino crash when an old type is deserialised in the CreateCustomObject
component
#405
Conversation
CustomObject
CustomObject
CreateCustomObject
component
From the Sprint Closure call @IsakNaslundBh to have a go with the script creating the issue |
@IsakNaslundBh shall we have a look at this together, tomorrow morning, in order to close it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am overall happy with that PR except for the one change I requested.
It is important to note that this happens because OnGrasshopperUpdates
is called when the component is deleted, which is questionable. This is by our own design:
public class CreateCustomComponent : CallerComponent, IGH_VariableParameterComponent
{
/*******************************************/
/**** Properties ****/
/*******************************************/
public override Caller Caller { get; } = new CreateCustomCaller();
/*******************************************/
/**** Constructors ****/
/*******************************************/
public CreateCustomComponent() : base()
{
this.Params.ParameterChanged += OnGrasshopperUpdates;
}
So we might want to find an event more suitable than ParameterChanged
or a way to differentiate the case where the component is deleted.
I would recommend sticking to this fix for now but raising another issue to investigate further.
Grasshopper_Engine/Query/Type.cs
Outdated
if (param == null) | ||
return typeof(object); | ||
type = typeof(object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one needs to stay a return
as it doesn't belong to the same if-else chain as the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the code to @adecler s comments.
This solves the problem for me and stops the crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now
Issues addressed by this PR
Closes #396
Rhino crashes altogether if you open a script with a
CustomObjecy
component that serialised aType
that doesn't exist anymore in the BHoM.Test files
@IsakNaslundBh would you mind using the file that triggered the issue in the first place?
Changelog
Engine.Grasshopper.Query.Type(this IGH_Param param, Caller caller = null)
never returnsnull
.Additional comments
This is quite critical, since it is crashing the whole Rhino.