Add support for marking custom functions as deprecated with visual warnings#8156
Conversation
|
Hello! Thanks for opening this PR. The extension editor UI is still a bit rough today (the extension editor has changed a lot lately and we still try to improve it). The "Private" checkbox should have been named "Hidden": when you check it, you will see that existing usages of the function appear in yellow. So I wonder if this would have fitted your need? More context: We try to make depreciation as transparent as possible for users. This means:
In your case, I guess you want to have the deprecation explanation shown to your users? |
Hi, I know about the "Hidden" checkbox, but it's intended for use within the extension itself, isn't it? |
| if (showDeprecatedInstructionWarning) { | ||
| hasDeprecationWarning = validationResult.hasDeprecationWarning(); | ||
| } | ||
| validationResult.delete(); |
There was a problem hiding this comment.
This will probably create a crash/memory corruption. Indeed, the JS/C++ bindings are using a [Value]:
[Value] ParameterValidationResult STATIC_ValidateParameter
This means (you can check that in glue.cpp, in the C function generated for interfacing) that the returned object is a static object in C++. There is always one living in memory, which is reused across calls. Which means:
- Multiple calls will refer to the same object (the second call "erases" the first one)
- If you delete it, you actually destroyed static memory which is basically undefined behavior I guess in C++/wasm. In short, it's a crash next time this memory is accessed.
This fix is simple: don't delete it :) This is sadly the hard to find/detect bugs with the C++/JS bindings (unclear lifetime of returned C++ objects).
There was a problem hiding this comment.
Yes, you are right, removed delete call for static object
| }; | ||
|
|
||
| gd::String MetadataDeclarationHelper::GetFreeFunctionSentence(const gd::EventsFunction &eventsFunction) { | ||
| // Note: [DEPRECATED] prefix is now added in the UI layer (Instruction.js) |
There was a problem hiding this comment.
Do you think this note is useful? This seems like a detail for the reader of the code, this could be removed I think.
4ian
left a comment
There was a problem hiding this comment.
Hi! I left a comment. My main other comment is that "[DEPRECATED]" is very "heavy" on the screen and I would rather have it as an additional preference (or we remove the existing preference and replace it by a preference which is an enum: "showDeprecatedOrHiddenWarning": "no" | "icon" | "icon-and-deprecated-warning-text").
Let me know if you can rework or introduce this preference :)
|
Hi @4ian, the idea sounds great! I've made appropriate changes, please take a look. |
767fcc1 to
81330bd
Compare
81330bd to
a0277ab
Compare
During cherry-pick conflict resolution, the parameter validation logic was incorrectly changed from validateParameter() to isParameterValid(), which caused a TypeError when editing instructions. The validateParameter() method returns a validation result object with getType(), isValid(), and hasDeprecationWarning() methods, while isParameterValid() returns only a boolean. This broke the deprecation warning feature introduced in PR 4ian#8156 and caused errors when adding actions/conditions with expression parameters. Changes: - Restored validateParameter() usage instead of isParameterValid() - Added back hasDeprecationWarning variable and its calculation - Re-added DeprecatedParameterValue import and parameter - Fixed renderInlineParameter call to include hasDeprecationWarning Co-authored-by: Cursor <cursoragent@cursor.com>












Summary
Changes
Core/GDCore:
SetDeprecationMessageandIsDeprecatedmethods toInstructionMetadata,ExpressionMetadata, andMultipleInstructionMetadataDeprecatedExpressionerror type toExpressionParserErrorInstructionValidatorwithValidateParameterthat returns both validity and deprecation status via newParameterValidationResultstructEventsFunctionmodel (isDeprecated,deprecationMessage)Events Sheet (UI):
[DEPRECATED]prefix for deprecated actions and conditionsshowDeprecatedInstructionWarningpreference flagExtension Editor: