Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#3 Togl coredumps in Togl_MakeCurrent on widget destroy

Run-time
closed-fixed
Greg Couch
None
5
2007-10-24
2000-08-03
Anonymous
No

When Togl destroys a widget, it deletes the current glX/wgl context, but it doesn't set the current context to NULL. That would be fine, if one could then call Togl_MakeCurrent in the user's destroy procedure -- with glX that should call
glXMakeCurrent(display, None, NULL). Unfortunately, the first argument is Tk_Display(togl->TkWin) instead of togl->display, so it coredumps (togl->TkWin is NULL, so Tk_Window(togl->TkWin) will coredump too). The diffs are:

866,867c866,867
< glXMakeCurrent( Tk_Display(togl->TkWin),
< Tk_WindowId(togl->TkWin),
---
> glXMakeCurrent( togl->display,
> togl->TkWin ? Tk_WindowId(togl->TkWin) : None,
870c870,871
< stereoMakeCurrent( Tk_Display(togl->TkWin),
---
> stereoMakeCurrent( togl->display,
> togl->TkWin ? Tk_WindowId(togl->TkWin) : None,

(Your line numbers may vary.)

Looking at the source code, there are many places where Tk_Display(togl->TkWin) could be replaced with togl->display.

Discussion

  • Logged In: NO

    You can also cure tehcrash rather drastically by adding an
    exithandler (in togl.c):

    togl->Ident = NULL;
    togl->Client_Data = DefaultClientData;
    Tcl_CreateExitHandler((Tcl_ExitProc *) toglexitproc,
    (ClientData) togl);

    and the exit handler is:
    static void
    toglexitproc(ClientData clientData)
    { // added gwm feb 2003 to terminate nicely
    Tcl_MutexLock(&preserveMutex);
    printf("In the togl exitproc");
    Tcl_MutexUnlock(&preserveMutex);
    exit(1); // and this prevents the crash!
    }

    this terminates with extreme nastiness TCL, but it does
    prevent the annoying crashes.
    Geoff

     
  • Greg Couch
    Greg Couch
    2007-10-24

    Logged In: YES
    user_id=131838
    Originator: NO

    Fixed in version 2.0 (next release).

     
  • Greg Couch
    Greg Couch
    2007-10-24

    • status: open --> closed-fixed