[Solved] supressing gtk warning messages
Posted
#1
(In Topic #719)
Guru

The best answer i have so far is this "hack"…
Uses gb.args
if the arg -q or –quiet is given then before the app loads it launches itself with any and all args plus "2>/dev/null" to redirect the error output and an additional arg -s.
when the 2nd run instance quits the 1st one that launched the second one also quits before it's even done anything.
the check works earliest in the _new() method. in _init() gb.args does not work.
PS. as it runs it's own exe you will need to "Make Executable" before it can work
Code (gambas)
- Args.Begin()
- ' the next 2 lines just handle if being run from the IDE and make Arg[0] be executable name.
- sRestOfargs.Insert(["-s", "2>/dev/null"])
Attached is a simple test app
It's a form with a tiny little TextArea in it, so small it produces warnings on my system when i move the mouse around the window…
(Test:79673): Gdk-CRITICAL **: 20:26:58.775: gdk_window_is_visible: assertion 'GDK_IS_WINDOW (window)' failed
Run with -q and all is quiet.
./Test.gambas -q
Of course this method will suppress ANY error messages ,
shell commands can be fixed by adding '>2&1'
Shell "/run/mycommand 2>&1"
that redirects error output to stdout and stdout is still showing
Please somebody tell me there's a better way…
Posted
Guru

BruceSteers said
PS. as it runs it's own exe you will need to "Make Executable" before it can work
or do this i guess if you want to add something like this to your own projects …
(see additional commented routine at line 15 to compile exe if run from IDE)
Note: i also did away with the -s arg and made it just remove the -q or –quiet arg on relaunch
Code (gambas)
- Args.Begin()
- ' With this command the project is compiled before it's relaunched (If run from the IDE Arg[0] has no path).
- sRestOfargs.Add("2>/dev/null")
Making the exe compile itself first before relaunching helps when developing as in the IDE you can just hit the run button without having to compile first.
You have to compile before test running the app in the IDE and using the -q arg to suppress the gtk garbage as the app will be relaunching itself if you do not "make exe" then the relaunch runs the old exe.
So the addition above will make the project compile a new exe (with your changes) before relaunch.
Note: DO NOT APPEND -q to other args. Ie. if you have other args say -V and -s you CANNOT use -qVs or -Vsq etc you MUST use something like '-Vs -q'
Any of the other args can be appended and be okay but the -q MUST be on it's own to be removed or the app will just cycle relaunching.
Posted
Guru

The code below will divert outgoing Error/Debug messages through the File_Read() event where i check for Gtk- and Gdk- messages and Print the error if not.
the downside is that your program will only output to StdOut with Print (not really much of a downside)
Code (gambas)
1 guest and 0 members have just viewed this.



