Re: [gtk-list] Memory management




Based on last weeks discussion about references, it seems that you'll
have to do a gtk_style_unref after the style has been assigned to the
widget so that it gets freed when the widget no longer uses it.
 
 -Eric

---Jeremy Wise <jwise@pathwaynet.com> wrote:
>
> 
> I've come across a memory leak in my program (gtkicq), and it
appears to
> have something to do with styles.  Here's the situation.  When in
chat,
> and the user hits a character, a callback is called which sends the
key to
> the other client, and sets the style...
> 
> GtkStyle *style;
> .
> .
> .
> style = gtk_style_new();
> memcpy( &style->fg[ GTK_STATE_NORMAL ], foreground, sizeof(GdkColor)
);
> memcpy( &style->text[ GTK_STATE_NORMAL ], foreground,
sizeof(GdkColor) );
> memcpy( &style->base[ GTK_STATE_NORMAL ], background,
sizeof(GdkColor) );
> 
> gtk_widget_set_style( widget, style );
> .
> .
> .
> 
> where widget is the text widget the user is typing in.  My question
is, do
> I have to clean up that style, or the colors after setting the
style, or
> should I leave them alone?  If the latter, then why is this "leaking?"
> 
> Any help will be appreciated.
> 
> Sincerely,
> 
> Jeremy Wise
> 
> +----------------------------------------------------------------+
> | Jeremy Wise                                God rules.          |
> | jwise@pathwaynet.com                       Always has,         |
> | ICQ #4664755                               Always will.        |
> | http://www.pathwaynet.com/~jwise           Hope you know Him!  |
> +----------------------------------------------------------------+
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
/dev/null
> 
> 

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]