views:

8

answers:

0

Hello,

I have functiof of load data:

GdkPixbufAnimation* load_image_from_stream(GInputStream* input_stream, GCancellable* generator_cancellable)
{
   ....
}

It's load very nice. Then I have function where i call load_image_from_stream:

void loading(GtkWidget* widget ,MainWin* mw)
{   
    GInputStream* input_stream;

    input_stream = g_file_read(loading_file, mw->generator_cancellable, NULL);  
    mw->animation = load_image_from_stream(G_INPUT_STREAM(input_stream), mw->generator_cancellable);    

    g_input_stream_close(input_stream, mw->generator_cancellable, NULL);
    g_object_unref (input_stream);  
}

I run this function in another thread with GIOScheduler:

gboolean main_win_open( MainWin* mw,  ZoomMode zoom )
{               

    JobParam* param1 = malloc(sizeof(JobParam));
    param1->widget = NULL;
    param1->mw     = mw;

    g_io_scheduler_push_job (**job_func1**, param1, NULL, G_PRIORITY_HIGH, param1->mw->generator_cancellable);
}

This is my job_func1:

gboolean job_func1(GIOSchedulerJob *job, GCancellable *cancellable, gpointer user_data)
{
    JobParam* param = (JobParam*)user_data;

    while (g_cancellable_is_cancelled(cancellable) == FALSE)
    {
        loading(NULL, param->mw);       
        g_cancellable_cancel (param->mw->generator_cancellable);
        }

    g_io_scheduler_job_send_to_mainloop(job, set_image, param, NULL);
    g_cancellable_cancel (param->mw->generator_cancellable);
}

And set_image:

void set_image(JobParam* param)
{
   gtk_anim_view_set_anim (param->mw->aview, param->mw->animation);
}

When i try to call loading image and then displaying it, it's work, but when i try to call second, third time and more displaying only first image.

Why? What's wrong?

Thank you.