Skip to content

Commit eaaba21

Browse files
author
jan.nijtmans
committed
Merge trunk
2 parents 9cabd11 + 5a07921 commit eaaba21

6 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎README‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ We are very interested in receiving bug reports, patches, and suggestions
4343
for improvements. We prefer that you send this information to us via the
4444
bug database, rather than emailing us directly. The bug database is at:
4545

46-
https://core.tcl.tk/itcl/ticket
46+
https://core.tcl-lang.org/itcl/ticket
4747

4848
We will log and follow-up on each bug, although we cannot promise a
4949
specific turn-around time. Enhancements, reported via the Feature

‎generic/itclBuiltin.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,7 @@ ItclExtendedCget(
27082708
result = Tcl_EvalObjv(interp, objc+1, newObjv, TCL_EVAL_DIRECT);
27092709
Tcl_DecrRefCount(newObjv[0]);
27102710
Tcl_DecrRefCount(newObjv[1]);
2711+
Tcl_Free(newObjv);
27112712
Tcl_DecrRefCount(objPtr);
27122713
if (oPtr != NULL) {
27132714
infoPtr->currContextIclsPtr = NULL;
@@ -3155,6 +3156,7 @@ Itcl_BiDestroyCmd(
31553156
Tcl_DecrRefCount(newObjv[2]);
31563157
Tcl_DecrRefCount(newObjv[1]);
31573158
Tcl_DecrRefCount(newObjv[0]);
3159+
Tcl_Free(newObjv);
31583160
return result;
31593161
}
31603162
if (objc != 1) {
@@ -3305,6 +3307,7 @@ Itcl_BiGetInstanceVarCmd(
33053307
memcpy(newObjv + 1, objv + 2, sizeof(Tcl_Obj *) * (objc - 2));
33063308
result = Tcl_EvalObjv(interp, objc - 1, newObjv, 0);
33073309
Tcl_DecrRefCount(newObjv[0]);
3310+
Tcl_Free(newObjv);
33083311
return result;
33093312
}
33103313
/*

‎generic/itclMigrate2TclCore.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Itcl_SetCallFrameResolver(
2828
#ifdef ITCL_USE_MODIFIED_TCL_H
2929
framePtr->isProcCallFrame |= FRAME_HAS_RESOLVER;
3030
framePtr->resolvePtr = resolvePtr;
31-
#elif defined(__cplusplus)
31+
#else
3232
(void)resolvePtr;
3333
#endif
3434
return TCL_OK;
@@ -46,7 +46,7 @@ _Tcl_SetNamespaceResolver(
4646
}
4747
#ifdef ITCL_USE_MODIFIED_TCL_H
4848
((Namespace *)nsPtr)->resolvePtr = resolvePtr;
49-
#elif defined(__cplusplus)
49+
#else
5050
(void)resolvePtr;
5151
#endif
5252
return TCL_OK;

‎generic/itclObject.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,10 @@ ItclCreateObject(
557557
}
558558

559559
Itcl_RenameCommand(interp, objName, name);
560-
ioPtr->createNamePtr = NULL;
560+
if (ioPtr->createNamePtr != NULL) {
561+
Tcl_DecrRefCount(ioPtr->createNamePtr);
562+
ioPtr->createNamePtr = NULL;
563+
}
561564
Tcl_TraceCommand(interp, Tcl_GetString(ioPtr->namePtr),
562565
TCL_TRACE_RENAME|TCL_TRACE_DELETE, ObjectRenamedTrace, ioPtr);
563566
}
@@ -679,6 +682,14 @@ ItclCreateObject(
679682
* Destroy the "constructed" table in the object data, since
680683
* it is no longer needed.
681684
*/
685+
if (saveNsNamePtr) {
686+
/*
687+
* A widget keeps the new value of ::itcl::internal::varNsName, only
688+
* release the saved previous one.
689+
*/
690+
Tcl_DecrRefCount(saveNsNamePtr);
691+
saveNsNamePtr = NULL;
692+
}
682693
if (infoPtr != NULL) {
683694
infoPtr->currIoPtr = saveCurrIoPtr;
684695
}
@@ -2265,6 +2276,7 @@ ItclTraceSelfVar(
22652276
"itcl_hull", NULL, contextIoPtr,
22662277
contextIoPtr->iclsPtr);
22672278
if (strlen(objectName) == 0) {
2279+
Tcl_DecrRefCount(objPtr);
22682280
objPtr = contextIoPtr->namePtr;
22692281
Tcl_IncrRefCount(objPtr);
22702282
} else {

‎generic/itclParse.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,11 @@ ItclGenericClassCmd(
577577
if (PTR2INT(Tcl_GetHashValue(hPtr)) == ITCL_WIDGETADAPTOR) {
578578
/* create the itcl_hull variable */
579579
namePtr = Tcl_NewStringObj("itcl_hull", TCL_INDEX_NONE);
580-
if (ItclCreateComponent(interp, iclsPtr, namePtr, ITCL_COMMON,
581-
&icPtr) != TCL_OK) {
580+
Tcl_IncrRefCount(namePtr);
581+
result = ItclCreateComponent(interp, iclsPtr, namePtr, ITCL_COMMON,
582+
&icPtr);
583+
Tcl_DecrRefCount(namePtr);
584+
if (result != TCL_OK) {
582585
return TCL_ERROR;
583586
}
584587
iclsPtr->numVariables++;

‎tests/helpers.tcl‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,21 @@ if {[namespace which -command memory] ne "" && (
3838
i eval {package require tcltest; @testargv@}
3939
i eval [list source -encoding utf-8 @test@]
4040
interp delete i
41+
# Process the window events of a deleted Tk application; until
42+
# then they hold memory, which would be counted as leaked.
43+
update
4144
}]]
4245
if {$leak} {
4346
puts "LEAKED: $leak bytes"
4447
}
4548
}
4649
itcl_leaktest [info script]
50+
# The test file may have loaded Tk in this interpreter (to set its tk
51+
# constraint) before calling loadTestedCommands. Destroy its main
52+
# window, or the application would wait in the Tk event loop when the
53+
# script ends.
54+
if {[info commands ::destroy] ne ""} {
55+
destroy .
56+
}
4757
return -code return
4858
}

0 commit comments

Comments
 (0)