Bug 202384 - can not reload text file encoding prefs
Summary: can not reload text file encoding prefs
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Szymon Ptaszkiewicz CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
: 162818 (view as bug list)
Depends on:
Blocks: 334241 335591
  Show dependency tree
 
Reported: 2007-09-06 02:33 EDT by Vloa Jen CLA
Modified: 2011-01-27 11:49 EST (History)
8 users (show)

See Also:
Szymon.Brandys: review+


Attachments
Patch v.0.1 (2.75 KB, patch)
2010-12-14 07:29 EST, Szymon Ptaszkiewicz CLA
no flags Details | Diff
Patch v.0.2 (5.95 KB, patch)
2010-12-14 09:50 EST, Szymon Ptaszkiewicz CLA
no flags Details | Diff
Patch v.0.3, minor changes added (6.13 KB, patch)
2010-12-14 10:15 EST, Szymon Ptaszkiewicz CLA
no flags Details | Diff
Patch v.0.4 (6.37 KB, patch)
2010-12-17 09:27 EST, Szymon Ptaszkiewicz CLA
no flags Details | Diff
Patch v.0.5 (8.19 KB, patch)
2010-12-20 09:36 EST, Szymon Ptaszkiewicz CLA
no flags Details | Diff
Patch v.0.6, rebased to HEAD (7.72 KB, patch)
2010-12-22 08:04 EST, Szymon Ptaszkiewicz CLA
no flags Details | Diff
Patch v.0.6 changed (7.32 KB, patch)
2010-12-22 10:59 EST, Szymon Brandys CLA
no flags Details | Diff
Patch v.0.7 (8.32 KB, patch)
2011-01-10 06:42 EST, Szymon Ptaszkiewicz CLA
Szymon.Brandys: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vloa Jen CLA 2007-09-06 02:33:54 EDT
steps:
1. change the project "text file encoding"  to Other->UTF-8
2. close the project, then close eclipse
3. open eclipse, then open the project
4. the "text file encoding" setting reset to "Inherited from container (MS950)
Comment 1 Walter Harley CLA 2007-09-06 14:50:43 EDT
Bug was categorized as JDT/APT - I don't think it has anything to do with either.  I'll attempt to recategorize it.
Comment 2 Krzysztof Michalski CLA 2007-09-10 06:52:50 EDT
I can't reproduce it on Build id: I20070809-1105. Could you check if it still occurs on the newest version?
Comment 3 Vloa Jen CLA 2007-09-12 08:43:00 EDT
yes, i tried , it works fine.
And i was thinking about why it happened at that time...
finally i got the point:
if we have viewed the "text file encoding" property 
before opening the project (as step 3.),
after opened the project,
the encoding will reset to "Inherited from container (MS950)"
Comment 4 Szymon Brandys CLA 2007-09-17 07:59:58 EDT
I can reproduce the issue indeed. I'm changing the priority since the team has other issues to address. A patch would be accepted.
Comment 5 Szymon Ptaszkiewicz CLA 2010-12-14 07:29:02 EST
Created attachment 185125 [details]
Patch v.0.1

The problem is that ProjectPreferences are initialized only upon creation so changing open-close state of project cannot change already initialized preferences. What we should do is to initialize project preferences each time the project is opened. The attached patch solves the problem. There is still an issue with line delimiter but the preference for line delimiter is handled directly from UI so it needs a separate bug.

Szymon B., do you think we could fix this in 3.7 M5?
Comment 6 Szymon Ptaszkiewicz CLA 2010-12-14 09:50:09 EST
Created attachment 185134 [details]
Patch v.0.2

Patch that fixes problems with encoding and with line delimiter.
Comment 7 Szymon Ptaszkiewicz CLA 2010-12-14 10:15:46 EST
Created attachment 185139 [details]
Patch v.0.3, minor changes added
Comment 8 Szymon Ptaszkiewicz CLA 2010-12-17 09:27:30 EST
Created attachment 185424 [details]
Patch v.0.4
Comment 9 Szymon Ptaszkiewicz CLA 2010-12-20 09:36:58 EST
Created attachment 185543 [details]
Patch v.0.5
Comment 10 Szymon Brandys CLA 2010-12-21 20:38:25 EST
Szymon, could you sync the patch to HEAD?
Comment 11 Szymon Ptaszkiewicz CLA 2010-12-22 08:04:21 EST
Created attachment 185703 [details]
Patch v.0.6, rebased to HEAD
Comment 12 Szymon Brandys CLA 2010-12-22 10:59:35 EST
Created attachment 185720 [details]
Patch v.0.6 changed

If there are two (or more) threads accessing project prefs, each may create a ProjectPreferences instance and only one of these will be added to the preferences tree. I think there is a chance that a wrong instance will be initialized during project opening. 

My patch seems to be safer.
Comment 13 Szymon Brandys CLA 2010-12-22 11:01:07 EST
Dj, could you look at the 'patch v.0.6 (rebased to HEAD)' and 'patch v.0.6 changed' and comment.
Comment 14 Szymon Ptaszkiewicz CLA 2010-12-22 11:11:18 EST
I opened separate bug 333101 for UI part.
Comment 15 Szymon Brandys CLA 2010-12-22 12:17:26 EST
I found one more issue with ProjectPreferences. 

If a project is closed and LineDelimiterEditor tries to get preferences (it creates nodes during  look up), ProjectPreferences#load is called and silently returns, because the pref file is not accessible. Right after that ProjectPreferences#loaded is called and it adds core.runtime.prefs to the list of loaded nodes, what is wrong.

Of course the fix for bug 333101 hides the problem, however there may be other places where people create nodes on look up. #loaded should not add anything to loadedNodes if #load fails.
Comment 16 Szymon Ptaszkiewicz CLA 2011-01-10 06:42:36 EST
Created attachment 186377 [details]
Patch v.0.7

Added changes from comment 15.
Comment 17 Szymon Ptaszkiewicz CLA 2011-01-10 06:43:46 EST
*** Bug 162818 has been marked as a duplicate of this bug. ***
Comment 18 Szymon Brandys CLA 2011-01-11 05:36:24 EST
The fix is in HEAD. Thanks.
Comment 19 Dani Megert CLA 2011-01-14 05:14:42 EST
The bug is nicely fixed! There's one remaining issue though, see bug 334362.