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.
I need to write a factory that produces projects, so that: p = projectManager.findProject(dir); // this is mine project // now something happens, so discard the project p2 = projectManager.findProject(dir); assert p != p2; I tried to use projectManager.clearNonProjectCache(), however that does not seem to really work.
Created attachment 54879 [details] Proposed functional behaviour change
Unless somebody objects, I'd like to integrate a change like this next week.
A few comments: -I do not think this is a semantically compatible change (IIRC the PM.clearNonProjectCache method is called on quite a few occasions, and any currently existing project that have simple name containing NonProject would be discarded). -the PM contains a cache of folders that are known not to contain a project - the clearNonProjectCache method (as name suggests) clears this cache. Using this method to clear the temporary projects seems to overload the meaning of this method.
BTW: why is ProjectState.notifyDeleted unusable in this case?
And some people say that reviews are not useful! notifyDeleted() it the call I've been looking for: Index: autoupdate/featureondemand/src/org/netbeans/modules/featureondemand/FeatureProjectFactory.java --- autoupdate/featureondemand/src/org/netbeans/modules/featureondemand/FeatureProjectFactory.java Base (1.1.2.6) +++ autoupdate/featureondemand/src/org/netbeans/modules/featureondemand/FeatureProjectFactory.java Locally Modified (Based On 1.1.2.6) @@ -98,7 +98,7 @@ break; } } - return new FeatureNonProject(projectDirectory, pt2m); + return new FeatureNonProject(projectDirectory, pt2m, state); } } } @@ -112,12 +112,14 @@ private final FileObject dir; private final FeatureInfo info; private final Lookup lookup; + private final ProjectState state; private boolean success = false; - public FeatureNonProject(FileObject dir, FeatureInfo info) { + public FeatureNonProject(FileObject dir, FeatureInfo info, ProjectState state) { this.dir = dir; this.info = info; this.lookup = Lookups.singleton(this); + this.state = state; } public FileObject getProjectDirectory() { @@ -134,7 +136,7 @@ OpenProjects.getDefault().close(new Project[] { this }); if (success) { try { - ProjectManager.getDefault().clearNonProjectCache(); + state.notifyDeleted(); Project p = ProjectManager.getDefault().findProject(getProjectDirectory()); if (p == this) { throw new IllegalStateException("New project shall be found! " + p);