Closed Bug 238136 Opened 20 years ago Closed 20 years ago

[w95/w95a][nt 3.51] Bookmarks don't work

Categories

(SeaMonkey :: Bookmarks & History, defect)

x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.8alpha1

People

(Reporter: Biesinger, Assigned: neil)

References

Details

Attachments

(4 files, 3 obsolete files)

OS: Linux → Windows NT
Attached patch patch (obsolete) — Splinter Review
*** Bug 238055 has been marked as a duplicate of this bug. ***
Comment on attachment 144428 [details] [diff] [review]
patch

to clarify - I have tested the patch now :) it works on both win2k (importing
system favorites works), and nt 3.51 (bookmarks work)
Attachment #144428 - Attachment description: completely untested patch → patch
Attached patch diff -w version, FOR REVIEW ONLY (obsolete) — Splinter Review
this is probably easier to review
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.8alpha
Comment on attachment 144428 [details] [diff] [review]
patch

oops, this only compiles on windows
Attachment #144428 - Attachment is obsolete: true
Attachment #144428 - Flags: review?(p_ch) → review-
Attached patch patch v1.1Splinter Review
Attachment #144452 - Attachment is obsolete: true
In fact there is a logic error in nsBookmarksService.cpp - as you know system
favourites are imported lazily, and the code in ImportSystemBookmarks already
checks that the favourites folder exists (w95/w95a systems don't have IE3).
Unfortunately as we have seen the code in LoadBookmarks does not.
Summary: [nt 3.51] Bookmarks don't work → [w95/w95a][nt 3.51] Bookmarks don't work
Comment on attachment 144476 [details] [diff] [review]
patch v1.1

ok, this patch obviously doesn't work.
Attachment #144476 - Flags: review?(p_ch) → review-
Attached patch Possible patch (obsolete) — Splinter Review
I couldn't figure out a neat way to do line 5300... suggestions?
nice, the patch looks good

what's so special about line 5300?
Attachment #144661 - Flags: review?(varga)
Comment on attachment 144661 [details] [diff] [review]
Possible patch

r=varga
So, you basically changed the behaviour to not exit with an error when there's
no system bookmarks folder on windows.

by line 5300 Neil probably meant this:
+#ifdef XP_WIN
+    if (systemBookmarksFolder)
+#endif
     if (!addedStaticRoot)
     {
Attachment #144661 - Flags: review?(varga) → review+
-> patch author
Assignee: cbiesinger → neil.parkwaycc.co.uk
Status: ASSIGNED → NEW
Attachment #144661 - Flags: superreview?(alecf)
Attachment #144661 - Flags: superreview?(alecf) → superreview?(jag)
Comment on attachment 144661 [details] [diff] [review]
Possible patch

>Index: xpfe/components/bookmarks/src/nsBookmarksService.cpp
>===================================================================
>RCS file: /cvsroot/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp,v
>retrieving revision 1.313
>diff -p -u -r1.313 nsBookmarksService.cpp
>--- xpfe/components/bookmarks/src/nsBookmarksService.cpp	9 Mar 2004 19:33:48 -0000	1.313
>+++ xpfe/components/bookmarks/src/nsBookmarksService.cpp	24 Mar 2004 14:09:30 -0000
>@@ -5213,29 +5213,31 @@ nsBookmarksService::LoadBookmarks()
> #endif
> 
> #if defined(XP_WIN) || defined(XP_BEOS)
>-    nsCOMPtr<nsIRDFResource> systemFavoritesFolder;
>     nsCOMPtr<nsIFile> systemBookmarksFolder;
> 
> #if defined(XP_WIN)
>     rv = NS_GetSpecialDirectory(NS_WIN_FAVORITES_DIR, getter_AddRefs(systemBookmarksFolder));
>-    NS_ENSURE_SUCCESS(rv, rv);
> #elif defined(XP_BEOS)
>     rv = NS_GetSpecialDirectory(NS_BEOS_SETTINGS_DIR, getter_AddRefs(systemBookmarksFolder));
>-    NS_ENSURE_SUCCESS(rv, rv);
>-    rv = systemBookmarksFolder->AppendNative(NS_LITERAL_CSTRING("NetPositive"));
>-    NS_ENSURE_SUCCESS(rv, rv);
>+
>+    if (NS_SUCCEEDED(rv))
>+        rv = systemBookmarksFolder->AppendNative(NS_LITERAL_CSTRING("NetPositive"));
>    
>-    rv = systemBookmarksFolder->AppendNative(NS_LITERAL_CSTRING("Bookmarks"));
>-    NS_ENSURE_SUCCESS(rv, rv);
>+    if (NS_SUCCEEDED(rv))
>+        rv = systemBookmarksFolder->AppendNative(NS_LITERAL_CSTRING("Bookmarks"));
>
> #endif
> 
>     nsCOMPtr<nsIURI> bookmarksURI;
>     rv = NS_NewFileURI(getter_AddRefs(bookmarksURI), systemBookmarksFolder);

So by removing the above NS_ENSURE_SUCCESSes, at this point you might be
constructing a new file URI from an "empty" nsIFile. I'm not sure what happens
in that case. A quick glance suggests the .spec will be "file:///", pointing to
the root directory. Not sure that's what you want. I doubt
NS_GetSpecialDirectory would fail, but ... I'd suggest adding |if
(NS_SUCCEEDED(rv))| to the NS_NewFileURI line.

>@@ -5245,7 +5247,8 @@ nsBookmarksService::LoadBookmarks()
> #if defined(XP_MAC) || defined(XP_MACOSX)
>             parser.SetIEFavoritesRoot(nsCString(kURINC_IEFavoritesRoot));
> #elif defined(XP_WIN) || defined(XP_BEOS)
>-            parser.SetIEFavoritesRoot(bookmarksURICString);
>+            if (systemFolderResource)
>+                parser.SetIEFavoritesRoot(bookmarksURICString);

This had me puzzled for a while. I guess this code would be a bit more clear to
me if it read:

    if (!bookmarksURICString.Empty())
	parset.SetIEFavoritesRoot(bookmarksURICString);

Or you could add a #if defined(XP_MAC) || defined(XP_MACOSX) section a little
higher up with |nsCAutoString bookmarksURICString(kURINC_IEFavoritesRoot);| and
get rid of these #ifdefs.

>@@ -5292,6 +5295,9 @@ nsBookmarksService::LoadBookmarks()
> 
>     // Add the root that System bookmarks are imported into as real bookmarks. This is 
>     // only done once. 
>+#ifdef XP_WIN
>+    if (systemBookmarksFolder)
>+#endif
>     if (!addedStaticRoot)
>     {

And this could also check for !bookmarksURICString.Empty() and get rid of the
#ifdef.

>         nsCOMPtr<nsIRDFContainer> rootContainer(do_CreateInstance(kRDFContainerCID, &rv));
>@@ -5329,8 +5335,6 @@ nsBookmarksService::LoadBookmarks()
> 
>             nsCOMPtr<nsIRDFResource> systemFolderResource;
> #if defined(XP_WIN)
>-            rv = gRDF->GetResource(bookmarksURICString,
>-                                   getter_AddRefs(systemFolderResource));
> #elif defined(XP_MAC) || defined(XP_MACOSX)
>             rv = gRDF->GetResource(NS_LITERAL_CSTRING(kURINC_IEFavoritesRoot),
>                                    getter_AddRefs(systemFolderResource));

Hmm, did you mean to remove this? This will leave systemFolderResource a null
pointer for XP_WIN (it hides the one you added above), in which case I'm
guessing the RemoveElement call below this will fail. If this was supposed to
stay, now that bookmarksURICString == kURINC_IEFavoritesRoot for the XPMAC(OSX)
cases, you could get rid of the #ifdefs. Ah, which makes it pretty much be the
systemFolderResource code you moved higher up into that XP_WIN|BEOS only
section. Move that out and I guess you could get rid of that code here.

Ugh, so much code is really the same in this file, but pretends to be
different. We should really aim to get rid of more #ifdefs.
Heh... *blush* s/\.Empty/.IsEmpty/g
Comment on attachment 153277 [details] [diff] [review]
Patch based on my comments, not for review yet

>+            if (!bookmarksURICString.IsEmpty()) {
>+                parser.SetIEFavoritesRoot(bookmarksURICString);
>+                parser.ParserFoundIEFavoritesRoot(&foundIERoot);
>+            }

I'm just guessing that if I don't SetIEFavoritesRoot,
ParserFoundIEFavoritesRoot will just return false. Fair assumption? Or should
we always check?

>@@ -5328,21 +5336,13 @@
>         // only to add confusion. 
>         if (!useDynamicSystemBookmarks)
>         {
>+            // XXXjag could this reuse rootContainer?
>             nsCOMPtr<nsIRDFContainer> container(do_CreateInstance(kRDFContainerCID, &rv));

I don't think we actually need to create a new rdf container here, we could
just reuse the one created right above this, right?
OK, this simplifies things a bit, and fixes the issues that jag found.
I didn't want to "simplify" things not directly touched by my patch.
Attachment #144661 - Attachment is obsolete: true
Attachment #154974 - Flags: superreview?(jag)
Attachment #154974 - Flags: review?(varga)
Comment on attachment 154974 [details] [diff] [review]
Addressing some review comments

sr=jag
Attachment #154974 - Flags: superreview?(jag) → superreview+
Fix checked in, with Jan's r= over IRC.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Attachment #144661 - Flags: superreview?(jag)
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: