tags 406378 =patch
thanks
On Sun, Jan 14, 2007 at 01:35:11PM +0000, Neil Williams wrote:
> On Sun, 14 Jan 2007 03:55:45 -0800
> Steve Langasek <[EMAIL PROTECTED]> wrote:
> > On Sat, Jan 13, 2007 at 09:26:13PM -0800, Thomas Bushnell BSG wrote:
> > > Hi Steve; you were very helpful with the last alpha bug reported by this
> > > submitter; I'm wondering if you can give it a little attention. I don't
> > > have easy access to an alpha to reproduce the problem.
> > Please ask upstream where they got the idea that g_type_register_static()
> > returned a guint, or that it was otherwise ok to cast its GType return type
> > to a guint.
> This behaviour has been "normal" for gnucash for at least 5 years.
Really? In gnucash 2.0.2, I find around 250 gtype declarations, and only 11
of them were using guint instead of GType (full patch attached now).
Casting GType to a 32-bit int is always fatal on alpha, because GType is
really a pointer disguised as an int, and due to the default load addresses
on alpha this will always truncate a 64-bit pointer to 32-bits and cause a
segfault. And I've used gnucash on alpha before, and it wasn't 5 years ago
-- either this is new code, or these types somehow weren't needed during
normal operation, or the nature of a gtype differs between gtk1.2 and
gtk2.0. (But I don't remember gtk1.2 having gobject/gtype at all, though
that could just be me...)
> The only "reason" I can find is from the API docs for glib2:
> "GType
> A numerical value which represents the unique identifier of a
> registered type. "
> http://developer.gnome.org/doc/API/2.0/gobject/gobject-Type-Information.html#GType
> I guess it's just being taken literally and in the absence of a warning
> not to . . .
> The use of guint predates the use of g_type_register_static, to a time
> when gtk_type_unique was in use:
> http://svn.gnucash.org/trac/changeset/12075#file1
>
> But the static guint type existed before that and has not been changed
> since:
> http://svn.gnucash.org/trac/browser/gnucash/trunk/src/business/business-gnome/search-owner.c?rev=6905#L65
Heh -- and unlike 2.0's GType, 1.2's GtkType *was* a typedef for a guint.
It's still type abuse, violating the abstraction provided by the API; but at
least that explains why gnucash worked on alpha before being ported to GTK
2.0.
> > Years of debugging crashing gtk+ programs on alpha, and it's
> > always the same thing -- somehow, GTK programmers are consistently getting
> > bad information about how to use gobject, and I want to know where it's
> > coming from so I can lart the people responsible.
> I can't find a URL for such bad information - maybe it's coming from a
> particular offline example. I'd have to say that the GObject/GLib/Gtk
> API documentation doesn't make it clear that although type is a
> numerical value it cannot be handled as a numerical value in a portable
> manner.
Er, it certainly can be handled as a numerical value in a portable manner --
*by taking care not to cast it (implicitly or otherwise) to a different type
that's too small*. You wouldn't think it appropriate to assign the return
value from a function returning unsigned long to a variable of type unsigned
short, would you?
> In the cases that you have found, has the use of guint also been a
> long-standing issue or are people putting this into new code?
New code, by and large.
> I somehow doubt anyone developing gnucash has been developing on an
> alpha.
No, I imagine not; but when this blatant type error is so common that I can
diagnose it from a glance at a backtrace, I really would like it if
upstreams were being given good enough docs to enable them to write working
code in the first place.
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
[EMAIL PROTECTED] http://www.debian.org/
diff -u gnucash-2.0.2/debian/changelog gnucash-2.0.2/debian/changelog
--- gnucash-2.0.2/debian/changelog
+++ gnucash-2.0.2/debian/changelog
@@ -1,3 +1,10 @@
+gnucash (2.0.2-2.2) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * For the 800th time, GType != int. Closes: #406378.
+
+ -- Steve Langasek <[EMAIL PROTECTED]> Sun, 14 Jan 2007 03:40:31 -0800
+
gnucash (2.0.2-2.1) unstable; urgency=medium
* NMU.
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome/gnc-split-reg.h
+++ gnucash-2.0.2/src/gnome/gnc-split-reg.h
@@ -159,7 +159,7 @@
/**
* GTK-related; gets an identifier for the class of GNCSplitRegs.
**/
-guint gnc_split_reg_get_type(void);
+GType gnc_split_reg_get_type(void);
/**
* Creates and returns a GNCSplitReg.
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome/gnc-split-reg.c
+++ gnucash-2.0.2/src/gnome/gnc-split-reg.c
@@ -170,10 +170,10 @@
FROM_STRING_FUNC(SortType, ENUM_LIST_SORTTYPE)
AS_STRING_FUNC(SortType, ENUM_LIST_SORTTYPE)
-guint
+GType
gnc_split_reg_get_type( void )
{
- static guint gnc_split_reg_type = 0;
+ static GType gnc_split_reg_type = 0;
if (!gnc_split_reg_type)
{
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/gnc-general-search.h
+++ gnucash-2.0.2/src/gnome-search/gnc-general-search.h
@@ -83,7 +83,7 @@
gpointer searched);
gpointer gnc_general_search_get_selected (GNCGeneralSearch *gsl);
-guint gnc_general_search_get_type (void);
+GType gnc_general_search_get_type (void);
#endif
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-account.h
+++ gnucash-2.0.2/src/gnome-search/search-account.h
@@ -46,7 +46,7 @@
/* signals */
};
-guint gnc_search_account_get_type (void);
+GType gnc_search_account_get_type (void);
GNCSearchAccount *gnc_search_account_new (void);
GNCSearchAccount *gnc_search_account_matchall_new (void);
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-boolean.h
+++ gnucash-2.0.2/src/gnome-search/search-boolean.h
@@ -47,7 +47,7 @@
/* signals */
};
-guint gnc_search_boolean_get_type (void);
+GType gnc_search_boolean_get_type (void);
GNCSearchBoolean *gnc_search_boolean_new (void);
/* methods */
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-date.h
+++ gnucash-2.0.2/src/gnome-search/search-date.h
@@ -48,7 +48,7 @@
/* signals */
};
-guint gnc_search_date_get_type (void);
+GType gnc_search_date_get_type (void);
GNCSearchDate *gnc_search_date_new (void);
/* methods */
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-double.h
+++ gnucash-2.0.2/src/gnome-search/search-double.h
@@ -47,7 +47,7 @@
/* signals */
};
-guint gnc_search_double_get_type (void);
+GType gnc_search_double_get_type (void);
GNCSearchDouble *gnc_search_double_new (void);
/* methods */
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-int64.h
+++ gnucash-2.0.2/src/gnome-search/search-int64.h
@@ -47,7 +47,7 @@
/* signals */
};
-guint gnc_search_int64_get_type (void);
+GType gnc_search_int64_get_type (void);
GNCSearchInt64 *gnc_search_int64_new (void);
/* methods */
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-numeric.h
+++ gnucash-2.0.2/src/gnome-search/search-numeric.h
@@ -50,7 +50,7 @@
/* signals */
};
-guint gnc_search_numeric_get_type (void);
+GType gnc_search_numeric_get_type (void);
GNCSearchNumeric *gnc_search_numeric_new (void);
GNCSearchNumeric *gnc_search_numeric_debcred_new (void);
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-reconciled.h
+++ gnucash-2.0.2/src/gnome-search/search-reconciled.h
@@ -47,7 +47,7 @@
/* signals */
};
-guint gnc_search_reconciled_get_type (void);
+GType gnc_search_reconciled_get_type (void);
GNCSearchReconciled *gnc_search_reconciled_new (void);
/* methods */
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-string.h
+++ gnucash-2.0.2/src/gnome-search/search-string.h
@@ -54,7 +54,7 @@
/* signals */
};
-guint gnc_search_string_get_type (void);
+GType gnc_search_string_get_type (void);
GNCSearchString *gnc_search_string_new (void);
/* methods */
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/gnc-general-search.c
+++ gnucash-2.0.2/src/gnome-search/gnc-general-search.c
@@ -80,10 +80,10 @@
*
* Returns the GtkType for the GNCGeneralSearch widget
*/
-guint
+GType
gnc_general_search_get_type (void)
{
- static guint general_search_type = 0;
+ static GType general_search_type = 0;
if (!general_search_type){
static const GTypeInfo our_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-account.c
+++ gnucash-2.0.2/src/gnome-search/search-account.c
@@ -56,10 +56,10 @@
static GNCSearchCoreTypeClass *parent_class;
-guint
+GType
gnc_search_account_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-boolean.c
+++ gnucash-2.0.2/src/gnome-search/search-boolean.c
@@ -51,10 +51,10 @@
static GNCSearchCoreTypeClass *parent_class;
-guint
+GType
gnc_search_boolean_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-date.c
+++ gnucash-2.0.2/src/gnome-search/search-date.c
@@ -55,10 +55,10 @@
static GNCSearchCoreTypeClass *parent_class;
-guint
+GType
gnc_search_date_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-double.c
+++ gnucash-2.0.2/src/gnome-search/search-double.c
@@ -55,10 +55,10 @@
static GNCSearchCoreTypeClass *parent_class;
-guint
+GType
gnc_search_double_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-int64.c
+++ gnucash-2.0.2/src/gnome-search/search-int64.c
@@ -56,10 +56,10 @@
static GNCSearchCoreTypeClass *parent_class;
-guint
+GType
gnc_search_int64_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-numeric.c
+++ gnucash-2.0.2/src/gnome-search/search-numeric.c
@@ -56,10 +56,10 @@
static GNCSearchCoreTypeClass *parent_class;
-guint
+GType
gnc_search_numeric_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-reconciled.c
+++ gnucash-2.0.2/src/gnome-search/search-reconciled.c
@@ -52,10 +52,10 @@
static GNCSearchCoreTypeClass *parent_class;
-guint
+GType
gnc_search_reconciled_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/gnome-search/search-string.c
+++ gnucash-2.0.2/src/gnome-search/search-string.c
@@ -55,10 +55,10 @@
static GNCSearchCoreTypeClass *parent_class;
-guint
+GType
gnc_search_string_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/business/business-gnome/search-owner.h
+++ gnucash-2.0.2/src/business/business-gnome/search-owner.h
@@ -46,7 +46,7 @@
/* signals */
};
-guint gnc_search_owner_get_type (void);
+GType gnc_search_owner_get_type (void);
GNCSearchOwner *gnc_search_owner_new (void);
/* methods */
only in patch2:
unchanged:
--- gnucash-2.0.2.orig/src/business/business-gnome/search-owner.c
+++ gnucash-2.0.2/src/business/business-gnome/search-owner.c
@@ -65,10 +65,10 @@
static guint signals[LAST_SIGNAL] = { 0 };
#endif
-guint
+GType
gnc_search_owner_get_type (void)
{
- static guint type = 0;
+ static GType type = 0;
if (!type) {
GTypeInfo type_info = {