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 131825 - Project system doesn't notify code model about changed configuration
Summary: Project system doesn't notify code model about changed configuration
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Vladimir Kvashin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-02 13:37 UTC by Vladimir Voskresensky
Modified: 2008-04-09 08:03 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 Vladimir Voskresensky 2008-04-02 13:37:11 UTC
I have two toolchains Sun and Gnu 
create empty application and create two configurations ConfSun and ConfGnu: one use Sun and another Gnu toolchain.

Create empty file with something like:

#if definded (__GNUC__) || defined (__GNUG__)
int gnu;
#else
int nonGnu;
#endif

One block is active while another is in gray (that's OK).
then try to change active configuration => 
project is not reparsed, because no notification from project system about changed configuration.
The same if change configuration in combobox on toolbar
Comment 1 Thomas Preisler 2008-04-02 20:21:54 UTC
Bug confirmed.

Fix is simple and safe:

Macintosh-49[547] hg diff
diff -r 7caec8644340 cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java
--- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java	Wed Apr 02 10:51:35 2008 -0700
+++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java	Wed Apr 02 12:16:36 2008 -0700
@@ -353,6 +353,12 @@ final public class NativeProjectProvider
         if (oldConf == null) {
             // What else can we do?
             firePropertiesChanged(getMakeConfigurationDescriptor().getProjectItems(), true, true, true);
+            return;
+        }
+        
+        // Check compiler collection. Fire if different
+        if (!oldMConf.getCompilerSet().getName().equals(newMConf.getCompilerSet().getName())) {
+            fireFilesPropertiesChanged();
             return;
         }

Whether it is a P1 is difficult to say. I would be comfortable putting the change in because of the low risk but it is not a regression and the use case is not super common. 
Comment 2 Thomas Preisler 2008-04-02 20:25:51 UTC
It is now fixed and I will commit to trunk shortly. Please escalate if we want the fix in 6.1.
Comment 3 Thomas Preisler 2008-04-02 21:30:51 UTC
Fixed in trunk (main). Can QA pls verify?

Plsease nothe the test code should be
#if defined
and not
#if definded
Comment 4 soldatov 2008-04-03 08:40:55 UTC
verified in trunk. Bug is fixed.
But now when you switches project configuration, then IDE reparses project. I verified on Boost, IDE reparses project
quickly. But on very big project (OpenSolaris for example) it can be slow process.
Comment 5 soldatov 2008-04-03 09:50:04 UTC
I opened in IDE 2 projects (described project(small project) + boost project). I switched configuration in small project
==> IDE reparses boost
Comment 6 Alexander Pepin 2008-04-03 13:54:50 UTC
I think it's not good to re-parse all other open projects when a configuration is changed for one of them. It could
cause some performance issues.
Comment 7 Thomas Preisler 2008-04-03 19:58:13 UTC
Using a different API call that doesn't cause all project to be reparsed:

changeset 51f0361a0ea6 in main
details: http://hg.netbeans.org/main?cmd=changeset;node=51f0361a0ea6
description:
	131825 Project system doesn't notify code model about changed configuration

diffs (12 lines):

diff -r 12033798e5ea -r 51f0361a0ea6 cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java
--- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java	Thu Apr 03 09:40:10 2008 -0700
+++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/NativeProjectProvider.java	Thu Apr 03 11:33:19 2008 -0700
@@ -358,7 +358,7 @@ final public class NativeProjectProvider
         
         // Check compiler collection. Fire if different (IZ 131825)
         if (!oldMConf.getCompilerSet().getName().equals(newMConf.getCompilerSet().getName())) {
-            fireFilesPropertiesChanged();
+            firePropertiesChanged(getAllFiles(), true);
             return;
         }

Please retest...
Comment 8 soldatov 2008-04-04 14:47:22 UTC
verified in trunk (200804040003 build)
Comment 9 Thomas Preisler 2008-04-05 17:44:16 UTC
131825 is not completely fixed and I'm not sure we want to apply what we have in trunk today to 6.1. The remaining problems seems to be in the code model and in the interaction with some project 
system notifications.  After several days of discussion with code model team I will reassign bug to vkvashin. There are several option and most require changes in code model. 

Here is the situation as I see it:

1) Project system cannot use filesPropertiesChanged because it triggers reparsing of *all* files in *all* projects.

2) Project system cannot use filesPropertiesChanged(fileItems) because it semantically is not identical to the one above. Code model side doesn't filter out excluded files.

3) During investigation of this bug I found a serious performance bug in the way code model and project system interacts. When you change macros or includes from global Options/C/C++/Code 
Assistance dialog, the project system sends out a filesPropertiesChanged notification for each open native project to the code model which again loops over all open native projects before it reparses them. 
It means projects will get reparsed more than once. This is actually a separate bug but it intersects  with the solution of 131825.

Solution 2) is what is currently in trunk.

Here is a couple of suggestions to what we can do:

a) Nothing. Don't push to the partial fix for 131825 to release61. 131825 is still broken in 6.1 and problem in 3) is still present. Probably not a big deal.
b) Push current partial fix for 131825 to release61. It does fix 131825 except in some corner cases. Problem in 3) is still broken.
c) Code model filters out excluded files in their implementation of filesPropertiesChanged(fileItems) in addition to the partial fix already in trunk. 131825 is completely fixed. 3) is still broken.
d) Combine c) with removing code that loops over open projects in project system. It should also fix 3).
e) Change project system call back to filesPropertiesChanged and remove loop in code model. It should fix 131825 and 3) but I'm not sure it is doable on the code model side.

Anyway, it is up to vkvashin to decide....
Comment 10 Vladimir Kvashin 2008-04-06 20:40:00 UTC
I've committed (into main) a change that I believe solves remaining issues:
http://hg.netbeans.org/main/rev/d030a1498334
Please review the changes.

Comment 11 Thomas Preisler 2008-04-06 22:59:09 UTC
I tested the changes and they do fix the problem originally described in this IZ and they do also fix the problem with
the double looping. The change on the project side is correct. I'm not in the position to review the changes on the code
model side though. They  seems rather complicated and need a reviewer that is familiar with the code model code. 
Comment 12 Vladimir Voskresensky 2008-04-07 05:07:02 UTC
I reviewed the code model part and fix is correct.
Comment 13 soldatov 2008-04-07 14:37:31 UTC
verified bug in trunk again.
works for me.
Comment 15 soldatov 2008-04-09 08:03:48 UTC
verified in 200804082140 build (branch: release61)