Closed
Bug 519468
Opened 16 years ago
Closed 16 years ago
matchOS is read from default prefs at startup
Categories
(Toolkit :: Startup and Profile System, defect)
Toolkit
Startup and Profile System
Tracking
()
VERIFIED
FIXED
mozilla1.9.3a1
Tracking | Status | |
---|---|---|
status1.9.2 | --- | beta2-fixed |
People
(Reporter: vingtetun, Assigned: vingtetun)
References
Details
(Whiteboard: [fennec l10n][l10n])
Attachments
(1 file, 7 obsolete files)
11.51 KB,
patch
|
benjamin
:
review+
pavlov
:
approval1.9.2+
|
Details | Diff | Splinter Review |
yeah, that a dupe of 429033, but I'm not sure we want to correct the original bug instead of using a workaround for B4, so I'm duplicating the bug.
Furthermore, my workaround is dirty! :)
![]() |
||
Comment 1•16 years ago
|
||
This bug probably belongs wherever bug 429033 belongs.
From the chat in #developers, it's not really clear what this means in cooperation with fastload.
Assignee | ||
Comment 2•16 years ago
|
||
this one looks more like what it's actually done for the command line overriding of the locale.
Attachment #403502 -
Attachment is obsolete: true
Comment 3•16 years ago
|
||
Comment on attachment 403633 [details] [diff] [review]
WIP-2
>+ if (matchOS) {
>+ // compute lang and region code only when needed!
>+ nsCAutoString uiLocale;
>+ rv = getUILangCountry(uiLocale);
>+ if (NS_SUCCEEDED(rv))
>+ mSelectedLocale = uiLocale;
We should also remove any observer for SELECTED_LOCALE_PREF like we do above. But only if matchOS is true
>+ }
>+ else {
>+ nsXPIDLCString provider;
>+ rv = prefs->GetCharPref(SELECTED_LOCALE_PREF, getter_Copies(provider));
>+ if (NS_SUCCEEDED(rv))
>+ mSelectedLocale = provider;
And we probably need to add an observer for SELECTED_LOCALE_PREF here, just to mimic the behavior that happens in ::Init()
I think this patch has potential. Hopefully we won't need to flush any fastload caches.
Updated•16 years ago
|
Component: General → Startup and Profile System
Product: Fennec → Toolkit
QA Contact: general → startup
Assignee | ||
Comment 4•16 years ago
|
||
* Address comments
* Add a test to see if matchOS is different from the default one once the user prefs has been loaded
Attachment #403633 -
Attachment is obsolete: true
Comment 5•16 years ago
|
||
Comment on attachment 403762 [details] [diff] [review]
WIP-3
This patch is modeled on the way the UILocale commandline flag works.
This patch listens for "profile-after-change" to adjust the selected locale from the user prefs. It is actually fired sooner than the UILocale code. The UILocale code does not call FlushAllCaches. Since this patch fires before UILocale, it doesn't call FlushAllCaches either.
That might be an oversight for UILocale and therefore something we would need to do.
Attachment #403762 -
Flags: review?(benjamin)
Comment 6•16 years ago
|
||
Comment on attachment 403762 [details] [diff] [review]
WIP-3
That's a big hunk of code you've just duplicated. Please make a helper function to avoid the duplication.
Attachment #403762 -
Flags: review?(benjamin) → review-
Comment 7•16 years ago
|
||
But I don't actually understand why you need to do it this way... can't you just install a pref observer for matchos, the same way there's already a pref observer for the locale/skin prefs?
Assignee | ||
Comment 8•16 years ago
|
||
* Use an helper function
* Remove the "profile-after-change" observer to an observer on the matchOS pref
Attachment #403762 -
Attachment is obsolete: true
Assignee | ||
Comment 9•16 years ago
|
||
Attachment #407583 -
Attachment is obsolete: true
Assignee | ||
Updated•16 years ago
|
Attachment #407627 -
Flags: review?(benjamin)
Comment 10•16 years ago
|
||
Comment on attachment 407627 [details] [diff] [review]
WIP-5
I think you should register the SELECTED_LOCALE_PREF observer in nsChromeRegistry::Init in the same place you register the MATCH_OS and SELECTED_SKIN observers. Then in ::Observe, just call SelectLocalePref whenever matchOS or the selected locale changes.
And this needs an xpcshell test.
Attachment #407627 -
Flags: review?(benjamin) → review-
Assignee | ||
Comment 11•16 years ago
|
||
all the selected locale change and matchOS are handle through SelectLocalePref now.
There is no more any removeObserver/addObserver calls into it, which means we are going to enter and refresh mSelectedLocale every time the selected locale pref change, even if we are into a 'matchOS mode'.
Attachment #407627 -
Attachment is obsolete: true
Attachment #408757 -
Flags: review?
Assignee | ||
Updated•16 years ago
|
Attachment #408757 -
Flags: review? → review?(benjamin)
Assignee | ||
Updated•16 years ago
|
Attachment #408757 -
Flags: review?(benjamin)
Assignee | ||
Comment 12•16 years ago
|
||
Comment on attachment 408757 [details] [diff] [review]
Patch
canceling review because I suspect the patch to be wrong
Assignee | ||
Comment 13•16 years ago
|
||
Add the xpcshell test
Attachment #408757 -
Attachment is obsolete: true
Attachment #408869 -
Flags: review?
Assignee | ||
Comment 14•16 years ago
|
||
+ don' call FlushAllCache at startup
Assignee | ||
Updated•16 years ago
|
Attachment #408869 -
Flags: review? → review?(benjamin)
Updated•16 years ago
|
Attachment #408869 -
Flags: review?(benjamin) → review-
Comment 15•16 years ago
|
||
Comment on attachment 408869 [details] [diff] [review]
Patch v0.2 + xpcshell test
>diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp
>+nsresult
>+nsChromeRegistry::SelectLocalePref(nsIPrefBranch* prefs)
>+{
>+ nsresult rv;
>+ nsCOMPtr<nsIPrefBranch2> prefs2 (do_QueryInterface(prefs));
Remove prefs2, you're not using it any more.
>+ PRBool matchOSLocale = PR_FALSE;
>+ rv = prefs->GetBoolPref(MATCH_OS_LOCALE_PREF, &matchOSLocale);
>+
>+ if (NS_SUCCEEDED(rv) && matchOSLocale) {
>+ // compute lang and region code only when needed!
>+ nsCAutoString uiLocale;
>+ rv = getUILangCountry(uiLocale);
>+ if (NS_SUCCEEDED(rv))
>+ mSelectedLocale = uiLocale;
You never call FlushAllCaches in this block. mSelectedLocale will be correct but the chrome caches won't reflect it.
>+ else {
>+ nsXPIDLCString provider;
>+ rv = prefs->GetCharPref(SELECTED_LOCALE_PREF, getter_Copies(provider));
>+ if (NS_SUCCEEDED(rv)) {
>+ mSelectedLocale = provider;
>+
>+ if (!mInitialized)
>+ FlushAllCaches();
If *not* mInitialized? Shouldn't it be the other way, we flush caches if we *are* initialized? Isn't what you really mean "if the user changes the pref after the profile has been initialized". If that's what you mean, you should use a profile-initial-state observer and only call FlushAllCaches once that notification has been received.
Although I see now that we don't actually send any profile-initial-state notifications. We should do that here:
http://mxr.mozilla.org/mozilla-central/source/toolkit/xre/nsXREDirProvider.cpp#816
>diff --git a/chrome/test/unit/data/test_bug519468.manifest b/chrome/test/unit/data/test_bug519468.manifest
>+locale global en-US jar:en-US.jar!/locale/en-US/global/
>+locale global fr-FR jar:en-US.jar!/locale/en-US/global/
I think you'd be better off using a dummy packagename rather than "global", since there are various services in mozilla which use global locale stuff to initialize error messages and might get confused here.
Assignee | ||
Comment 16•16 years ago
|
||
(In reply to comment #15)
> (From update of attachment 408869 [details] [diff] [review])
> >diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp
>
> >+nsresult
> >+nsChromeRegistry::SelectLocalePref(nsIPrefBranch* prefs)
> >+{
> >+ nsresult rv;
> >+ nsCOMPtr<nsIPrefBranch2> prefs2 (do_QueryInterface(prefs));
>
> Remove prefs2, you're not using it any more.
Done.
>
> >+ PRBool matchOSLocale = PR_FALSE;
> >+ rv = prefs->GetBoolPref(MATCH_OS_LOCALE_PREF, &matchOSLocale);
> >+
> >+ if (NS_SUCCEEDED(rv) && matchOSLocale) {
> >+ // compute lang and region code only when needed!
> >+ nsCAutoString uiLocale;
> >+ rv = getUILangCountry(uiLocale);
> >+ if (NS_SUCCEEDED(rv))
> >+ mSelectedLocale = uiLocale;
>
> You never call FlushAllCaches in this block. mSelectedLocale will be correct
> but the chrome caches won't reflect it.
I've move the FlushAllCaches call in the observer method.
> >+ else {
> >+ nsXPIDLCString provider;
> >+ rv = prefs->GetCharPref(SELECTED_LOCALE_PREF, getter_Copies(provider));
> >+ if (NS_SUCCEEDED(rv)) {
> >+ mSelectedLocale = provider;
> >+
> >+ if (!mInitialized)
> >+ FlushAllCaches();
>
> If *not* mInitialized? Shouldn't it be the other way, we flush caches if we
> *are* initialized? Isn't what you really mean "if the user changes the pref
> after the profile has been initialized". If that's what you mean, you should
> use a profile-initial-state observer and only call FlushAllCaches once that
> notification has been received.
my bad, you're perfectly right.
> Although I see now that we don't actually send any profile-initial-state
> notifications. We should do that here:
> http://mxr.mozilla.org/mozilla-central/source/toolkit/xre/nsXREDirProvider.cpp#816
Done.
> >diff --git a/chrome/test/unit/data/test_bug519468.manifest b/chrome/test/unit/data/test_bug519468.manifest
>
> >+locale global en-US jar:en-US.jar!/locale/en-US/global/
> >+locale global fr-FR jar:en-US.jar!/locale/en-US/global/
>
> I think you'd be better off using a dummy packagename rather than "global",
> since there are various services in mozilla which use global locale stuff to
> initialize error messages and might get confused here.
I have replace 'global' by 'testmatchos'
Attachment #408869 -
Attachment is obsolete: true
Attachment #409643 -
Flags: review?
Assignee | ||
Updated•16 years ago
|
Attachment #409643 -
Flags: review? → review?(benjamin)
Updated•16 years ago
|
Attachment #409643 -
Flags: review?(benjamin) → review+
Updated•16 years ago
|
Comment 17•16 years ago
|
||
passed tests on try server
pushed:
http://hg.mozilla.org/mozilla-central/rev/4e4a74c88e7d
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Comment 18•16 years ago
|
||
Comment on attachment 409643 [details] [diff] [review]
Patch v0.3
Needed for Fennec beta 5
Attachment #409643 -
Flags: approval1.9.2?
Updated•16 years ago
|
Attachment #409643 -
Flags: approval1.9.2? → approval1.9.2+
Comment 19•16 years ago
|
||
status1.9.2:
--- → final-fixed
![]() |
||
Comment 20•16 years ago
|
||
I might be seeing a regression of this in my n810 fennec nightly. It insists on coming up in German, even though my OS locale is set to en-US. That's a
Moailla/5.0 (X11; U; Linux armv6l; de; rv:1.9.2b2pre) Gecko/20091103
about:buildconfig references http://hg.mozilla.org/releases/mozilla-1.9.2/rev/bae033362017.
![]() |
||
Comment 21•16 years ago
|
||
We definitely need this in our BFT's and Smoketests on litmus.
![]() |
||
Comment 22•16 years ago
|
||
Axel, works for me on francais and English (en-US), so verified FIXED with en-US:
Mozilla/5.0 (X11; U; Linux armv7l; Nokia N900; en-US; rv:1.9.2b2pre) Gecko/20091104 Firefox/3.6b2pre Fennec/1.0b5
and
Mozilla/5.0 (X11; U; Linux armv6l; Nokia N8xx; en-US; rv:1.9.3a1pre) Gecko/20091104 Firefox/3.7a1pre Fennec/1.0b5
If you see any new issues, go ahead an file a new bug.
Status: RESOLVED → VERIFIED
Flags: in-litmus?
Comment 23•16 years ago
|
||
This fails for me on a German system:
TEST-UNEXPECTED-FAIL | .../mozilla/_tests/xpcshell/test_chrome/unit/test_bug519468.js | en-US == de-DE
Updated•16 years ago
|
Assignee: nobody → 21
Flags: in-testsuite+
Target Milestone: --- → mozilla1.9.3a1
Comment 25•16 years ago
|
||
Filed bug 557024 about the test failure.
You need to log in
before you can comment on or make changes to this bug.
Description
•