Fix NullReferenceException in NUIGadgetManager#7653
Open
upple wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the robustness of the UIGadget components by implementing extensive try-catch blocks, improved null safety for application paths, and more detailed logging during initialization and resource loading. Feedback focuses on preventing a potential native resource leak in CreateUIGadgetInfo using a finally block, adopting safer casting for CoreApplication.Current, and removing several redundant null checks and exception handlers to streamline the implementation.
- Wrap UIGadgetInfo.CreateUIGadgetInfo with try/catch and log packageId on exception - Add try/catch in UIGadgetManager static constructor to prevent TypeInitializationException - Add try/catch in foreach loop to continue loading other packages on failure - Add try/catch in UIGadgetManager.Refresh() with packageId in error logs - Add try/catch in NUIGadgetManager static constructor, LoadGadgetInfos, and Refresh Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
- Use 'as' cast instead of direct cast for CoreApplication.Current with null check - Remove redundant outer try/catch in foreach loops (CreateUIGadgetInfo already handles exceptions internally) - Move PackageInfoDestroy to finally block for proper native handle cleanup - Remove redundant null check after 'new NUIGadgetInfo' operator Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
hjhun
reviewed
May 20, 2026
hjhun
reviewed
May 20, 2026
hjhun
reviewed
May 20, 2026
- Remove try/catch from CreateUIGadgetInfo (keep finally for native handle cleanup) - Let exceptions propagate to UIGadgetManager which handles them - Remove outer try/catch from static constructor - Add try/catch inside foreach loops in static constructor and Refresh() - Revert CoreApplication.Current as cast (not related to original issue) - Revert defensive try/catch in NUIGadgetManager (not related to original issue) Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
upple
commented
May 20, 2026
Member
|
🤖 [AI Review] Reviewed — no findings. Scope checked:
No 🔴 critical issues, no 🟡 suggestions to flag. Automated review — final merge decision rests with human reviewers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
API Changes