Tk Source Code

Check-in [b5918b5b]
Login

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

Overview
Comment:[Bug 3588824]: bug in image index handling for weird image names
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b5918b5b9e6c6b2f436a8476134a090a13c1fc52
User & Date: dgp 2012-12-04 17:02:22
Context
2012-12-06
14:01
Force the use of the correct internal function for parsing hex colors rather than leaving it to the vagaries of the system library (buggy on some versions of MinGW apparently). check-in: b0b867db user: dkf tags: trunk
2012-12-04
19:59
merge trunk check-in: ab4678a0 user: dgp tags: core-8-6-0-rc
17:02
[Bug 3588824]: bug in image index handling for weird image names check-in: b5918b5b user: dgp tags: trunk
16:37
[Bug 3588824]: bug in image index handling for weird image names check-in: 22d3368e user: dgp tags: core-8-5-branch
2012-12-03
01:22
merge-mark check-in: b7d2e2b8 user: fvogel tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7





2012-11-14  Jan Nijtmans  <[email protected]>

	* win/tkWinDialog.c: [Bug 3500545]: tk_getOpenFile -multiple 1 wrong
	on windows

2012-11-11  Jan Nijtmans  <[email protected]>

>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2012-12-04  Francois Vogel  <[email protected]>

	* generic/tkTextIndex.c: [Bug 3588824]: bug in image index handling
	* tests/textIndex.test:  for weird image names

2012-11-14  Jan Nijtmans  <[email protected]>

	* win/tkWinDialog.c: [Bug 3500545]: tk_getOpenFile -multiple 1 wrong
	on windows

2012-11-11  Jan Nijtmans  <[email protected]>

Changes to generic/tkTextImage.c.

781
782
783
784
785
786
787




788
789
790
791
792
793
794
TkTextImageIndex(
    TkText *textPtr,		/* Text widget containing image. */
    const char *name,		/* Name of image. */
    TkTextIndex *indexPtr)	/* Index information gets stored here. */
{
    Tcl_HashEntry *hPtr;
    TkTextSegment *eiPtr;





    hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->imageTable, name);
    if (hPtr == NULL) {
	return 0;
    }
    eiPtr = Tcl_GetHashValue(hPtr);
    indexPtr->tree = textPtr->sharedTextPtr->tree;







>
>
>
>







781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
TkTextImageIndex(
    TkText *textPtr,		/* Text widget containing image. */
    const char *name,		/* Name of image. */
    TkTextIndex *indexPtr)	/* Index information gets stored here. */
{
    Tcl_HashEntry *hPtr;
    TkTextSegment *eiPtr;

    if (textPtr == NULL) {
	return 0;
    }

    hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->imageTable, name);
    if (hPtr == NULL) {
	return 0;
    }
    eiPtr = Tcl_GetHashValue(hPtr);
    indexPtr->tree = textPtr->sharedTextPtr->tree;

Changes to generic/tkTextIndex.c.

756
757
758
759
760
761
762
763

764

765
766
767
768
769
770
771








772
773
774
775
776
777
778

    if (sharedPtr == NULL) {
	sharedPtr = textPtr->sharedTextPtr;
    }

    /*
     *---------------------------------------------------------------------
     * Stage 1: check to see if the index consists of nothing but a mark name.

     * We do this check now even though it's also done later, in order to

     * allow mark names that include funny characters such as spaces or "+1c".
     *---------------------------------------------------------------------
     */

    if (TkTextMarkNameToIndex(textPtr, string, indexPtr) == TCL_OK) {
	goto done;
    }









    /*
     *------------------------------------------------
     * Stage 2: start again by parsing the base index.
     *------------------------------------------------
     */








|
>
|
>
|






>
>
>
>
>
>
>
>







756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788

    if (sharedPtr == NULL) {
	sharedPtr = textPtr->sharedTextPtr;
    }

    /*
     *---------------------------------------------------------------------
     * Stage 1: check to see if the index consists of nothing but a mark
     * name, an embedded window or an embedded image.  We do this check
     * now even though it's also done later, in order to allow mark names,
     * embedded window names or image names that include funny characters
     * such as spaces or "+1c".
     *---------------------------------------------------------------------
     */

    if (TkTextMarkNameToIndex(textPtr, string, indexPtr) == TCL_OK) {
	goto done;
    }

    if (TkTextWindowIndex(textPtr, string, indexPtr) != 0) {
	return TCL_OK;
    }

    if (TkTextImageIndex(textPtr, string, indexPtr) != 0) {
	return TCL_OK;
    }

    /*
     *------------------------------------------------
     * Stage 2: start again by parsing the base index.
     *------------------------------------------------
     */

Changes to generic/tkTextWind.c.

1335
1336
1337
1338
1339
1340
1341




1342
1343
1344
1345
1346
1347
1348
TkTextWindowIndex(
    TkText *textPtr,		/* Text widget containing window. */
    const char *name,		/* Name of window. */
    TkTextIndex *indexPtr)	/* Index information gets stored here. */
{
    Tcl_HashEntry *hPtr;
    TkTextSegment *ewPtr;





    hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->windowTable, name);
    if (hPtr == NULL) {
	return 0;
    }

    ewPtr = Tcl_GetHashValue(hPtr);







>
>
>
>







1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
TkTextWindowIndex(
    TkText *textPtr,		/* Text widget containing window. */
    const char *name,		/* Name of window. */
    TkTextIndex *indexPtr)	/* Index information gets stored here. */
{
    Tcl_HashEntry *hPtr;
    TkTextSegment *ewPtr;

    if (textPtr == NULL) {
	return 0;
    }

    hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->windowTable, name);
    if (hPtr == NULL) {
	return 0;
    }

    ewPtr = Tcl_GetHashValue(hPtr);

Changes to tests/textIndex.test.

210
211
212
213
214
215
216





217
218
219

















220
221
222
223
224
225
226
.t tag add x 2.8 2.11
.t tag add x 6.0 6.2
set weirdTag "funny . +- 22.1\n\t{"
.t tag add $weirdTag 2.1  2.6
set weirdMark "asdf \n{-+ 66.2\t"
.t mark set $weirdMark 4.0
.t tag config y -relief raised





test textIndex-3.1 {TkTextGetIndex, weird mark names} {
    list [catch {.t index $weirdMark} msg] $msg
} {0 4.0}


















test textIndex-4.1 {TkTextGetIndex, tags} {
    list [catch {.t index x.first} msg] $msg
} {0 2.8}
test textIndex-4.2 {TkTextGetIndex, tags} {
    list [catch {.t index x.last} msg] $msg
} {0 6.2}







>
>
>
>
>



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







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
.t tag add x 2.8 2.11
.t tag add x 6.0 6.2
set weirdTag "funny . +- 22.1\n\t{"
.t tag add $weirdTag 2.1  2.6
set weirdMark "asdf \n{-+ 66.2\t"
.t mark set $weirdMark 4.0
.t tag config y -relief raised
set weirdImage "foo-1"
.t image create 2.1 -image [image create photo $weirdImage]
set weirdEmbWin ".t.bar-1"
entry $weirdEmbWin
.t window create 3.1 -window $weirdEmbWin
test textIndex-3.1 {TkTextGetIndex, weird mark names} {
    list [catch {.t index $weirdMark} msg] $msg
} {0 4.0}
test textIndex-3.2 {TkTextGetIndex, weird mark names} knownBug {
    list [catch {.t index "$weirdMark -1char"} msg] $msg
} {0 4.0}
test textIndex-3.3 {TkTextGetIndex, weird embedded window names} {
    list [catch {.t index $weirdEmbWin} msg] $msg
} {0 3.1}
test textIndex-3.4 {TkTextGetIndex, weird embedded window names} knownBug {
    list [catch {.t index "$weirdEmbWin -1char"} msg] $msg
} {0 3.0}
test textIndex-3.5 {TkTextGetIndex, weird image names} {
    list [catch {.t index $weirdImage} msg] $msg
} {0 2.1}
test textIndex-3.6 {TkTextGetIndex, weird image names} knownBug {
    list [catch {.t index "$weirdImage -1char"} msg] $msg
} {0 2.0}
.t delete 3.1  ; # remove the weirdEmbWin
.t delete 2.1  ; # remove the weirdImage

test textIndex-4.1 {TkTextGetIndex, tags} {
    list [catch {.t index x.first} msg] $msg
} {0 2.8}
test textIndex-4.2 {TkTextGetIndex, tags} {
    list [catch {.t index x.last} msg] $msg
} {0 6.2}