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 724357 - Convert all occurrences of "stat()" to GFileInfo in browser.c
Convert all occurrences of "stat()" to GFileInfo in browser.c
Status: RESOLVED FIXED
Product: easytag
Classification: Other
Component: general
master
Other All
: Normal normal
: 2.1
Assigned To: EasyTAG maintainer(s)
EasyTAG maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-02-14 12:34 UTC by Abhinav
Modified: 2014-02-14 14:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
This patch will change occurrences of stat from stdio to GFileInfo from GIO (3.99 KB, patch)
2014-02-14 12:37 UTC, Abhinav
needs-work Details | Review
Converted all occurrences of stat of stdio to GFileInfo of GIO. (3.88 KB, patch)
2014-02-14 14:36 UTC, Abhinav
committed Details | Review

Description Abhinav 2014-02-14 12:34:38 UTC
browser.c currently uses stat () from stdio at many occurrences. All usage of stat must be replaced by better GFileInfo from GIO.
Comment 1 Abhinav 2014-02-14 12:37:34 UTC
Created attachment 269116 [details] [review]
This patch will change occurrences of stat from stdio to GFileInfo from GIO
Comment 2 David King 2014-02-14 12:51:34 UTC
Review of attachment 269116 [details] [review]:

Looks good overall, just some style comments.

::: src/browser.c
@@ +2742,3 @@
+                                              G_FILE_QUERY_INFO_NONE, NULL, 
+                                              NULL);
+                if (!fileinfo)

You should leave a blank line before the if().

@@ +2745,2 @@
                 {
                     g_free(npath);

Unrelated to your patch, but as npath is freed in both the error and non-error case, you should move the free to after the GFile has been created, since it is no longer needed at that point.

@@ +2755,3 @@
                 {
+                    g_object_unref (fileinfo);
+                    g_object_unref (file);

You can unref the GFile immediately after creating the GFileInfo, which saves doing it here and then again below.

@@ +2979,3 @@
             }
+            if (fileinfo)
+                g_object_unref (fileinfo);

I think that it is better to move the unref up to after where you call g_file_query_info(). Then you can do something like:

if (fileinfo)
{
    if (g_file_info_get_type() == foo)
    {
        stuff;
    }

    g_object_unref (fileinfo);
}
Comment 3 Abhinav 2014-02-14 14:36:37 UTC
Created attachment 269125 [details] [review]
Converted all occurrences of stat of stdio to GFileInfo of GIO.

Did all the changes from above post.
Comment 4 David King 2014-02-14 14:53:08 UTC
Comment on attachment 269125 [details] [review]
Converted all occurrences of stat of stdio to GFileInfo of GIO.

Thanks. I pushed a slightly-modified version to master as 4381597a181c96b8786857825eb8f9b05bb48e50.