Trying to fix the memory leak...
This commit is contained in:
parent
d91b369050
commit
7084a9a077
|
@ -6,7 +6,7 @@ G_DEFINE_TYPE(PreviewWidget, PreviewWidget, GTK_TYPE_BIN)
|
||||||
|
|
||||||
void kona_download_image( GtkWidget *widget, gpointer data )
|
void kona_download_image( GtkWidget *widget, gpointer data )
|
||||||
{
|
{
|
||||||
PreviewWidget_set_image(data, "/home/kurisu/Pictures/Wallpapers/preview.jpg"); // DEBUG ONLY!
|
PreviewWidget_set_image(data, "/home/kurisu/Pictures/Screenshot from 2016-03-07 09-16-18.png"); // DEBUG ONLY!
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
||||||
|
@ -18,7 +18,7 @@ void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
||||||
widgets = gtk_container_get_children(GTK_CONTAINER(widget));
|
widgets = gtk_container_get_children(GTK_CONTAINER(widget));
|
||||||
w = widgets->data; // Grab GtkImage
|
w = widgets->data; // Grab GtkImage
|
||||||
|
|
||||||
GdkPixbuf *p;
|
GdkPixbuf *p, *ps;
|
||||||
p = gdk_pixbuf_new_from_file(url, NULL);
|
p = gdk_pixbuf_new_from_file(url, NULL);
|
||||||
iheight = (float) gdk_pixbuf_get_height(p);
|
iheight = (float) gdk_pixbuf_get_height(p);
|
||||||
iwidth = (float) gdk_pixbuf_get_width(p);
|
iwidth = (float) gdk_pixbuf_get_width(p);
|
||||||
|
@ -31,9 +31,9 @@ void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
||||||
height = iheight / iwidth * 200;
|
height = iheight / iwidth * 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ps = gdk_pixbuf_scale_simple(p, width, height, GDK_INTERP_BILINEAR);
|
||||||
p = gdk_pixbuf_scale_simple(p, width, height, GDK_INTERP_BILINEAR);
|
g_object_unref(p);
|
||||||
gtk_image_set_from_pixbuf(GTK_IMAGE(w), p);
|
gtk_image_set_from_pixbuf(GTK_IMAGE(w), ps);
|
||||||
|
|
||||||
gtk_widget_set_visible(w, TRUE);
|
gtk_widget_set_visible(w, TRUE);
|
||||||
|
|
||||||
|
@ -78,5 +78,8 @@ GtkWidget *PreviewWidget_new(KonaImage* ki)
|
||||||
|
|
||||||
void debugfoo(GtkButton *widget, GtkImage *img)
|
void debugfoo(GtkButton *widget, GtkImage *img)
|
||||||
{
|
{
|
||||||
|
gtk_image_clear(img);
|
||||||
|
g_object_unref(gtk_image_get_pixbuf(img));
|
||||||
|
|
||||||
gtk_widget_destroy(img);
|
gtk_widget_destroy(img);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue