Re: gtk_widget_modify_style causes App to crash



On 2001.11.27 10:20 Rajesh Padalia wrote:
Hi,

I am using following code to set font of Rows in Clist. It works but
causes Application to crash after setting font few times. Any
ideas? Appreciate your help in sorting out this problem.

GtkRcStyle * rcstyle = gtk_rc_style_new();
rcstyle->font_name = Font_Selected;
(gchar * Font_Selected is set through GnomeFontPicker)
gtk_widget_modify_style(GTK_CLIST(alarm_clist), rcstyle));
gtk_rc_style_unref(rcstyle);

Might be a simple pointer issue, it's probably trying to deallocate
something in member font_name that isn't dynamic. Try this instead:


GtkRcStyle *rcstyle = gtk_rc_style_new();
g_free(rcstyle->font_name);
rcstyle->font_name = (Font_Selected != NULL) ?
 g_strdup(Font_Selected) : NULL;

gtk_widget_modify_style(GTK_CLIST(alarm_clist), rcstyle));

g_free(rcstyle->font_name);
rcstyle->font_name = NULL;
gtk_rc_style_unref(rcstyle);



--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/



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