From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15452 invoked by alias); 27 Nov 2002 18:58:25 -0000 Mailing-List: contact insight-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sources.redhat.com Received: (qmail 15445 invoked from network); 27 Nov 2002 18:58:23 -0000 Received: from unknown (HELO mta6.snfc21.pbi.net) (206.13.28.240) by sources.redhat.com with SMTP; 27 Nov 2002 18:58:23 -0000 Received: from modrick ([66.120.11.181]) by mta6.snfc21.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with SMTP id <0H6900GQU0P977@mta6.snfc21.pbi.net> for insight@sources.redhat.com; Wed, 27 Nov 2002 10:58:22 -0800 (PST) Date: Wed, 27 Nov 2002 10:58:00 -0000 From: Mo DeJong Subject: Patch to fix canvas related crash in libgui To: Insight Message-id: <20021127110007.39b62f79.mdejong@uncounted.org> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-SW-Source: 2002-q4/txt/msg00124.txt.bz2 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 * 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 ));