[Vala] Seg fault when trying to pass args to gtk_init_check.




I use the libpeas plugin engine, and want to init gtk from the plugin registar method.
I saved the main() args in static field in my library, and the plugin registar method looks like this:
public void peas_register_types (ObjectModule module) {
    int* argsc;
    char*** argsv;
    argsv = Max.get_args (out argsc);
    
    stdout.printf ("Args count : " + (*argsc).to_string () + "\n");
    stdout.printf ("First arg : " + (string)argsv[0] + "\n");
    
    if (!gtk_init_check (argsc, argsv)) {
        stderr.printf ("Error: Failed to initialize Gtk.\n");
        return;
    }
    stdout.printf ("Pass first\n");
...
}
...
extern bool gtk_init_check (int *argc, char ***argv);

I get this output:

$$ LD_LIBRARY_PATH=. ./simple_triangle
Start to setup plugins.
Loading plugin module: backend-gtkglext1
Args count : 1
First arg : ./simple_triangle
Segmentation fault

The question is why it's make seg fault?
I tested the input, and it looks fine!
If I don't pass args to gtk_init_check, i.e.:
gtk_init_check (null, null)

It works! So what is the problem?

Thanks
Tal
                                          


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