Re: [PATCH] Gtk2.xs (gtk_init): do gtk_init_check in PL_minus_c mode

Alexey Tourbin wrote:

$ env -i perl -c -e 'use Gtk2 -init'
Gtk-WARNING **: cannot open display:  at /usr/lib/perl5/vendor_perl/x86_64-linux/ line 138.

I have the feeling that though it's annoying, it may be about all that's
really possible.  If a program does a gtk_init in a BEGIN block then it
has to have a display to syntax check it.

 -    if (ix == 2) {
+     if (ix == 2 || PL_minus_c) {
              RETVAL = gtk_init_check (&pargv->argc, &pargv->argv);

But either way I'd leave the Gtk2->init function unchanged as the basic
operation, instead think about what Gtk2::import() should do for '-init'
under different perlrun options.

Torsten Schoenfeld <kaffeetisch gmx de> writes:

undesired effects.

The only bad stuff I can think of is if a subsequent BEGIN block (or
CHECK block) depended on a '-init' actually having initted.

I imagine that's a bit unlikely, ie. that very few 'use's or 'BEGIN's in
a program would care, and that instead in practice '-init' is a
shorthand for a Gtk2->init at the start of execution rather than really
wanting it at the import stage as such.  Could '-init' be made to add a
Gtk2->init at the start of execution in the importing parent module?  It
might still be not quite right if a module does a -init (which it
probably oughtn't anyway), but for the top-level program it could be
what's wanted.

muppet <scott asofyet org> writes:

                /* And here's a nice place to comment on the
rationale... */
                warn ("In syntax check mode, calling gtk_init_check()
instead of gtk_init()";

Probably check mode should be quieter not noisier than normal :-).
Perhaps a warning if the init failed and it decided to proceed anyway in
hope, then it could warn, since I think the error messages from widget
creation stuff are pretty unclear if you forget or failed to init.

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