aboutsummaryrefslogtreecommitdiff
path: root/generic/tkZinc.c
diff options
context:
space:
mode:
authorlecoanet2004-05-19 13:03:31 +0000
committerlecoanet2004-05-19 13:03:31 +0000
commitb0ebecfc8a6389443e6528e48fcf548417dcce2b (patch)
tree193ac64fbf4aac4cda0960067b1b481ce40eafeb /generic/tkZinc.c
parentf18b60fbc6fb09ac51d40bb2240b75a315826d80 (diff)
downloadtkzinc-b0ebecfc8a6389443e6528e48fcf548417dcce2b.zip
tkzinc-b0ebecfc8a6389443e6528e48fcf548417dcce2b.tar.gz
tkzinc-b0ebecfc8a6389443e6528e48fcf548417dcce2b.tar.bz2
tkzinc-b0ebecfc8a6389443e6528e48fcf548417dcce2b.tar.xz
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.
Diffstat (limited to 'generic/tkZinc.c')
-rw-r--r--generic/tkZinc.c28
1 files changed, 19 insertions, 9 deletions
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 <num; i++, wip++) {
+ if ((*wip)->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");*/