gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!

Home Page:https://gtk-rs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using from another package fails on Windows with GLib-GIO-CRITICAL ** This application can not open files.

doivosevic opened this issue · comments

So if I run the application from the same package everything works fine, but if I depend on the package from another and invoke the run method from it I get the fail.

(xxx.exe:6808): GLib-GIO-CRITICAL **: 20:28:34.488: This application can not open files.

    let mut flags: ApplicationFlags = Default::default();
    // flags.set(ApplicationFlags::HANDLES_OPEN, true);

    let application = gtk::Application::new(
        Some("io.github.plotters-rs.plotters-gtk-test"),
        flags,
    )
    .expect("Initialization failed...");

    application.connect_activate(move |app| {
        build_ui(app, drawn_dots.clone());
    });

    application.run(&args().collect::<Vec<_>>());

The code is pretty much identical to https://github.com/38/plotters/blob/ebc23079e66822d696f5772cc95ab5586a8c0766/examples/gtk-demo/src/main.rs

Can you provide a minimal, runnable testcase for reproducing this?

Ok. So I've found the issue. The problem was the demo code I linked was reading from args and passing it into application which I overlooked so when my app was taking in some command line arguments they were passed down into gtk application and hence the error.
Passing an empty vec here fixes my problem

`application.run(&args().collect::<Vec<_>>());`

I should have read the code more carefully