After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 444087 - Update ephy to use glib's g_get_user_special_dir()
Update ephy to use glib's g_get_user_special_dir()
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: General
git master
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Marco Pesenti Gritti
Depends on: 444121
Blocks:
 
 
Reported: 2007-06-04 20:19 UTC by Diego Escalante Urrelo (not reading bugmail)
Modified: 2007-07-10 22:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A new try. (1.50 KB, patch)
2007-06-05 20:15 UTC, Diego Escalante Urrelo (not reading bugmail)
needs-work Details | Review
Fixed the bug mentioned by chpe (1.72 KB, patch)
2007-07-05 01:18 UTC, Diego Escalante Urrelo (not reading bugmail)
needs-work Details | Review

Description Diego Escalante Urrelo (not reading bugmail) 2007-06-04 20:19:08 UTC
From IRC:

<dieguito> should we update Bastien's work on xdg user dirs to use glib's new g_get_user_special_dir() ?
 bgo #432651
<chpe> yes :) (#if GLIB_CHECK_VERSION (2, 11, 3) of course)
Comment 1 Diego Escalante Urrelo (not reading bugmail) 2007-06-04 21:16:16 UTC
Made this:
Index: lib/ephy-file-helpers.c
===================================================================
--- lib/ephy-file-helpers.c     (revision 7067)
+++ lib/ephy-file-helpers.c     (working copy)
@@ -224,12 +224,22 @@ ephy_file_downloads_dir_from_xdg (void)
 {
        const char *home_dir;
        char *downloads_dir;
+       const char *downloads_tmp;
+       g_print("saaa\n");
 
        /* We use getenv to exactly match the default output
         * from xdg_user_dir_lookup, otherwise we might have a
         * mismatch in the string comparison below */
        home_dir = getenv ("HOME");
+       #if GLIB_CHECK_VERSION (2, 11, 3)
+       g_print("glib dirs\n");
+       downloads_tmp = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+       downloads_dir = g_strdup (downloads_tmp);
+       #else
        downloads_dir = xdg_user_dir_lookup ("DOWNLOAD");
+       #endif
+
+       g_print("downloads_dir = %s\n", downloads_dir);
 
        /* No home directory, it will use /tmp then */
        if (home_dir == NULL)

But Ephy locks on g_get_user_special_dir. First I thought it was because of the const/char thing, so I added that g_strdup. No use, still locks.
Comment 2 Diego Escalante Urrelo (not reading bugmail) 2007-06-04 21:35:16 UTC
Depends on Bug #444121.
Comment 3 Diego Escalante Urrelo (not reading bugmail) 2007-06-05 20:15:01 UTC
Created attachment 89431 [details] [review]
A new try.

What about this one?.
I'm not so sure it's correctly done but at least now it doesn't crash :).

I'm g_strdup'ing the string returned by glib since according to docs it belongs to glib.
Also I changed the last if to:
if (downloads_dir && strcmp (downloads_dir, home_dir) == 0)

because otherwise it crashed, seems to me because it was freeing a NULL and if my limited C knowledge is not betraying me, that's not a good idea.
Comment 4 Christian Persch 2007-06-05 20:51:15 UTC
+#if GLIB_CHECK_VERSION (2, 11, 3)
+#else

#if !GLIB_...

+	downloads_tmp = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+	downloads_dir = g_strdup (downloads_tmp);

You can just directly strdup it, no need for the _tmp var.

+	if (downloads_dir && strcmp (downloads_dir, home_dir) == 0) {
 		g_free (downloads_dir);

I just saw a pre-existing bug  here (not introduced by your patch): xdg_user_dir_lookup returns a strdup'd string which you must free with free but not with g_free, while g_get_user_special_dir uses g_strdup which is compatible with g_free but not with free...
Comment 5 Diego Escalante Urrelo (not reading bugmail) 2007-07-05 01:18:34 UTC
Created attachment 91223 [details] [review]
Fixed the bug mentioned by chpe

Should this be enough?
Comment 6 Christian Persch 2007-07-05 11:24:47 UTC
I think the two |return user_dir;| statements in xdg_use_dir_lookup need the same treatment.

With that fixed, ok to commit, thanks!
Comment 7 Christian Persch 2007-07-10 18:48:30 UTC
Actually let's just remove xdg_user_dir_lookup completely and just use the glib thing.
Comment 8 Christian Persch 2007-07-10 22:15:52 UTC
Fixed in svn.