RESOLVED FIXED 261043
[GTK] Wrong free function in documentation for webkit_web_view_evaluate_javascript
https://bugs.webkit.org/show_bug.cgi?id=261043
Summary [GTK] Wrong free function in documentation for webkit_web_view_evaluate_javas...
Rolf Gebhardt
Reported 2023-09-01 12:02:57 PDT
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
Michael Catanzaro
Comment 1 2023-09-01 13:17:35 PDT
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
Comment 2 2023-09-01 13:19:36 PDT
Rolf Gebhardt
Comment 3 2023-09-01 14:33:49 PDT
(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
Comment 4 2023-09-02 06:34:47 PDT
Let's fix that too.
Michael Catanzaro
Comment 5 2023-09-02 06:38:45 PDT
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
Comment 6 2023-09-02 06:52:08 PDT
Committed 267583@main (ddb67f54d767): <https://commits.webkit.org/267583@main> Reviewed commits have been landed. Closing PR #17354 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.