[Gambas-user] tracking down toolkit erors

Bruce Steers bsteers4 at gmail.com
Mon Aug 9 16:41:24 CEST 2021


Many Thanks BrianG.  With this and your other help I now have this
routine....


































*' Gambas class fileExtern dup2(OldFD As Integer, newfd As Integer) In
"libc:6"Private Writer As FilePrivate Reader As FilePrivate restore As
FilePublic Sub _new()  Writer = Open Pipe "/tmp/testpipeout" For Write
restore = File.Err  dup2(Writer.handle, 2)  Reader = Open Pipe
"/tmp/testpipeout" For Read WatchEndPublic Sub File_read()  Dim buffer As
String  buffer = Read #Last, -Lof(Last)  For Each sLine As String In
Split(buffer, "\n")    If Not sLine Then Continue    If sLine Like "(" &
Application.Name & ":*): G*k-*" Then Continue     Print sLine
NextEndPublic Sub Form_Close()  If Writer Then Writer.Close()  If Reader
Then Reader.Close()  dup2(restore.handle, 2)End*







*Public Sub Button1_Click()  Print "Print Something"  Debug "Debug
Something"End*
I had to check each line of the buffer individually and used Like to
pattern-match the Gtk- Gdk- messages

So with that code my own Debug and Error messages still output (albeit to
stdout but that's fine) just the gtk/gdk messages are gone :)
Thanks again Brian , much respect :)
BruceS




On Sun, 8 Aug 2021 at 03:34, Brian G <brian at westwoodsvcs.com> wrote:

> 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)
> End
>
> 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 <bsteers4 at gmail.com> wrote:
>
>>
>>
>> On Wed, 4 Aug 2021 at 00:53, <jose.rodriguez at cenpalab.cu> wrote:
>>
>>> August 3, 2021 2:29 PM, "Bruce Steers" <bsteers4 at gmail.com
>>> <bsteers4 at gmail.com?to=%22Bruce%20Steers%22%20%3Cbsteers4 at gmail.com%3E>>
>>> 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  EndifEnd*
>
> 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 ]----
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210809/04b7fd16/attachment.htm>


More information about the User mailing list