Itcl - the [incr Tcl] extension

Changes On Branch bug-8e632ce049
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-8e632ce049 Excluding Merge-Ins

This is equivalent to a diff from c2637b44af to 6e1142ec9f

2019-11-26
13:45
fixes leak [8e632ce049], integrate branch bug-8e632ce049 check-in: da8e02393b user: sebres tags: trunk
13:43
fixed leak (bug [8e632ce049]), always call paired release in ItclAfterCallMethod for every preserve of ItclCheckCallMethod (moved outside of wrong if block). Closed-Leaf check-in: 6e1142ec9f user: sebres tags: bug-8e632ce049
13:36
bug [8e632ce049] - added test case covering leak check-in: 590d935e41 user: sebres tags: bug-8e632ce049
2019-11-20
16:39
TEA update check-in: c2637b44af user: dgp tags: trunk, itcl-4-2-0
2019-11-05
15:46
amend to [48d5801f5a]: remove header declaration check-in: 6fae71f276 user: sebres tags: trunk

Changes to generic/itclMethod.c.
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
    } else {
	stackPtr = (Itcl_Stack *)Tcl_GetHashValue(hPtr);
    }

    Itcl_PushStack(framePtr, stackPtr);

    if (ioPtr != NULL) {
        ioPtr->callRefCount++;
	Itcl_PreserveData(ioPtr);
    }
    imPtr->iclsPtr->callRefCount++;
    if (!imPtr->iclsPtr->infoPtr->useOldResolvers) {
        Itcl_SetCallFrameResolver(interp, ioPtr->resolvePtr);
    }
    result = TCL_OK;








|
|







2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
    } else {
	stackPtr = (Itcl_Stack *)Tcl_GetHashValue(hPtr);
    }

    Itcl_PushStack(framePtr, stackPtr);

    if (ioPtr != NULL) {
	ioPtr->callRefCount++;
	Itcl_PreserveData(ioPtr); /* ++ preserve until ItclAfterCallMethod releases it */
    }
    imPtr->iclsPtr->callRefCount++;
    if (!imPtr->iclsPtr->infoPtr->useOldResolvers) {
        Itcl_SetCallFrameResolver(interp, ioPtr->resolvePtr);
    }
    result = TCL_OK;

2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578




2579
2580
2581
2582
2583
2584
2585
    if (callContextPtr->refCount-- <= 1) {
        if (callContextPtr->ioPtr != NULL) {
	    hPtr = Tcl_FindHashEntry(&callContextPtr->ioPtr->contextCache,
	            (char *)callContextPtr->imPtr);
            if (hPtr == NULL) {
                ckfree((char *)callContextPtr);
	    }
	    Itcl_ReleaseData(ioPtr);
        } else {
            ckfree((char *)callContextPtr);
        }
    }




    result = call_result;
finishReturn:
    Itcl_ReleaseData(imPtr);
    return result;
}

void







<




>
>
>
>







2567
2568
2569
2570
2571
2572
2573

2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
    if (callContextPtr->refCount-- <= 1) {
        if (callContextPtr->ioPtr != NULL) {
	    hPtr = Tcl_FindHashEntry(&callContextPtr->ioPtr->contextCache,
	            (char *)callContextPtr->imPtr);
            if (hPtr == NULL) {
                ckfree((char *)callContextPtr);
	    }

        } else {
            ckfree((char *)callContextPtr);
        }
    }

    if (ioPtr != NULL) {
	Itcl_ReleaseData(ioPtr); /* -- paired release for preserve in ItclCheckCallMethod */
    }
    result = call_result;
finishReturn:
    Itcl_ReleaseData(imPtr);
    return result;
}

void
Changes to tests/methods.test.
149
150
151
152
153
154
155
















156
157
158
159
160
161
162
            proc leakProc {} { set n 1 }
	}
	LeakClass::leakProc
	::itcl::delete class LeakClass
    }
    list 0
} 0

















# ----------------------------------------------------------------------
#  Clean up
# ----------------------------------------------------------------------
itcl::delete class test_args

::tcltest::cleanupTests







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
            proc leakProc {} { set n 1 }
	}
	LeakClass::leakProc
	::itcl::delete class LeakClass
    }
    list 0
} 0
test methods-2.2 {covers leak condition test for nested methods calls within eval, bug [8e632ce049]} -setup {
    itcl::class C1 {
	proc factory {} {
	    set obj [C1 #auto]
	    $obj myeval [list $obj read]
	    itcl::delete object $obj
	}
	method myeval {script} { eval $script }
	method read {} { myeval {} }
    }
} -body {
    time { C1::factory } 50
    list 0
} -result 0 -cleanup {
    itcl::delete class C1
}

# ----------------------------------------------------------------------
#  Clean up
# ----------------------------------------------------------------------
itcl::delete class test_args

::tcltest::cleanupTests