-
Notifications
You must be signed in to change notification settings - Fork 133
IEP-1110 NPE when trying to create new launch configuration #852
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -308,7 +308,9 @@ public void widgetSelected(SelectionEvent evt) { | |||||||||||||||||
|
|
||||||||||||||||||
| Optional<String> suitableTarget = Stream.of(targetsWithDfuSupport).filter(t -> { | ||||||||||||||||||
| try { | ||||||||||||||||||
| return t.contentEquals(launchBarManager.getActiveLaunchTarget().getId()); | ||||||||||||||||||
| if (launchBarManager.getActiveLaunchConfiguration() != null) { | ||||||||||||||||||
| return t.contentEquals(launchBarManager.getActiveLaunchTarget().getId()); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+311
to
+313
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The null check for - if (launchBarManager.getActiveLaunchConfiguration() != null) {
- return t.contentEquals(launchBarManager.getActiveLaunchTarget().getId());
- }
+ LaunchTarget activeLaunchTarget = launchBarManager.getActiveLaunchTarget();
+ if (activeLaunchTarget != null) {
+ return t.contentEquals(activeLaunchTarget.getId());
+ }Commitable suggestion
Suggested change
|
||||||||||||||||||
| } catch (CoreException e) { | ||||||||||||||||||
| Logger.log(e); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -490,7 +492,7 @@ protected void initializeCProject(IProject project, ILaunchConfigurationWorkingC | |||||||||||||||||
| config.setMappedResources(new IResource[] { project }); | ||||||||||||||||||
|
|
||||||||||||||||||
| ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project); | ||||||||||||||||||
| if (projDes != null) { | ||||||||||||||||||
| if (projDes != null && projDes.getActiveConfiguration() != null) { | ||||||||||||||||||
| String buildConfigID = projDes.getActiveConfiguration().getId(); | ||||||||||||||||||
| config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -803,8 +805,10 @@ private String newVariableExpression(OpenocdDynamicVariable dynamicVariable) { | |||||||||||||||||
| private String getLaunchTarget() { | ||||||||||||||||||
| String selectedTarget = StringUtil.EMPTY; | ||||||||||||||||||
| try { | ||||||||||||||||||
| selectedTarget = launchBarManager.getActiveLaunchTarget().getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, | ||||||||||||||||||
| StringUtil.EMPTY); | ||||||||||||||||||
| if (launchBarManager.getActiveLaunchConfiguration() != null) { | ||||||||||||||||||
| selectedTarget = launchBarManager.getActiveLaunchTarget() | ||||||||||||||||||
| .getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, StringUtil.EMPTY); | ||||||||||||||||||
sigmaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+808
to
+811
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the first comment, consider storing the result of - if (launchBarManager.getActiveLaunchConfiguration() != null) {
- selectedTarget = launchBarManager.getActiveLaunchTarget()
- .getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, StringUtil.EMPTY);
- }
+ LaunchTarget activeLaunchTarget = launchBarManager.getActiveLaunchTarget();
+ if (activeLaunchTarget != null) {
+ selectedTarget = activeLaunchTarget.getAttribute(IDFLaunchConstants.ATTR_IDF_TARGET, StringUtil.EMPTY);
+ }Commitable suggestion
Suggested change
|
||||||||||||||||||
| } catch (CoreException e) { | ||||||||||||||||||
| Logger.log(e); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
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.
The null check for
launchBarManager.getActiveLaunchConfiguration()is good for preventing Null Pointer Exceptions. However, it would be better to also check iflaunchBarManager.getActiveLaunchTarget()is not null before callinggetAttributeon it. This will further enhance the robustness of the code.Commitable suggestion