Bug 261043
| Summary: | [GTK] Wrong free function in documentation for webkit_web_view_evaluate_javascript | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Rolf Gebhardt <buggy> |
| Component: | WebKitGTK | Assignee: | Michael Catanzaro <mcatanzaro> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | buggy, bugs-noreply, mcatanzaro |
| Priority: | P2 | Keywords: | Gtk |
| Version: | Other | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| URL: | https://webkitgtk.org/reference/webkit2gtk/stable/method.WebView.evaluate_javascript.html | ||
Rolf Gebhardt
The example in the documentation for webkit_web_view_evaluate_javascript at
https://webkitgtk.org/reference/webkit2gtk/stable/method.WebView.evaluate_javascript.html
is incorrect.
The statement "webkit_javascript_result_unref(js_result);" (see code fragment below) seems to be a holdover from the example for the deprecated Function webkit_web_view_run_javascript.
Therefore, it remains unclear how to correctly deal with the JSCValue "value" returned by the function webkit_web_view_evaluate_javascript_finish.
Code fragment from the documentation:
static void
web_view_javascript_finished (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
JSCValue *value;
GError *error = NULL;
value = webkit_web_view_evaluate_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error);
--- some lines of code removed ---
webkit_javascript_result_unref (js_result);
}
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Michael Catanzaro
Good catch, thanks!
(In reply to Rolf from comment #0)
> Therefore, it remains unclear how to correctly deal with the JSCValue
> "value" returned by the function webkit_web_view_evaluate_javascript_finish.
It's a GObject, so use g_object_unref().
Michael Catanzaro
Pull request: https://github.com/WebKit/WebKit/pull/17354
Rolf Gebhardt
(In reply to Michael Catanzaro from comment #1)
> Good catch, thanks!
>
> (In reply to Rolf from comment #0)
> > Therefore, it remains unclear how to correctly deal with the JSCValue
> > "value" returned by the function webkit_web_view_evaluate_javascript_finish.
>
> It's a GObject, so use g_object_unref().
Thanks a lot for the hint and for fixing.
I have another small point concerning the same function:
The documentation to the first parameter "script" says: "The value is a NUL terminated UTF-8 string."
The second parameter "length" tells us: "Length of script, or -1 if script is a nul-terminated string."
I understand what is meant. But perhaps the description of "script" should reflect the two possibilities to specify the end of the string.
(Not really important, just a suggestion)
Michael Catanzaro
Let's fix that too.
Michael Catanzaro
Actually that's not part of the docs itself, but from gi-docgen. We should have used unsigned char * for this API to indicate that it is a string of bytes that may or may not be nul-terminated, rather than char * which indicates a nul-terminated UTF-8 string. But we cannot fix the type until the next API version.
EWS
Committed 267583@main (ddb67f54d767): <https://commits.webkit.org/267583@main>
Reviewed commits have been landed. Closing PR #17354 and removing active labels.