Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Bibek Sahu <scorpio@dodds.net>
To: Shaw Terwilliger <sterwill@postman.abisource.com>, axp-list@redhat.com
Subject: Re: C++ gurus; AbiWord pointer casting on Alpha
Date: Thu, 19 Nov 1998 16:26:52 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.3.95.981119162109.31728P-200000@norad.dodds.net> (raw)
In-Reply-To: <3650D107.CDA25BE0@postman.abisource.com>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1675 bytes --]


	Ok, scratch that, I was wrong: there is no 'callback_data' member.

	I looked at the Gimp source to see how it was done there (since it
does work fine on my machine), and discovered that AbiWord was being done
in a fundamentally incorrect manner.

	Gotta love that GTK documentation, huh?  I had to dig through the
gtk headers and another program's source code to figure this out... THAT I
consider to be fundamentally Wrong. ;-)

	At any rate, since the menuing code was already using the
UT_Vectors, the fix was trivial.  A patch is attached.  Menus work for me
now; hurray! :-)

	However, it still does segfault on exit.  I'll look into that
later.

- Bibek

On Mon, 16 Nov 1998, Shaw Terwilliger wrote:

> Bibek Sahu wrote:
> >         Although I don't know the code well enough to be positive, it
> > appears that 'callback_action' is supposed to be data rather than a
> > function pointer.  The 'callback_data' member, defined to be of type
> > gpointer, which is in all the structures that include callback_action
> > might be more appropriate if you need a pointer.
> 
> Hm... I'm still wondering if it's a compiler thing (testgtk is C,
> we're using C++; odd chance that the C++ compiler is doing much
> different
> casting here).  If we're abusing that member (storing pointers instead
> of, say, an index to a list of functions), the GTK guys sure haven't
> told me so.  I asked on the list early this morning, and on the IRC
> channel.  None of them seem to really know; the total lack of
> documentation
> on GTK+ doesn't help much.  :)  
> 
> I'll take a look at this some more and try to get back to the Alpha
> list about it.
> 
> -- 
> Shaw Terwilliger
> 

[-- Attachment #2: Type: TEXT/PLAIN, Size: 1665 bytes --]

--- ev_UnixMenu.cpp.orig	Thu Nov 19 14:55:12 1998
+++ ev_UnixMenu.cpp	Thu Nov 19 16:04:09 1998
@@ -369,7 +369,7 @@
 	UT_ASSERT(wd);
 	m_vecMenuWidgets.addItem(wd);
 
-	p->callback_action = (guint)wd;
+	p->callback_action = m_vecMenuWidgets.findItem(wd);
 	p->item_type = NULL;
 	if (bCheckable)
 		p->item_type = "<CheckItem>";
@@ -402,7 +402,7 @@
 	UT_ASSERT(wd);
 	m_vecMenuWidgets.addItem(wd);
 
-	p->callback_action = (guint)wd;
+	p->callback_action = m_vecMenuWidgets.findItem(wd);
 	p->item_type = "<Branch>";
 
 	// append this name to the prefix, omitting the "&".
@@ -445,7 +445,7 @@
 	UT_ASSERT(wd);
 	m_vecMenuWidgets.addItem(wd);
 
-	p->callback_action = (guint)wd;
+	p->callback_action = m_vecMenuWidgets.findItem(wd);
 	p->item_type = "<Separator>";
 }
 
@@ -607,7 +607,7 @@
 					_wd * wd = new _wd(this,id);
 					UT_ASSERT(wd);
 
-					p->callback_action = (guint)wd;
+					p->callback_action = m_vecMenuWidgets.findItem(wd);
 					p->item_type = NULL;
 
 					// Currently no checkable dynamic items
@@ -642,7 +642,7 @@
 {
 	for (UT_uint32 k=0; (k < m_nrActualFactoryItems); k++)
 	{
-		_wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
+		_wd * wd = (_wd *)m_vecMenuWidgets.getNthItem(m_menuFactoryItems[k].callback_action);
 		if (wd && (wd->m_id==id))
 			return m_menuFactoryItems[k].path;
 	}
@@ -654,7 +654,7 @@
 {
 	for (UT_uint32 k=0; (k < m_nrActualFactoryItems); k++)
 	{
-		_wd * wd = (_wd *)m_menuFactoryItems[k].callback_action;
+		_wd * wd = (_wd *)m_vecMenuWidgets.getNthItem(m_menuFactoryItems[k].callback_action);
 		if (wd && (wd->m_id==id))
 			return UT_TRUE;
 	}

       reply	other threads:[~1998-11-19 22:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3650D107.CDA25BE0@postman.abisource.com>
1998-11-19 22:26 ` Bibek Sahu [this message]
1998-11-19 23:02   ` C++ gurus; AbiWord pointer casting on Alpha Bibek Sahu
1998-11-16 10:44 Shaw Terwilliger
1998-11-17  0:56 ` Bibek Sahu
1998-11-17  1:12   ` Paul Tomblin
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox