From b0ebecfc8a6389443e6528e48fcf548417dcce2b Mon Sep 17 00:00:00 2001 From: lecoanet Date: Wed, 19 May 2004 13:03:31 +0000 Subject: ZnGLMakeCurrent: Added code to select a valid context from the widget list for the display when no widget is passed in. This is the case when freeing image or font texture. Enabled the context freeing for the last widget on a given display. Both patches together should fix the crash on MacOS. --- generic/tkZinc.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'generic/tkZinc.c') diff --git a/generic/tkZinc.c b/generic/tkZinc.c index 88b10d9..b065698 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -916,19 +916,30 @@ ZnGLMakeCurrent(Display *dpy, ZnGLContextEntry *ce; ce = ZnGetGLContext(dpy); -#ifdef _WIN32 if (!wi) { /* Get a zinc widget from the context struct * for this display. If no more are left, * returns, nothing can be done. This can - * happend only when freeing images or fonts + * happen only when freeing images or fonts * after the last zinc on a given display has - * been deleted. In this case the context has - * been already deleted, freeing all resources - * including textures. + * been deleted. In this case the context should + * be deleted, freeing all resources including + * textures. */ - return NULL; + ZnWInfo **wip = ZnListArray(ce->widgets); + int i, num = ZnListSize(ce->widgets); + + for (i = 0; i win != NULL) { + wi = *wip; + break; + } + } + if (!wi) { + return NULL; + } } +#ifdef _WIN32 ce->hwnd = Tk_GetHWND(Tk_WindowId(wi->win)); ce->hdc = GetDC(ce->hwnd); SetPixelFormat(ce->hdc, ce->ipixel, &ce->pfd); @@ -937,8 +948,7 @@ ZnGLMakeCurrent(Display *dpy, fprintf(stderr, "Can't make the GL context current: %d\n", GetLastError()); } #else - glXMakeCurrent(dpy, wi?Tk_WindowId(wi->win):DefaultRootWindow(dpy), - ce->context); + glXMakeCurrent(dpy, Tk_WindowId(wi->win), ce->context); #endif return ce; } @@ -8075,7 +8085,7 @@ Destroy(char *mem_ptr) /* Info about the widget. */ * though). Thus it has been limited to WIN for * the time being. */ -#ifdef _WIN32 +#if 1 /*def _WIN32*/ if (ZnListSize(ce->widgets) == 0) { ZnGLContextEntry *prev, *next; /*printf("Freeing a GL context\n");*/ -- cgit v1.1