public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Patch to fix canvas related crash in libgui
@ 2002-11-27 10:58 Mo DeJong
  0 siblings, 0 replies; only message in thread
From: Mo DeJong @ 2002-11-27 10:58 UTC (permalink / raw)
  To: Insight

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 ));

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-27 18:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-27 10:58 Patch to fix canvas related crash in libgui Mo DeJong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).