This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 120502 - Original Current Path is restored after changing
Summary: Original Current Path is restored after changing
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P1 blocker (vote)
Assignee: Thomas Preisler
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2007-10-30 16:56 UTC by Alexander Pepin
Modified: 2007-11-01 15:32 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pepin 2007-10-30 16:56:34 UTC
This is a regression in comparison with at least build 20071001. 
Preparation: Cygwin, MinGW and MSYS are installed. Cygwin is added to PATH
Steps to reproduce:
- run IDE
- open Tools->Options->C/C++
- add paths to MinGW/bin and MSYS/bin to the "Current PATH" list
- remove path to Cygwin/bin from the "Current PATH" list
- press OK
- open Tools->Options->C/C++
Result: "Current Path" list has an original view (has a path to Cygwin/bin and doesn't have paths to MinGW/bin and
MSYS/bin).
Comment 1 Thomas Preisler 2007-10-30 21:39:30 UTC
I think I found the root cause of the bug:

CppSettings is supposed to be singleton but

    public static CppSettings getDefault() {
	return (CppSettings) findObject(CppSettings.class, true);
    }

sometimes returns a new and reinitialized object. This may be a regression but I don't think it is caused by any changes
in CND though. Strange.

Fix is to change the code to

     public static CppSettings getDefault() {
	return (CppSettings) findObject(CppSettings.class, true);
        if (cppSettings == null) {
            cppSettings = (CppSettings) findObject(CppSettings.class, true);
     }
     return cppSettings;

which ensures there is only one singleton.
Patch:


# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: cnd/core/src/org/netbeans/modules/cnd/settings/CppSettings.java
--- cnd/core/src/org/netbeans/modules/cnd/settings/CppSettings.java Base (1.9)
+++ cnd/core/src/org/netbeans/modules/cnd/settings/CppSettings.java Locally Modified (Based On 1.9)
@@ -96,6 +96,7 @@
     
     private String path = null;
 
+    private static CppSettings cppSettings = null;
 
     /** Initialize each property */
     protected void initialize() {
@@ -107,8 +108,11 @@
     
     /** Return the signleton cppSettings */
     public static CppSettings getDefault() {
-	return (CppSettings) findObject(CppSettings.class, true);
+        if (cppSettings == null) {
+            cppSettings = (CppSettings) findObject(CppSettings.class, true);
     }
+        return cppSettings;
+    }
     
     /**
      * Return the local version of $PATH. This masquerades as a property but isn't!
Comment 2 Thomas Preisler 2007-10-30 22:56:23 UTC
Fixed.
Comment 3 Alexander Pepin 2007-11-01 15:32:38 UTC
verified in build 200710310000