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 754721 - Support g_autoptr() for all libsoup object types
Support g_autoptr() for all libsoup object types
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: API
2.51.x
Other Linux
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2015-09-08 10:42 UTC by Kalev Lember
Modified: 2015-09-15 14:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support g_autoptr() for all libsoup object types (3.51 KB, patch)
2015-09-08 10:43 UTC, Kalev Lember
none Details | Review
Support g_autoptr() for all libsoup object types (4.06 KB, patch)
2015-09-08 14:57 UTC, Kalev Lember
committed Details | Review
autocleanups: Fix free functions for non-GObject based types (1.95 KB, patch)
2015-09-10 11:29 UTC, Kalev Lember
committed Details | Review
autocleanups: Add a few more missing types (3.80 KB, patch)
2015-09-10 11:29 UTC, Kalev Lember
none Details | Review
autocleanups: Exclude the header from instrospection (904 bytes, patch)
2015-09-10 11:29 UTC, Kalev Lember
committed Details | Review
autocleanups: Add a few more missing types (3.42 KB, patch)
2015-09-14 17:48 UTC, Kalev Lember
none Details | Review
Require single includes for new headers (2.90 KB, patch)
2015-09-15 12:04 UTC, Kalev Lember
none Details | Review

Description Kalev Lember 2015-09-08 10:42:25 UTC
.
Comment 1 Kalev Lember 2015-09-08 10:43:08 UTC
Created attachment 310889 [details] [review]
Support g_autoptr() for all libsoup object types

This allows using e.g. g_autoptr(SoupSession) in other programs, but
does not make libsoup itself use g_autoptr, or require a new enough glib
to support it.
Comment 2 Dan Winship 2015-09-08 14:34:16 UTC
Comment on attachment 310889 [details] [review]
Support g_autoptr() for all libsoup object types

>+ * Copyright (C) 2015 Red Hat, Inc.

No "(C)". (Yes I know most existing files have it. They're wrong.)

These ought to be SOUP_AVAILABLE_IN_2_52, though it seems like it's probably not possible to do that? Maybe wrap

  #if SOUP_VERSION_MAX_ALLOWED >= SOUP_VERSION_2_52
  ...
  #endif

around it?

Need to update docs/ for this. Probably just adding soup-autocleanups.h to IGNORE_HFILES is the right answer.
Comment 3 Kalev Lember 2015-09-08 14:49:39 UTC
(In reply to Dan Winship from comment #2)
> Comment on attachment 310889 [details] [review] [review]
> Support g_autoptr() for all libsoup object types
> 
> >+ * Copyright (C) 2015 Red Hat, Inc.
> 
> No "(C)". (Yes I know most existing files have it. They're wrong.)

Ha, and I thought it's just me who finds it weird to write both 'Copyright' and '(C)'.


> These ought to be SOUP_AVAILABLE_IN_2_52, though it seems like it's probably
> not possible to do that? Maybe wrap
> 
>   #if SOUP_VERSION_MAX_ALLOWED >= SOUP_VERSION_2_52
>   ...
>   #endif
> 
> around it?

I don't know about that -- glib's and gtk's
/usr/include/glib-2.0/glib/glib-autocleanups.h
/usr/include/gtk-3.0/gtk/gtk-autocleanups.h
... don't have any AVAILABLE_IN guards in these files?


> Need to update docs/ for this. Probably just adding soup-autocleanups.h to
> IGNORE_HFILES is the right answer.

Yup, sounds right to me. I don't think these need any docs.
Comment 4 Kalev Lember 2015-09-08 14:57:25 UTC
Created attachment 310908 [details] [review]
Support g_autoptr() for all libsoup object types

This allows using e.g. g_autoptr(SoupSession) in other programs, but
does not make libsoup itself use g_autoptr, or require a new enough glib
to support it.
Comment 5 Dan Winship 2015-09-09 13:41:23 UTC
(In reply to Kalev Lember from comment #3)
> > These ought to be SOUP_AVAILABLE_IN_2_52, though it seems like it's probably
> > not possible to do that? Maybe wrap
> > 
> >   #if SOUP_VERSION_MAX_ALLOWED >= SOUP_VERSION_2_52
> >   ...
> >   #endif
> > 
> > around it?
> 
> I don't know about that -- glib's and gtk's
> /usr/include/glib-2.0/glib/glib-autocleanups.h
> /usr/include/gtk-3.0/gtk/gtk-autocleanups.h
> ... don't have any AVAILABLE_IN guards in these files?

you can't use AVAILABLE_IN because of how the G_DEFINE_AUTOPTR_CLEANUP_FUNC macro expands, but I still think it would be best to put the version check above around the whole thing, so that people don't accidentally use the macros when they meant to depend on an older version of libsoup.

OK to commit with that addition
Comment 6 Kalev Lember 2015-09-09 14:05:31 UTC
(In reply to Dan Winship from comment #5)
> so that people don't accidentally use the macros when they meant to depend on an older version of libsoup.

Thanks, makes sense now why it's needed.
Comment 7 Kalev Lember 2015-09-09 14:11:59 UTC
Thanks, pushed with that fix.

Attachment 310908 [details] pushed as 5df74a1 - Support g_autoptr() for all libsoup object types
Comment 8 Kalev Lember 2015-09-10 11:28:53 UTC
Reopening; I got a few free functions wrong in the first patch and found a more types that could be added.
Comment 9 Kalev Lember 2015-09-10 11:29:23 UTC
Created attachment 311056 [details] [review]
autocleanups: Fix free functions for non-GObject based types
Comment 10 Kalev Lember 2015-09-10 11:29:28 UTC
Created attachment 311057 [details] [review]
autocleanups: Add a few more missing types
Comment 11 Kalev Lember 2015-09-10 11:29:34 UTC
Created attachment 311058 [details] [review]
autocleanups: Exclude the header from instrospection
Comment 12 Kalev Lember 2015-09-10 11:32:03 UTC
Review of attachment 311056 [details] [review]:

::: libsoup/soup-autocleanups.h
@@ +23,2 @@
 #include <libsoup/soup-types.h>
+#include <libsoup/soup-uri.h>

Which is better: include all the headers that we need here like I've done in this patch, or maybe alternatively move soup-autocleanups.h as the last include in soup.h? The last option is what glib/gtk+ are doing, but they are also enforcing single includes, so not sure which way is best here in libsoup.
Comment 13 Dan Winship 2015-09-10 14:05:35 UTC
Comment on attachment 311057 [details] [review]
autocleanups: Add a few more missing types

>+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupMessageQueue, g_object_unref)

That's an internal type (and not a GObject)

>+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupProxyResolver, g_object_unref)
>+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupProxyResolverDefault, g_object_unref)
>+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupProxyURIResolver, g_object_unref)

Don't define autocleanups for deprecated types please. (There may be others in the list that I've missed too...)
Comment 14 Dan Winship 2015-09-10 14:08:42 UTC
(In reply to Kalev Lember from comment #12)
> Which is better: include all the headers that we need here like I've done in
> this patch, or maybe alternatively move soup-autocleanups.h as the last
> include in soup.h? The last option is what glib/gtk+ are doing, but they are
> also enforcing single includes, so not sure which way is best here in
> libsoup.

Either way is fine by me... while we don't *officially* require single-includes, IMHO including only <libsoup/soup.h> is still preferred, so semi-requiring that for new headers is fine.
Comment 15 Kalev Lember 2015-09-10 15:47:58 UTC
Attachment 311056 [details] pushed as 0b0d6ab - autocleanups: Fix free functions for non-GObject based types
Attachment 311058 [details] pushed as 4694333 - autocleanups: Exclude the header from instrospection
Comment 16 Kalev Lember 2015-09-14 17:47:59 UTC
Okay, here's an updated patch with deprecated types removed:
Comment 17 Kalev Lember 2015-09-14 17:48:55 UTC
Created attachment 311300 [details] [review]
autocleanups: Add a few more missing types
Comment 18 Kalev Lember 2015-09-15 12:04:09 UTC
Created attachment 311355 [details] [review]
Require single includes for new headers

For new headers added this cycle, enforce single includes by only
allowing directly including <libsoup/soup.h>.
Comment 19 Dan Winship 2015-09-15 14:14:03 UTC
pushed those two patches. thanks