This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Patch to fix canvas related crash in libgui
- From: Mo DeJong <mdejong at uncounted dot org>
- To: Insight <insight at sources dot redhat dot com>
- Date: Wed, 27 Nov 2002 11:00:07 -0800
- Subject: Patch to fix canvas related crash in libgui
This patch fixes the ide_print_canvas and ide_print_text commands, which do
not appear to be used by Insight. It does stop Source-Navigator from crashing
though.
cheers
Mo
2002-11-26 Mo DeJong <mdejong@uncounted.org>
* src/tkWinPrintCanvas.c (PrintCanvasCmd):
* src/tkWinPrintText.c (PrintTextCmd): Check to
see if the Tcl command is object based and access
objClientData instead of clientData if it is.
Raise an error if the widget was never mapped.
This fixes a crash when printing canvas objects
under Windows.
Index: libgui/src/tkWinPrintCanvas.c
===================================================================
RCS file: /cvs/src/src/libgui/src/tkWinPrintCanvas.c,v
retrieving revision 1.4
diff -u -r1.4 tkWinPrintCanvas.c
--- libgui/src/tkWinPrintCanvas.c 8 Sep 2001 22:34:48 -0000 1.4
+++ libgui/src/tkWinPrintCanvas.c 27 Nov 2002 06:55:08 -0000
@@ -78,8 +78,22 @@
sprintf((char*)lpdi->lpszDocName,"SN - Printing\0");
lpdi->lpszOutput=NULL;
- canvasPtr = (TkCanvas *)(canvCmd.clientData);
- tkwin = canvasPtr->tkwin;
+ /*
+ * Canvas was objectified in Tk 8.3, keep backwards compatibility.
+ */
+
+ if (canvCmd.isNativeObjectProc)
+ canvasPtr = (TkCanvas *)(canvCmd.objClientData);
+ else
+ canvasPtr = (TkCanvas *)(canvCmd.clientData);
+
+ tkwin = canvasPtr->tkwin;
+ /* Can't print unless we have a native window */
+ if (Tk_WindowId(tkwin) == None) {
+ Tcl_AppendResult(interp, "canvas was never mapped" , (char *) NULL);
+ goto error;
+ }
+
memset(&pd,0,sizeof( PRINTDLG ));
pd.lStructSize = sizeof( PRINTDLG );
pd.hwndOwner = NULL;
Index: libgui/src/tkWinPrintText.c
===================================================================
RCS file: /cvs/src/src/libgui/src/tkWinPrintText.c,v
retrieving revision 1.5
diff -u -r1.5 tkWinPrintText.c
--- libgui/src/tkWinPrintText.c 8 Sep 2001 22:34:48 -0000 1.5
+++ libgui/src/tkWinPrintText.c 27 Nov 2002 06:55:08 -0000
@@ -277,7 +277,7 @@
}
/*
- * The second arg is the canvas widget.
+ * The second arg is the text widget.
*/
if (!Tcl_GetCommandInfo(interp, argv[1], &textCmd)) {
Tcl_AppendResult(interp, "couldn't get text information for \"",
@@ -295,9 +295,22 @@
sprintf((char*)lpdi->lpszDocName,"SN - Printing\0");
lpdi->lpszOutput=NULL;
- textPtr = (TkText *)(textCmd.clientData);
+ /*
+ * Maintain compatibility if/when text is objectified.
+ */
+
+ if (textCmd.isNativeObjectProc)
+ textPtr = (TkText *)(textCmd.objClientData);
+ else
+ textPtr = (TkText *)(textCmd.clientData);
tkwin = textPtr->tkwin;
+ /* Can't print unless we have a native window */
+ if (Tk_WindowId(tkwin) == None) {
+ Tcl_AppendResult(interp, "text was never mapped" , (char *) NULL);
+ goto error;
+ }
+
dInfoPtr = textPtr->dInfoPtr;
dlPtr=dInfoPtr->dLinePtr;
memset(&pd,0,sizeof( PRINTDLG ));