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 698139 - Add a function to ensure types are registered
Add a function to ensure types are registered
Status: RESOLVED FIXED
Product: libgd
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: libgd maintainer(s)
Depends on:
Blocks: 698146
 
 
Reported: 2013-04-16 15:31 UTC by Paolo Borelli
Modified: 2013-04-18 23:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add a function to ensure types are registered (3.71 KB, patch)
2013-04-16 15:31 UTC, Paolo Borelli
needs-work Details | Review
Try 2 (3.74 KB, patch)
2013-04-17 20:20 UTC, Mattias Bengtsson
none Details | Review
Try 3 (5.55 KB, patch)
2013-04-17 22:48 UTC, Mattias Bengtsson
committed Details | Review

Description Paolo Borelli 2013-04-16 15:31:26 UTC
This is needed when using Gd widgets in .ui files
Comment 1 Paolo Borelli 2013-04-16 15:31:29 UTC
Created attachment 241650 [details] [review]
Add a function to ensure types are registered
Comment 2 Cosimo Cecchi 2013-04-17 15:17:40 UTC
Review of attachment 241650 [details] [review]:

Thanks for the patch, I have some comments below:

::: Makefile.am
@@ +210,3 @@
        $(NULL)
 Gd_1_0_gir_INCLUDES = $(LIBGD_GIR_INCLUDES)
+Gd_1_0_gir_FILES = $(libgd_la_SOURCES) $(nodist_libgd_la_SOURCES)

I guess this is needed because you import gd.h in gd.c? If so I'd rather you included the headers directly (you also need #ifdefs for each at that point I believe).

::: libgd/gd.c
@@ +16,3 @@
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */

I would rename this to something like gdtypescatalog.c.

@@ +58,3 @@
+#ifdef LIBGD__HEADER_BUTTON
+  g_type_ensure (GD_TYPE_HEADER_SIMPLE_BUTTON);
+  g_type_ensure (GD_TYPE_HEADER_MENU_BUTTON);

Missing GdHeaderToggleButton and GdHeaderRadioButton here
Comment 3 Paolo Borelli 2013-04-17 17:38:56 UTC
(In reply to comment #2)
> I guess this is needed because you import gd.h in gd.c? If so I'd rather you
> included the headers directly (you also need #ifdefs for each at that point I
> believe).
> 

May I ask why? duplicating all the ifdefs seem kind of pointless when the prototype of the function itself is in that header. Besides all the other libs I checked included public headers in the gir_FILES. What am I missing?

To be honest I do not quite understand why the source files are split into a nodist var in the first place...

> 
> I would rename this to something like gdtypescatalog.c.
> 

Seems kind of long and I do not like having .c files without a matching header... should I also have a separate .h file? I also guess that it would be gd-types-catalog with dashes for consistency with the other files.
Comment 4 Paolo Borelli 2013-04-17 18:50:47 UTC
Also, Zeeshan in #698146 proposes to call the function gd_init(). I have no strong opinion about that
Comment 5 Mattias Bengtsson 2013-04-17 20:20:31 UTC
Created attachment 241775 [details] [review]
Try 2

Here's an updated patch that adds ensure's for the missing GdHeaderToggleButton and GdHeaderRadioButton and renames gd_ensure_types() to gd_init()

@cosimo: I'm not experienced enough with the autoconf stuff to comment on your first remark, but gd.c/gd_init() as Paolo and Zeeshan suggested seems fine to me.
Comment 6 Mattias Bengtsson 2013-04-17 22:48:49 UTC
Created attachment 241782 [details] [review]
Try 3

Incorporated all suggested changes. 

I really hope I did it this time. I feel unsure about the #includes inside gd_ensure_types() but it all seems to work.
Comment 7 Cosimo Cecchi 2013-04-17 22:57:04 UTC
Review of attachment 241782 [details] [review]:

Looks better, thanks. I have another comment.

::: libgd/gd-types-catalog.c
@@ +33,3 @@
+# include <libgd/gd-styled-text-renderer.h>
+# include <libgd/gd-toggle-pixbuf-renderer.h>
+# include <libgd/gd-two-lines-renderer.h

This seems to be missing a matching ">" at the end.

But generally, please move all the includes at the top out of the function body, and use #include "gd-foo-bar.h" instead of #include <libgd/gd-foo-bar.h> (headers will be in the same directory, and it's consistent with what GTK and other files in libgd do already).
Comment 8 Mattias Bengtsson 2013-04-18 07:46:18 UTC
If no one gets in before me I will fix this tomorrow. Thanks for the review!
Comment 9 Paolo Borelli 2013-04-18 16:56:29 UTC
I amended the patch and pushed

(I do not 100% agree on moving the includes at the top since now we have the ifdefs in *three* places instead of just one, but oh well...)
Comment 10 Zeeshan Ali 2013-04-18 23:10:26 UTC
Can someone please update the status of patches?
Comment 11 Cosimo Cecchi 2013-04-18 23:19:07 UTC
Comment on attachment 241782 [details] [review]
Try 3

A version of this modified for review comments was committed.