public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: Mo DeJong <mdejong@uncounted.org>
To: Insight <insight@sources.redhat.com>
Subject: Patch to fix canvas related crash in libgui
Date: Wed, 27 Nov 2002 10:58:00 -0000	[thread overview]
Message-ID: <20021127110007.39b62f79.mdejong@uncounted.org> (raw)

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

                 reply	other threads:[~2002-11-27 18:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021127110007.39b62f79.mdejong@uncounted.org \
    --to=mdejong@uncounted.org \
    --cc=insight@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).