Bug 98009 - [GTK] WebKitDownload: use more of GOwnPtr/GRefPtr
Summary: [GTK] WebKitDownload: use more of GOwnPtr/GRefPtr
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-01 03:41 PDT by Claudio Saavedra
Modified: 2012-10-01 04:30 PDT (History)
1 user (show)

See Also:


Attachments
[GTK] WebKitDownload: use more of GOwnPtr/GRefPtr https://bugs.webkit.org/show_bug.cgi?id=98009 (4.76 KB, patch)
2012-10-01 03:44 PDT, Claudio Saavedra
cgarcia: review-
cgarcia: commit-queue-
Details | Formatted Diff | Diff
[GTK] WebKitDownload: use more of GOwnPtr/GRefPtr https://bugs.webkit.org/show_bug.cgi?id=98009 (4.78 KB, patch)
2012-10-01 03:59 PDT, Claudio Saavedra
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Claudio Saavedra 2012-10-01 03:41:42 PDT
There are plenty of uses of raw pointers here, so let's fix a few.
Comment 1 Claudio Saavedra 2012-10-01 03:44:58 PDT
Created attachment 166441 [details]
[GTK] WebKitDownload: use more of GOwnPtr/GRefPtr https://bugs.webkit.org/show_bug.cgi?id=98009

Reviewed by NOBODY (OOPS!).

        Use more GOwnPtr/GRefPtr in WebKitDownload

        * webkit/webkitdownload.cpp:
        (webkit_download_open_stream_for_uri): Use GRefPtr
        for a GFile and GOwnPtr for GError.
        (webkit_download_set_destination_uri): Ditto.
        (webkit_download_received_data): Use GOwnPtr for GError.
Comment 2 WebKit Review Bot 2012-10-01 03:48:15 PDT
Attachment 166441 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/gtk/ChangeLog', u'Source/Web..." exit_code: 1
Source/WebKit/gtk/webkit/webkitdownload.cpp:862:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Carlos Garcia Campos 2012-10-01 03:49:49 PDT
Comment on attachment 166441 [details]
[GTK] WebKitDownload: use more of GOwnPtr/GRefPtr https://bugs.webkit.org/show_bug.cgi?id=98009

View in context: https://bugs.webkit.org/attachment.cgi?id=166441&action=review

Thanks, GRefPtr increases the ref counter in the assign operator, so you need to adopt the ref to avoid it.

> Source/WebKit/gtk/webkit/webkitdownload.cpp:463
> +    GRefPtr<GFile> file = g_file_new_for_uri(uri);

You need to adopt the ref, use 

GRefPtr<GFile> file = adoptGRef(g_file_new_for_uri(uri));

> Source/WebKit/gtk/webkit/webkitdownload.cpp:698
> +        GRefPtr<GFile> src = g_file_new_for_uri(priv->destinationURI);
> +        GRefPtr<GFile> dest = g_file_new_for_uri(destination_uri);

These should be adopted too.

> Source/WebKit/gtk/webkit/webkitdownload.cpp:701
> +        g_file_move(src.get(), dest.get(), G_FILE_COPY_BACKUP, NULL, NULL, NULL, &error.outPtr());

Use 0 instead of NULL now that you are changing this line.
Comment 4 Claudio Saavedra 2012-10-01 03:59:46 PDT
Created attachment 166443 [details]
[GTK] WebKitDownload: use more of GOwnPtr/GRefPtr https://bugs.webkit.org/show_bug.cgi?id=98009

Reviewed by NOBODY (OOPS!).

        Use more GOwnPtr/GRefPtr in WebKitDownload

        * webkit/webkitdownload.cpp:
        (webkit_download_open_stream_for_uri): Use GRefPtr
        for a GFile and GOwnPtr for GError.
        (webkit_download_set_destination_uri): Ditto.
        (webkit_download_received_data): Use GOwnPtr for GError.
Comment 5 WebKit Review Bot 2012-10-01 04:03:46 PDT
Attachment 166443 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/gtk/ChangeLog', u'Source/Web..." exit_code: 1
Source/WebKit/gtk/webkit/webkitdownload.cpp:862:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Carlos Garcia Campos 2012-10-01 04:06:03 PDT
Comment on attachment 166443 [details]
[GTK] WebKitDownload: use more of GOwnPtr/GRefPtr https://bugs.webkit.org/show_bug.cgi?id=98009

Perfect!
Comment 7 WebKit Review Bot 2012-10-01 04:30:26 PDT
Comment on attachment 166443 [details]
[GTK] WebKitDownload: use more of GOwnPtr/GRefPtr https://bugs.webkit.org/show_bug.cgi?id=98009

Clearing flags on attachment: 166443

Committed r130036: <http://trac.webkit.org/changeset/130036>
Comment 8 WebKit Review Bot 2012-10-01 04:30:29 PDT
All reviewed patches have been landed.  Closing bug.