Create Window object before Application init

Hello,

I’m trying to build initial application class that has Window as member.
As this operation happened on construct, the app not activated yet at this point.

GTK has not been initialized. Call `gtk::init` first.

So the question: can I init the app by Gtk::init() before launch application with:

App::new()

Seems App::new() method contain this ‘launcher’ so it will be called twice?
How to safely init application only once, or there is some lock for multiple init call?

Worried to not start 2 processes instead than 1.

Maybe that’s dependent from wrapper implementation.

In my case, gtk::init() has following documentation:

Tries to initialize GTK.

Call either this function or Application::new before using any other GTK functions.

Note that this function calls gtk_init_check() rather than gtk_init(), so will not cause the program to terminate if GTK could not be initialized. Instead, an Ok is returned if the windowing system was successfully initialized otherwise an Err is returned.

gtk_init() can be called multiple times, only the 1st time will actually initialize, subsequent calls will do nothing. So no problem in your case :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.