On 26/03/11 00:32, Manolo Gouy wrote:

[STR Closed w/Resolution]

Link: http://www.fltk.org/str.php?L2595
Version: 1.3.0
Fix Version: 1.3.0 (r8534)


Fixed in Subversion repository.

This bug was not OpenGL-related, nor Cocoa-related. It occurs
replacing GL subwindows by Fl_Window in your test program, and with
last year's Carbon FLTK 1.3 version.


Ok! Many thanks for your patch: it fixes the crash.

There's one weird side effect when using GL subwindows, though: if you draw a string in the GL window before deleting it, and you draw the same string in the new GL window that replaces it, the string is drawn as a solid color rectangle.

I guess there's a caching issue (are the textures e.g. linked to a given GL context via a display list)?

Attached is a small example that shows the problem.



The bug was: when attempting to delete a subwindow, the code
did not detect it's a subwindow, so deletes the window OS structure
that is in fact its parent's. Later, the OS accesses the parent
window structure, that has just been deleted.

Thus, the issue is "How to detect that I'm dealing with a subwindow
when I want to delete it and when the link to its parent has been
already removed ?"

I have implemented this: make sure that none of the windows
of the window list shares the same OS window (xid) as ours.

Is there a more direct way to do it ?


Link: http://www.fltk.org/str.php?L2595
Version: 1.3.0
Fix Version: 1.3.0 (r8534)


// compile with "fltk-config --use-gl --compile gldelete.cpp"
//
// run code, then press 'd'
// - expected behaviour: the opengl window is deleted and replaced 
//   with a new one
// - observed behaviour: code crashes

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Tile.H>
#include <FL/Fl_Gl_Window.H>
#include <FL/gl.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif

class openglWindow : public Fl_Gl_Window{
public:
  openglWindow(int x, int y, int w, int h) : Fl_Gl_Window(x, y, w, h){}
  void draw()
  {
    glClearColor(0.5, 0.3, 0.8, 0.);
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    glRasterPos2d(0, 0);
    gl_draw("A string");
  }
};

Fl_Tile *tile;

int shortcuts(int event)
{
  if(Fl::test_shortcut('d')){
    tile->clear();
    
    openglWindow *gl = new openglWindow(0, 0, 400, 400);
    gl->end();
    gl->mode(FL_RGB | FL_DEPTH | FL_DOUBLE);
    tile->add(gl);
    gl->show();
  }
  return 1;
}

int main(int argc, char **argv)
{
  Fl_Window *win = new Fl_Window(0, 0, 400, 400);
  tile = new Fl_Tile(0, 0, 400, 400);
  openglWindow *gl = new openglWindow(0, 0, 400, 400);
  gl->end();
  gl->mode(FL_RGB | FL_DEPTH | FL_DOUBLE);
  tile->end();
  win->end();
  win->show(argc, argv);
  Fl::add_handler(shortcuts);
  Fl::run();
}
_______________________________________________
fltk-bugs mailing list
fltk-bugs@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to