[Gambas-user] tracking down toolkit erors

Brian G brian at westwoodsvcs.com
Sun Aug 8 03:37:09 CEST 2021

Bruce replace your _new with this code 

Extern dup2(OldFD As Integer, newfd As Integer) In "libc:6" 
Static Dummy As File 
Static Public Sub _init() 
dummy = Open "/dev/null" For Write 
dup2(dummy.Handle, 1) 
dup2(dummy.handle, 2) 

Should give you what you want without all the fiddle 

"Failure is the key to success; 
each mistake teaches us something" .. Morihei Ueshiba 
Brian G 

----- On Aug 7, 2021, at 12:39 PM, Bruce Steers <bsteers4 at gmail.com> wrote: 

> On Thu, 5 Aug 2021 at 20:34, Bruce Steers < [ mailto:bsteers4 at gmail.com |
> bsteers4 at gmail.com ] > wrote:

>> On Wed, 4 Aug 2021 at 00:53, < [ mailto:jose.rodriguez at cenpalab.cu |
>> jose.rodriguez at cenpalab.cu ] > wrote:

>>> August 3, 2021 2:29 PM, "Bruce Steers" < [
>>> mailto:bsteers4 at gmail.com?to=%22Bruce%20Steers%22%20%3Cbsteers4 at gmail.com%3E |
>>> bsteers4 at gmail.com ] > wrote:

>>>> I have this program i'm developing that was starting and stopping cleanly then i
>>>> recently added some controls and did various other things and now it says this
>>>> when it starts...
>>>> (Desktop-ish:12906): Gtk-WARNING **: 16:29:25.336: Theme parsing error:
>>>> <data>:1:15: Expected a valid selectorIs there a way to track down what's
>>>> causing it?
>>>> thanks
>>>> BruceS

>>> GTK has always output loads of different errors with many programs (not gambas
>>> ones, I mean), when run in a terminal. People say it depends on the current
>>> theme and whatnot...

>> Indeed, Pluma was always my texteditor of choice and that used to pump out loads
>> of warnings.
>> (but now of course i use my own editor i wrote with gambas that has all those
>> cool Texteditor features ;) )

>> Would be great to be able to catch the warnings though.
>> Either a way to track what exactly is causing them or just suppress the
>> messages.

>> BruceS

> so 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.

> Public Sub _new()

> Args.Begin()
> Dim bQuiet As Boolean = Args.Has("q", "quiet", "supress gtk error messages")
> If bQuiet Then bQuiet = (Args.Has("s", "supressed", "supressed gtk error
> warnings") == False)
> Args.End()

> If bQuiet And File.In.IsTerm Then ' if we are not run from a terminal then no
> need for any of this
> Dim sRestOfargs As String[] = Args.All.Copy()

> ' the next 2 lines just handle if being run from the IDE and make Arg[0] be
> executable name.
> If Not InStr(sRestOfargs[0], "/") Then sRestOfargs[0] = Application.Path &/
> Application.Name
> If File.Ext(sRestOfargs[0]) <> "gambas" Then sRestOfargs[0] &= ".gambas"

> sRestOfargs.Insert(["-s", "2>/dev/null"])
> Shell sRestOfargs.Join(" ")
> Me.Close
> Return
> Endif

> End

> 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...

> BruceS

> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210807/fb1ca8b1/attachment-0001.htm>

More information about the User mailing list