Re: how to tell if a widget is still "alive" ?
- From: Gregory Hosler <ghosler redhat com>
- To: David NeÄas <yeti physics muni cz>
- Cc: GTK developer list <gtk-app-devel-list gnome org>
- Subject: Re: how to tell if a widget is still "alive" ?
- Date: Thu, 17 Jun 2010 15:49:11 +0800
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 06/17/2010 03:38 PM, David NeÄas wrote:
On Thu, Jun 17, 2010 at 09:07:46AM +0800, Gregory Hosler wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
I have an application where I'm making use of animated gifs on a GtkTextBuffer.
I set a timer (g_timeout_add()) to remove the animated character after a small
period of time (10 secs in this case).
The argument to the timer callback includes a pointer to the text buffer
GtkTextChildAnchor in front of where I inserted my animation. The idea is that
inside the timeout, I insert a static copy of the gif, and do a
gtk_text_buffer_delete() of the iter's before and after the animation.
This works about 99.999% of the time.
In some rare circumstances, by the time that the timer callback is called, the
GtkTextChildAnchor has been deleted.
To guard against this, I tested the GtkTextChildAnchor with
GTK_IS_TEXT_CHILD_ANCHOR(), but on occassion, I will get a segfault on the
GTK_IS_TEXT_CHILD_ANCHOR() (the address of the GtkTextChildAnchor is still a
valid address).
I'm thinking that the GtkTextChildAnchor has been deleted, the memory used for
something else, and the GTK_IS_TEXT_CHILD_ANCHOR() is seg faulting as a result.
Question: how might I avoid this seg fault situation ? Will "GTK_IS_WIDGET()"
help to determine if the GtkTextChildAnchor is still alive before testing it
with GTK_IS_TEXT_CHILD_ANCHOR() ? or is there a better way of doing this ?
The standard rule is: if you permanently use an object take a reference
with g_object_ref(). Then it can't be finalized unless you release
the reference.
<slaps head>
ah, yes! of course!
In my earlier days of gtk+ usage I didn't understand the significance of the
ref. I do now (and have for some time), but somehow missed this obvious soln!
Thanks a lot!
- -Greg
See also the description of gtk_text_child_anchor_get_deleted().
You can get notified when an object is finalized, but this is not a case
where you should do it.
Yeti
- --
+---------------------------------------------------------------------+
Please also check the log file at "/dev/null" for additional information.
(from /var/log/Xorg.setup.log)
| Greg Hosler ghosler redhat com |
+---------------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkwZ03UACgkQ404fl/0CV/SZfwCgwcyRO4l0zLAxZYGYAZenV62z
4jMAoIDLVaz0owZWz4DZuBwOsGit1l+b
=ZJnK
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]