gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
277 stars 61 forks source link

Unexpected WIDGET_TEXT behavior #1536

Open rdimeo opened 1 year ago

rdimeo commented 1 year ago

I came across unusual and unexpected behavior when attempting to process events returned from a text widget. The following short program below demonstrates this behavior.

pro test_text_event,event
uname = widget_info(event.id,/uname)
case uname of
'QUIT': widget_control,event.top,/destroy
'N':    begin
            print,'TYPE: ',event.type
    end
else:
endcase
end
; ************************ ;
pro test_text
tlb = widget_base(/col)
void = widget_text(tlb,value = '10',uname = 'N', $
    xsize = 25, /editable,/all_events)
void = widget_button(tlb,value = 'QUIT', $
    uname = 'QUIT')
widget_control,tlb,/realize
xmanager,'test_text',tlb,event_handler = 'test_text_event',/no_block
end

The first time I run the program after doing a full reset (.FU), it does not return EVENT.TYPE 0 events after pressing ENTER (as I would expect a text widget should). Other event types seem to be returned properly. The next time I run the program (after NOT doing a full reset), when I change the text in the short program below and press ENTER, I get the following error:

NULL baseWidget (possibly Destroyed?) found in GDLWidget::PushEvent( WidgetIDT baseWidgetID=0, DStructGDL* ev=0x2e77cad56f0), please report!

So the WIDGET_TEXT does not seem to be returning events and event types as I would expect. And it also seems to depend whether or not I've done a full reset (though the behavior is still unexpected). Thanks in advance!

GillesDuvert commented 1 year ago

@rdimeo thanks for this nice bug report and how to reproduce --- will be cured soon

GillesDuvert commented 1 year ago

@rdimeo I've tested and do not have this behaviour at all. IDL and GDL behave the same. What I get is:

what is your platform ? ( !version and !gdl outputs)

rdimeo commented 1 year ago
GDL> print,!version
{

x64

Windows

Windows

Windows

8.2

Feb 21 2023
      64
      64
}

GDL> print,!gdl
{

1.0.2 Git

Feb 21 2023
  1676955600
   1
   0
   0
}
rdimeo commented 1 year ago

The unusual behavior that I described is repeatable in GDL (for me) but works as expected on IDL.

GillesDuvert commented 1 year ago

Ah, not fully tested under Windows, I'm afraid. wxWidgets may not behave exactly the same under Windows, eventhough they claim to be portable. Strangely, !GDL says it is compiled without wxWidgets ?

GillesDuvert commented 1 year ago

tested with windows 10, I find the same events as above, but text is not edited : that's already one bug.

GillesDuvert commented 1 year ago

Redone test. Apparently with GDL/wxwidgets one can get two '0' with one keystroke (adding a character), so indeed there could be a problem, although the handler is supposed to deal with any type of events and that's should be transparent. .FU seems OK, also. Opening an issue for this .