[webkit-reviews] review denied: [Bug 39944] [GTK] GtkLauncher should support relative file paths : [Attachment 57449] Patch with style and memory leak fix

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jun 1 05:11:49 PDT 2010


Xan Lopez <xan.lopez at gmail.com> has denied Martin Robinson
<mrobinson at webkit.org>'s request for review:
Bug 39944: [GTK] GtkLauncher should support relative file paths
https://bugs.webkit.org/show_bug.cgi?id=39944

Attachment 57449: Patch with style and memory leak fix
https://bugs.webkit.org/attachment.cgi?id=57449&action=review

------- Additional Comments from Xan Lopez <xan.lopez at gmail.com>
>+static gchar* filenameToURL(const char* filename)
>+{
>+    GFile *gFile = g_file_new_for_path(filename);
>+    if (!g_file_query_exists(gFile, 0)) {
>+	  g_object_unref(gFile);
>+	  return 0;
>+    }
>+    g_object_unref(gFile);

Maybe use g_file_test if you only create the object to check that the path is
valid?

>+
>+    gchar *fullPath = realpath(filename, 0);
>+    if (!fullPath)
>+	  return 0;
>+
>+    gchar *fileURL = g_filename_to_uri(fullPath, 0, 0);
>+    free(fullPath);

GOwnPtr for fullPath.

>+
>+    return fileURL;
>+}
>+
> int
> main (int argc, char* argv[])
> {
>@@ -201,8 +221,15 @@ main (int argc, char* argv[])
>     main_window = create_window ();
>     gtk_container_add (GTK_CONTAINER (main_window), vbox);
> 
>-    gchar* uri = (gchar*) (argc > 1 ? argv[1] : "http://www.google.com/");
>-    webkit_web_view_load_uri (web_view, uri);
>+    gchar *uri = (gchar*) (argc > 1 ? argv[1] : "http://www.google.com/");
>+    gchar *fileURL = filenameToURL(uri);
>+
>+    if (fileURL) {
>+	  webkit_web_view_load_uri(web_view, fileURL);
>+	  g_free(fileURL);
>+    } else {
>+	  webkit_web_view_load_uri(web_view, uri);
>+    }

You can use GOwnPtr for fileURL, and have only one branch with fileURI ?
fileURI : uri

> 
>     gtk_widget_grab_focus (GTK_WIDGET (web_view));
>     gtk_widget_show_all (main_window);


More information about the webkit-reviews mailing list