views:

9

answers:

0

Hello,

I need to run function in another thread then main form:

I have a job_func:

void job_func(GIOSchedulerJob *job, GCancellable *cancellable, gpointer user_data)
{
    MainWin* mw = (MainWin*)user_data;

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

Then loading function:

void loading(GtkWidget* widget ,MainWin* mw)
{   
    GInputStream* 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);  

}

And running function loading in another thread: here i need in mw->animation

gboolean main_win_open( MainWin* mw, const char* file_path, ZoomMode zoom ) {
list = NULL;

g_io_scheduler_push_job (loading, mw, NULL, G_PRIORITY_DEFAULT, mw->generator_cancellable);

    if (mw->animation == NULL)
         return;

}

Here mw->animation is NULL. Why? What's wrong? I got mw->animtion in mw->animation = load_image_from_stream(G_INPUT_STREAM(input_stream), mw->generator_cancellable);

Thank you