CSS provider memory problem

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

 



Hello, 

I have in aplication many widget which some times change color (as atention of working device). I stil use gtk_widget_override_color() function. I rewrite code to CSS-like styling for widgets. There is problem with memmory.
I write simpy demonstration code:


int blink(GtkWidget *widget)
{
   static int flag=0;
	
   GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(widget));
   GtkCssProvider *provider = gtk_css_provider_new();
   gtk_style_context_add_provider(style_context, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
   g_object_unref(provider);
	
   if(flag){
      gtk_css_provider_load_from_data(provider, "*{background: red;}", -1, NULL);
      flag = 0;
   }else{
      gtk_css_provider_load_from_data(provider, "*{background: white;}", -1, NULL);
      flag = 1;
   }
	
	return(TRUE);
}

int main
{
.........

	g_timeout_add(50, (GSourceFunc)blink, button);

...........
}

After starting this code, constantly rise amount of alocated memory. It seems that every use of gtk_style_context_add_provider() add new provider, but the old one is not remove. Is there any way to remove the old provider or get pointer to old provider from widget and reuse this one? Or any other solution?

Thanks much.
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux