For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > September 2004 > Re: Problem with HList









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Problem with HList
Nick Ing-Simmons

2004-09-20, 9:03 am

This is a multi-part message in MIME format...

------------=_1095671865-3987-0
Content-Disposition: inline
Content-transfer-encoding: quoted-printable
Content-type: text/plain; charset="UTF-8"

Dave Scheck <dave.scheck@motorola.com> writes:
>Nick
>
>I came across an interesting problem with HList today. I googled around=

=20
>and came across very little and hoped that you might have a solution.=20=

=20
>Below is some test code that illustrates the problem.
>
>use strict;
>use Tk;
>require Tk::HList;
>
>my $top =3D MainWindow->new();
>my $list =3D $top->HList()->pack(-fill =3D> 'both',-expand =3D> 1);
>
>$list->add(0,-text =3D> "Line 0");
>$list->add(2,-text =3D> "Line 2");
>$list->add(1,-before =3D> 2,-text =3D> "Line 1");
>
>MainLoop;


The abort() is called because the Tix code that handles -before
tries to modify arg-list in place but tk8.4 API has arg list=20
as=20

Tcl_Obj *const *objv;

So that would not be allowed by the compiler.

It was marked (by me as FIXME) which the attached patch does.

>
>The output that I get is
>Abort
>
>It looks like the ABORT signal is being thrown, but I don't understand why.
>
>I am using Perl v5.8.3 and Tk 804.025 on Solaris 5.6
>
>Thanks for your help
>Dave



------------=_1095671865-3987-0
Content-Type: text/plain; charset="US-ASCII"; name="patch"
Content-Disposition: inline; filename="patch"
Content-Transfer-Encoding: quoted-printable

--- pTk/mTk/tixGeneric/tixHList.c.ship 2004-09-20 10:16:36.347152188 +0100
+++ pTk/mTk/tixGeneric/tixHList.c 2004-09-20 10:15:30.557194005 +0100
@@ -266,7 +266,7 @@
static void FreeElement _ANSI_ARGS_((WidgetPtr wPtr,
HListElement * chPtr));
static HListElement * NewElement _ANSI_ARGS_((Tcl_Interp *interp,
- WidgetPtr wPtr, int argc, char ** argv,
+ WidgetPtr wPtr, int argc, Tcl_Obj **objv,
char * pathName, char * defParentName,
int * newArgc));
static void RedrawWhenIdle _ANSI_ARGS_((WidgetPtr wPtr));
@@ -598,28 +598,39 @@
WidgetPtr wPtr =3D (WidgetPtr) clientData;
HListElement * chPtr;
char * pathName =3D argv[0];
+ Tcl_Obj **cObjv =3D (Tcl_Obj **) ckalloc(argc*sizeof(Tcl_Obj *));
+ int i;
=20
argc --;
argv ++;
=20
- if ((chPtr =3D NewElement(interp, wPtr, argc, argv, pathName,
+ for (i=3D0; i <=3D argc; i++)
+ {
+ cObjv[i] =3D objv[i];
+ }
+
+ if ((chPtr =3D NewElement(interp, wPtr, argc, cObjv, pathName,
NULL, &argc)) =3D=3D NULL) {
+ ckfree((char *)cObjv);
return TCL_ERROR;
}
=20
if (argc > 0) {
- if (ConfigElement(wPtr, chPtr, argc, argv, 0, 1) !=3D TCL_OK) {
+ if (ConfigElement(wPtr, chPtr, argc, cObjv, 0, 1) !=3D TCL_OK) {
DeleteNode(wPtr, chPtr);
+ ckfree((char *)cObjv);
return TCL_ERROR;
}
} else {
if (Tix_DItemConfigure(chPtr->col[0].iPtr, 0, 0, 0) !=3D TCL_OK) {
DeleteNode(wPtr, chPtr);
+ ckfree((char *)cObjv);
return TCL_ERROR;
}
}
=20
Tcl_AppendResult(interp, chPtr->pathName, NULL);
+ ckfree((char *)cObjv);
return TCL_OK;
}
=20
@@ -642,6 +653,8 @@
WidgetPtr wPtr =3D (WidgetPtr) clientData;
HListElement * chPtr;
char * parentName;
+ Tcl_Obj **cObjv =3D (Tcl_Obj **) ckalloc(argc*sizeof(Tcl_Obj *));
+ int i;
=20
parentName =3D argv[0];
if (argv[0] && strcmp(argv[0], "") =3D=3D 0) {
@@ -650,24 +663,34 @@
=20
argc --;
argv ++;
- if ((chPtr =3D NewElement(interp, wPtr, argc, argv, NULL,
+
+ for (i=3D0; i <=3D argc; i++)
+ {
+ cObjv[i] =3D objv[i];
+ }
+
+ if ((chPtr =3D NewElement(interp, wPtr, argc, cObjv, NULL,
parentName, &argc)) =3D=3D NULL) {
+ ckfree((char *)cObjv);
return TCL_ERROR;
}
=20
if (argc > 0) {
if (ConfigElement(wPtr, chPtr, argc, argv, 0, 1) !=3D TCL_OK) {
DeleteNode(wPtr, chPtr);
+ ckfree((char *)cObjv);
return TCL_ERROR;
}
} else {
if (Tix_DItemConfigure(chPtr->col[0].iPtr, 0, 0, 0) !=3D TCL_OK) {
DeleteNode(wPtr, chPtr);
+ ckfree((char *)cObjv);
return TCL_ERROR;
}
}
=20
Tcl_AppendResult(interp, chPtr->pathName, NULL);
+ ckfree((char *)cObjv);
return TCL_OK;
}
=20
@@ -2729,11 +2752,11 @@
*--------------------------------------------------------------
*/
static HListElement *
-NewElement(interp, wPtr, argc, argv, pathName, defParentName, newArgc)
+NewElement(interp, wPtr, argc, objv, pathName, defParentName, newArgc)
Tcl_Interp *interp;
WidgetPtr wPtr;
int argc;
- Tcl_Obj *CONST *objv;
+ Tcl_Obj **objv;
char * pathName; /* Default pathname, if -pathname is not
* specified in the options */
char * defParentName; /* Default parent name (will NULL if pathName
@@ -2806,13 +2829,8 @@
=20
copy:
if (n!=3Di) {
-#if 0
- /* FIXME */
objv[n] =3D objv[i];
objv[n+1] =3D objv[i+1];
-#else
- abort();
-#endif
}
n+=3D2;
}

------------=_1095671865-3987-0--
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com