FLTK logo

Re: [fltk.coredev] Windows 11 crash (still investigating)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Windows 11 crash (still investigating) "'Albrecht Schlosser' via fltk.coredev" 15:46 Apr 28  
  On 4/28/24 20:18 Gonzalo Garramuño wrote:

On 28/4/24 12:13, 'Albrecht Schlosser' via fltk.coredev wrote:

OK, thanks for confirmation. Can you try my patch (code above) ?

Tried it.  Seems to fix Windows, Wayland and XWayland (did not try macOS and X11 yet but I am guessing they should be fine too).


Thanks for testing it. It's basically your "patch" with minor modifications.

I'll give it another review tomorrow and I will very likely commit it. I'm pretty sure that the patch itself is correct but I still don't understand everything that leads to this situation. Your example code is a good reproducer and was very helpful in analyzing the issue (more to come tomorrow).

One bug of your program (and I call it a bug because it causes a kind of undefined behavior) can be seen in a comment in your example code:

Timeline(int X, int Y, int W, int H, const char* L = 0) :
Fl_Gl_Window(X, Y, W, H, L)
{
//Fl_Group::current(0); // adding this seems to make it not crash [1]
thumbnailWindow = new Fl_Double_Window(120, Y - 100, 128, 80); [2]
thumbnailWindow->clear_border();
thumbnailWindow->set_non_modal(); [3]
thumbnailWindow->begin();
Fl_Box* box = new Fl_Box(2, 2, 120 - 2, 80 - 2);
box->box(FL_FLAT_BOX);
box->color(FL_BLACK);
thumbnailWindow->end(); [4]
end(); [5]
}

    
[1] You should really enable this statement to make sure that `thumbnailWindow` does not become a child (subwindow) of the Timeline (Fl_Gl_)Window.

[2] Since the constructor of 
Fl_Gl_Window ends with `begin();` as all group widgets do the following `thumbnailWindow` will become a child if you don't enable the statement above. Alternative code after the c'tor of thumbnailWindow:
  if (parent()) parent()->remove(this);
but this is IMHO the less elegant solution.

[3] 
set_non_modal() should only be used on top-level windows and makes the window stay above its base window (in Z order). In FLTK this relation is determined when the modal or non-modal window is shown: the active window becomes its base (or "parent") window as far as the system is concerned. Unfortunately we can't affect this order by any other means.

[4] This is correct but superfluous, because it is followed by `end();` [5]

[5] This end()'s the `Timeline` window which does not really do what everybody expects. What it really does is
Fl_Group::current([this->]parent()), i.e. it makes the parent of the Timeline widget the new "current group". In your code environment (in the test program) this would be correct if ... you didn't enable the statement in [1]. Therefore you would have to use `win.begin()` in your main program if you intended to add other widgets after the timeline. This is not the case in your demo program but may well be in your real program.


As you wrote yourself "adding this seems to make it not crash", and as I wrote above, this would be better because it prevents making the "non-modal" `thumbnailWindow` a subwindow of your main window. I'm not sure if it is documented that subwindows and { modal | non-modal } are mutually exclusive (IMHO this must be the case).

However, there are still some things I do not yet fully understand when it comes to event delivery of FL_LEAVE events and hiding the non-modal subwindow. In my tests I could only trigger the NULL pointer dereference (the patched code in Fl_Window) when I dragged the mouse (timeline) to the right out of the window. It does not happen when the mouse leaves the timeline to any other direction (up, down, and including to the left side). But that is internal stuff and should not affect you and your program.

Summary:
(1) You should fix your program (see above) and ...
(2) I will fix the potential NULL pointer dereference.

Good night from here

Albrecht

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/04eccf9a-2eb7-4459-afac-bbdcb783c765%40aljus.de.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.