Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] NPE in Managed Build, was RE: Committed: [cdt-patch] Managed Build System - Enumerated option reference - Fix for PR 61596

Sean,

 

I’m emailing this rather than filing a bug with a patch because I’m not sure if this is already known and being worked on…

 

Has the fix for the situation Leo describes been fully addressed yet?

 

After the first time I modify my project configuration, if I go again to modify it, clicking the OK button gives me an NPE.  The NPE doesn’t bring the system down but OK does not work and the only way out of the dialog is via the Cancel button.  So basically, after the first time you modify your settings, you can never modify them again :-(

 

The NPE happens because when getEnumeratedId() is called on the option reference, it compares the ID to the name from the enum name map and they’re not equal, so it returns null.

 

/* (non-Javadoc)

       * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumeratedId(java.lang.String)

       */

      public String getEnumeratedId(String name) {

            if (name == null) return null;

            Set idSet = getEnumNameMap().keySet();

            Iterator iter = idSet.iterator();

            while (iter.hasNext()) {

                  String id = (String) iter.next();

                  String enumName = (String) getEnumNameMap().get(id);

                  if (name.equals(enumName)) {

                        return id;

                  }

            }

            return null;

      }

 

There are no null checks in BuildToolSettingsPage.performOk(), so the line highlighted in green below goes BLAMMO…

 

                  // Transfer value from preference store to options

                  switch (option.getValueType()) {

                        case IOption.BOOLEAN :

                              boolean boolVal = getPreferenceStore().getBoolean(option.getId());

                              ManagedBuildManager.setOption(configuration, option, boolVal);

                              break;

                        case IOption.ENUMERATED :

                              String enumVal = getPreferenceStore().getString(option.getId());

                              String enumId = option.getEnumeratedId(enumVal);

                              ManagedBuildManager.setOption(configuration, option,

                                          (enumId.length() > 0) ? enumId : enumVal);

                              break;

 

Basically, these calls originating from BuildToolSettingsPage.performOk() are redundant now… you already have the ID, so you don’t need to resolve it in any way.  Just call setOption and you’re done.

 

Stack trace for the NPE is below:

 

org.eclipse.core.launcher.Main at localhost:2122

            Thread [main] (Suspended (exception NullPointerException))

                        BuildToolSettingsPage.performOk() line: 436

                        BuildPropertyPage.performOk() line: 888

                        PropertyDialog(PreferenceDialog).okPressed() line: 741

                        PropertyDialog(PreferenceDialog).buttonPressed(int) line: 198

                        Dialog$2.widgetSelected(SelectionEvent) line: 505

                        TypedListener.handleEvent(Event) line: 89

                        EventTable.sendEvent(Event) line: 82

                        Button(Widget).sendEvent(Event) line: 796

                        Display.runDeferredEvents() line: 2725

                        Display.readAndDispatch() line: 2390

                        PropertyDialog(Window).runEventLoop(Shell) line: 668

                        PropertyDialog(Window).open() line: 648

                        PropertyDialogAction.run() line: 177

                        ProjectPropertyDialogAction.run() line: 69

                        ProjectPropertyDialogAction(Action).runWithEvent(Event) line: 881

                        ActionContributionItem.handleWidgetSelection(Event, boolean) line: 899

                        ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 850

                        ActionContributionItem$7.handleEvent(Event) line: 769

                        EventTable.sendEvent(Event) line: 82

                        MenuItem(Widget).sendEvent(Event) line: 796

                        Display.runDeferredEvents() line: 2725

                        Display.readAndDispatch() line: 2390

                        Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1353

                        Workbench.runUI() line: 1324

                        Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 243

                        PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 141

                        IDEApplication.run(Object) line: 90

                        PlatformActivator$1.run(Object) line: 298

                        EclipseStarter.run(Object) line: 249

                        EclipseStarter.run(String[], Runnable) line: 126

                        NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]

                        NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39

                        DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25

                        Method.invoke(Object, Object[]) line: 324

                        Main.basicRun(String[]) line: 269

                        Main.run(String[]) line: 722

                        Main.main(String[]) line: 706

            Thread [Framework Event Dispatcher] (Running)

            Thread [Start Level Event Dispatcher] (Running)

            Thread [Thread-0] (Running)

            Thread [Thread-1] (Running)

            Thread [CDT Indexer] (Running)

            Thread [Indexer TimeOut Thread] (Running)

            Thread [Worker-0] (Running)

            Thread [Time Out Thread] (Running)

            Thread [org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration$1] (Running)

 

 

 

___________________________________________

 

Chris Recoskie

Software Designer

IDE Frameworks Group

Texas Instruments, Toronto

 

 

-----Original Message-----
From: cdt-patch-admin@xxxxxxxxxxx [mailto:cdt-patch-admin@xxxxxxxxxxx] On Behalf Of Sean Evoy
Sent: Wednesday, May 12, 2004 10:34 AM
To: cdt-patch@xxxxxxxxxxx
Subject: Committed: [cdt-patch] Managed Build System - Enumerated option reference - Fix for PR 61596

 


Thanks for catching that, Leo.

Sean Evoy
Rational Software - IBM Software Group
Ottawa, Ontario, Canada


"Treggiari, Leo" <leo.treggiari@xxxxxxxxx>
Sent by: cdt-patch-admin@xxxxxxxxxxx

05/11/2004 04:06 PM

Please respond to
cdt-patch

To

<cdt-patch@xxxxxxxxxxx>

cc

 

Subject

RE: [cdt-patch] Managed Build System - Enumerated option reference - Fix for PR 61596

 

 

 




Hi Sean,
 
Yes, I saw your changes and they look good.  But I believe there is a scenario that the changes didn’t address.
 
1.        Create a new managed build project named Test.  In the example below, it is an “Executable (Cygwin)”.
2.        Open the project properties, select the C/C++ Build page and change the Debugging option to “Minimal (-g1)”.
3.        Save the changes and exit Eclipse.
 
The resulting .cdtbuild file is below.  Notice the optionReferences in the Configuration->toolReference that were modified in step 2 above.  These optionReferences are using the “name” rather than the “Id” of the enumerated value.  My patch addresses this.
 
Regards,
Leo
 
<?xml version="1.0" encoding="UTF-8"?>
<?fileVersion 2.0.0?>
 
<ManagedProjectBuildInfo>
<target id="Test.cdt.managedbuild.target.gnu.cygwin.exe.1178135125" name="Executable (Cygwin)" parent="cdt.managedbuild.target.gnu.cygwin.exe" isAbstract="false" artifactName="Test" isTest="false" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
<configuration id="cdt.managedbuild.config.gnu.cygwin.exe.debug.1244696685" name="Debug" parent="cdt.managedbuild.config.gnu.cygwin.exe.debug">
<toolReference id="cdt.managedbuild.tool.gnu.c.compiler" command="gcc" outputPrefix="" outputFlag="-o">
<optionReference id="gnu.c.compiler.option.optimization.level" defaultValue="None (-O0)"/>
<optionReference id="gnu.c.compiler.option.debugging.level" defaultValue="Minimal (-g1)"/>
</toolReference>
<toolReference id="cdt.managedbuild.tool.gnu.cpp.compiler" command="g++" outputPrefix="" outputFlag="-o">
<optionReference id="gnu.cpp.compiler.option.optimization.level" defaultValue="gnu.cpp.compiler.optimization.level.none"/>
<optionReference id="gnu.cpp.compiler.option.debugging.level" defaultValue="gnu.cpp.compiler.debugging.level.max"/>
</toolReference>
</configuration>
<configuration id="cdt.managedbuild.config.gnu.cygwin.exe.release.1100325044" name="Release" parent="cdt.managedbuild.config.gnu.cygwin.exe.release">
<toolReference id="cdt.managedbuild.tool.gnu.c.compiler" command="gcc" outputPrefix="" outputFlag="-o">
<optionReference id="gnu.c.compiler.option.optimization.level" defaultValue="gnu.c.optimization.level.most"/>
<optionReference id="gnu.c.compiler.option.debugging.level" defaultValue="gnu.c.debugging.level.none"/>
</toolReference>
<toolReference id="cdt.managedbuild.tool.gnu.cpp.compiler" command="g++" outputPrefix="" outputFlag="-o">
<optionReference id="gnu.cpp.compiler.option.optimization.level" defaultValue="gnu.cpp.compiler.optimization.level.most"/>
<optionReference id="gnu.cpp.compiler.option.debugging.level" defaultValue="gnu.cpp.compiler.debugging.level.none"/>
</toolReference>
</configuration>
</target>
</ManagedProjectBuildInfo>
 
-----Original Message-----
From:
cdt-patch-admin@xxxxxxxxxxx [mailto:cdt-patch-admin@xxxxxxxxxxx] On Behalf Of Sean Evoy
Sent:
Tuesday, May 11, 2004 1:14 PM
To:
cdt-patch@xxxxxxxxxxx
Subject:
Re: [cdt-patch] Managed Build System - Enumerated option reference - Fix for PR 61596

 

Leo,

I have submitted work to address the issue of storing the name of the enumerated option value in the project file instead of the ID. I switched over to using the ID and added some logic to the project conversion routine and project load/save to handle this. Could you check to make sure this is sufficient for you. If not, I can revisit the design and merge in your work.


Sean Evoy
Rational Software - IBM Software Group
Ottawa, Ontario, Canada

"Treggiari, Leo" <leo.treggiari@xxxxxxxxx>
Sent by: cdt-patch-admin@xxxxxxxxxxx

05/10/2004 11:42 PM

 

Please respond to
cdt-patch

 

To

<cdt-patch@xxxxxxxxxxx>

cc

 

Subject

[cdt-patch] Managed Build System - Enumerated option reference - Fix for PR 61596


 

 

 

 





Attached is the fix for PR 61596.

Regards,
Leo


Back to the top