summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkTextImage.c4
-rw-r--r--generic/tkTextIndex.c16
-rw-r--r--generic/tkTextWind.c4
-rw-r--r--tests/textIndex.test22
5 files changed, 48 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 8237eed..65f2bbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-04 Francois Vogel <fvogelnew1@free.fr>
+
+ * generic/tkTextIndex.c: [Bug 3588824]: bug in image index handling
+ * tests/textIndex.test: for weird image names
+
2012-11-13 Jan Nijtmans <nijtmans@users.sf.net>
* win/tkWinTest.c: [Bug 3585396]: winDialog.test requires user
diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c
index 771347d..bc2b7c4 100644
--- a/generic/tkTextImage.c
+++ b/generic/tkTextImage.c
@@ -779,6 +779,10 @@ TkTextImageIndex(
Tcl_HashEntry *hPtr;
TkTextSegment *eiPtr;
+ if (textPtr == NULL) {
+ return 0;
+ }
+
hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->imageTable, name);
if (hPtr == NULL) {
return 0;
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index a9b0bed..70c94db 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -758,9 +758,11 @@ GetIndex(
/*
*---------------------------------------------------------------------
- * 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".
+ * 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".
*---------------------------------------------------------------------
*/
@@ -768,6 +770,14 @@ GetIndex(
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.
diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c
index ecafd4e..5dc8feb 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.c
@@ -1329,6 +1329,10 @@ TkTextWindowIndex(
Tcl_HashEntry *hPtr;
TkTextSegment *ewPtr;
+ if (textPtr == NULL) {
+ return 0;
+ }
+
hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->windowTable, name);
if (hPtr == NULL) {
return 0;
diff --git a/tests/textIndex.test b/tests/textIndex.test
index 6341b6d..28dc0df 100644
--- a/tests/textIndex.test
+++ b/tests/textIndex.test
@@ -214,9 +214,31 @@ set weirdTag "funny . +- 22.1\n\t{"
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