[gtk-server] Re: GtkTextIter

  • From: Ian Haywood <ihaywood@xxxxxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Mon, 20 Nov 2006 17:46:28 +1100

On Monday 20 November 2006 02:46, Peter van Eerten wrote:
> Hi Ian,
>
> For the GtkIter widget you need to workaround your problem with a trick.
> Indeed, there is no such function as a 'gtk_iter_new'. Therefore, you must
> allocate memory with some other widget. I always use 'gtk_frame_new' for
> this.
Thanks for this.

> Now your variable 'iter' points to allocated memory for a frame, where GTK
> can store information for an iter-structure as well.
Overwriting the frame data?
I'd be worried this would cause memory leaks or similar weird issues when GTK 
tries to clean up the frame structure that's been scribbled over by the 
text_iter structure. Also we are praying that never 
sizeof(GtkTextIter) > sizeof (GtkFrame) 
However you imply that have used this technique in practice without problems, 
is that right?

I suppose you could immediately pass the frame object to gtk_text_iter_copy ()
which would give you a "real" text_iter memory allocation to use.

Ian

Other related posts: