Tk Source Code

Check-in [70839a22]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Enhance the tests for <<NoManagedChild>>, and fix the implementation so that this event only fires when the last slave is forgotten/removed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip518-event-last-child-unmanaged
Files: files | file ages | folders
SHA3-256: 70839a22b2f60e5693329fa4b7702e217d96d0d02d5fc5e2a397b5a38ad985b6
User & Date: fvogel 2018-10-29 23:01:08
Context
2018-10-30
22:07
Added tests checking that <<NoManagedChild>> fires on destruction of the last managed child check-in: 9ac3dfe7 user: fvogel tags: tip518-event-last-child-unmanaged
2018-10-29
23:01
Enhance the tests for <<NoManagedChild>>, and fix the implementation so that this event only fires when the last slave is forgotten/removed. check-in: 70839a22 user: fvogel tags: tip518-event-last-child-unmanaged
12:52
Tests for virtual event <<NoManagedChild>> check-in: eda5d55d user: oehhar tags: tip518-event-last-child-unmanaged
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkGrid.c.

1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
....
2776
2777
2778
2779
2780
2781
2782



2783
2784
2785
2786
2787

2788
2789
2790
2791
2792
2793
2794
....
3508
3509
3510
3511
3512
3513
3514



3515
3516
3517
3518
3519

3520
3521
3522
3523
3524
3525
3526
    masterPtr->flags &= ~REQUESTED_RELAYOUT;

    /*
     * If the master has no slaves anymore, then don't change the master size.
     * Otherwise there is no way to "relinquish" control over the master
     * so another geometry manager can take over.
     *
     * Sends the event "NoManagedChild" to the master to inform it about there
     * being no managed children inside it.
     */

    if (masterPtr->slavePtr == NULL) {
	TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL);
	return;
    }

    if (masterPtr->masterDataPtr == NULL) {
	return;
    }

................................................................................

    SetGridSize(slavePtr->masterPtr);
    slavePtr->masterPtr = NULL;

    /*
     * If we have emptied this master from slaves it means we are no longer
     * handling it and should mark it as free.



     */

    if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) {
	TkFreeGeometryMaster(masterPtr->tkwin, "grid");
	masterPtr->flags &= ~ALLOCED_MASTER;

    }
}
 
/*
 *----------------------------------------------------------------------
 *
 * DestroyGrid --
................................................................................
	return TCL_ERROR;
    }
    SetGridSize(masterPtr);

    /*
     * If we have emptied this master from slaves it means we are no longer
     * handling it and should mark it as free.



     */

    if (masterPtr->slavePtr == NULL && masterPtr->flags & ALLOCED_MASTER) {
	TkFreeGeometryMaster(masterPtr->tkwin, "grid");
	masterPtr->flags &= ~ALLOCED_MASTER;

    }

    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------






<
<
<



<







 







>
>
>





>







 







>
>
>





>







1731
1732
1733
1734
1735
1736
1737



1738
1739
1740

1741
1742
1743
1744
1745
1746
1747
....
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
....
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
    masterPtr->flags &= ~REQUESTED_RELAYOUT;

    /*
     * If the master has no slaves anymore, then don't change the master size.
     * Otherwise there is no way to "relinquish" control over the master
     * so another geometry manager can take over.



     */

    if (masterPtr->slavePtr == NULL) {

	return;
    }

    if (masterPtr->masterDataPtr == NULL) {
	return;
    }

................................................................................

    SetGridSize(slavePtr->masterPtr);
    slavePtr->masterPtr = NULL;

    /*
     * If we have emptied this master from slaves it means we are no longer
     * handling it and should mark it as free.
     *
     * Send the event "NoManagedChild" to the master to inform it about there
     * being no managed children inside it.
     */

    if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) {
	TkFreeGeometryMaster(masterPtr->tkwin, "grid");
	masterPtr->flags &= ~ALLOCED_MASTER;
	TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL);
    }
}
 
/*
 *----------------------------------------------------------------------
 *
 * DestroyGrid --
................................................................................
	return TCL_ERROR;
    }
    SetGridSize(masterPtr);

    /*
     * If we have emptied this master from slaves it means we are no longer
     * handling it and should mark it as free.
     *
     * Send the event "NoManagedChild" to the master to inform it about there
     * being no managed children inside it.
     */

    if (masterPtr->slavePtr == NULL && masterPtr->flags & ALLOCED_MASTER) {
	TkFreeGeometryMaster(masterPtr->tkwin, "grid");
	masterPtr->flags &= ~ALLOCED_MASTER;
	TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL);
    }

    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------

Changes to generic/tkPack.c.

609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
....
1374
1375
1376
1377
1378
1379
1380



1381
1382
1383
1384
1385

1386
1387
1388
1389
1390
1391
1392
    masterPtr->flags &= ~REQUESTED_REPACK;

    /*
     * If the master has no slaves anymore, then leave the master's size as-is.
     * Otherwise there is no way to "relinquish" control over the master
     * so another geometry manager can take over.
     *
     * Sends the event "NoManagedChild" to the master to inform it about there
     * being no managed children inside it.
     */

    if (masterPtr->slavePtr == NULL) {
	TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL);
	return;
    }

    /*
     * Abort any nested call to ArrangePacking for this window, since we'll do
     * everything necessary here, and set up so this call can be aborted if
     * necessary.
................................................................................
    }

    packPtr->masterPtr = NULL;

    /*
     * If we have emptied this master from slaves it means we are no longer
     * handling it and should mark it as free.



     */

    if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) {
	TkFreeGeometryMaster(masterPtr->tkwin, "pack");
	masterPtr->flags &= ~ALLOCED_MASTER;

    }

}
 
/*
 *----------------------------------------------------------------------
 *






<
<
<



<







 







>
>
>





>







609
610
611
612
613
614
615



616
617
618

619
620
621
622
623
624
625
....
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
    masterPtr->flags &= ~REQUESTED_REPACK;

    /*
     * If the master has no slaves anymore, then leave the master's size as-is.
     * Otherwise there is no way to "relinquish" control over the master
     * so another geometry manager can take over.



     */

    if (masterPtr->slavePtr == NULL) {

	return;
    }

    /*
     * Abort any nested call to ArrangePacking for this window, since we'll do
     * everything necessary here, and set up so this call can be aborted if
     * necessary.
................................................................................
    }

    packPtr->masterPtr = NULL;

    /*
     * If we have emptied this master from slaves it means we are no longer
     * handling it and should mark it as free.
     *
     * Send the event "NoManagedChild" to the master to inform it about there
     * being no managed children inside it.
     */

    if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) {
	TkFreeGeometryMaster(masterPtr->tkwin, "pack");
	masterPtr->flags &= ~ALLOCED_MASTER;
	TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL);
    }

}
 
/*
 *----------------------------------------------------------------------
 *

Changes to tests/grid.test.

2025
2026
2027
2028
2029
2030
2031
2032
2033
2034














2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
    update
    bind . <<NoManagedChild>> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 14.1
} -result {1}















test grid-24.2 {<Configure> does not fire on last grid forget} -body {
    global A
    catch {unset A}
    grid [frame .1]
    update
    bind . <Configure> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <Configure> {}
    grid_reset 14.2
} -result {0}

test grid-24.3 {<Configure> fires on forelast grid forget} -body {
    global A
    catch {unset A}
    grid [frame .1]
    grid [frame .2]
    update
    bind . <Configure> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <Configure> {}
    grid_reset 14.3
} -result {1}

test grid-24.4 {<<NoManagedChild>> does not fire on forelast grid forget} -body {
    global A
    catch {unset A}
    grid [frame .1]
    grid [frame .2]
    update
    bind . <<NoManagedChild>> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 14.4
} -result {0}

test grid-24.5 {<<NoManagedChild>> should not fire on grid anchor} -body {
    global A
    bind . <<NoManagedChild>> {set A 1}
    grid anchor . w
    update
    info exists A
} -cleanup {
    grid anchor . nw
    bind . <<NoManagedChild>> {}
    grid_reset 14.5
} -result {0}

 
# cleanup
cleanupTests
return

# Local Variables:
# mode: tcl
# End:






|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
|










|


|











|


|











|


|








|










2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
    update
    bind . <<NoManagedChild>> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 24.1
} -result {1}

test grid-24.2 {<<NoManagedChild>> fires on last grid remove} -body {
    global A
    catch {unset A}
    grid [frame .1]
    update
    bind . <<NoManagedChild>> {set A 1}
    grid remove .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 24.2
} -result {1}

test grid-24.3 {<Configure> does not fire on last grid forget} -body {
    global A
    catch {unset A}
    grid [frame .1]
    update
    bind . <Configure> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <Configure> {}
    grid_reset 24.3
} -result {0}

test grid-24.4 {<Configure> fires on forelast grid forget} -body {
    global A
    catch {unset A}
    grid [frame .1]
    grid [frame .2]
    update
    bind . <Configure> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <Configure> {}
    grid_reset 24.4
} -result {1}

test grid-24.5 {<<NoManagedChild>> does not fire on forelast grid forget} -body {
    global A
    catch {unset A}
    grid [frame .1]
    grid [frame .2]
    update
    bind . <<NoManagedChild>> {set A 1}
    grid forget .1
    update
    info exists A
} -cleanup {
    bind . <<NoManagedChild>> {}
    grid_reset 24.5
} -result {0}

test grid-24.6 {<<NoManagedChild>> does not fire on grid anchor} -body {
    global A
    bind . <<NoManagedChild>> {set A 1}
    grid anchor . w
    update
    info exists A
} -cleanup {
    grid anchor . nw
    bind . <<NoManagedChild>> {}
    grid_reset 24.6
} -result {0}

 
# cleanup
cleanupTests
return

# Local Variables:
# mode: tcl
# End: