summaryrefslogtreecommitdiffstats
path: root/generic/tkTextWind.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2022-02-19 14:09:23 (GMT)
committerfvogel <fvogelnew1@free.fr>2022-02-19 14:09:23 (GMT)
commit78f0a3abb0849c7182c54bcd789829b3c96661dc (patch)
treef6cdd1eba9fbfe601f4c45890f13a1dc515e59ef /generic/tkTextWind.c
parentcbead0eb6aa76d7d9a6eb19dc4dcb97e9026d26a (diff)
downloadtk-78f0a3abb0849c7182c54bcd789829b3c96661dc.zip
tk-78f0a3abb0849c7182c54bcd789829b3c96661dc.tar.gz
tk-78f0a3abb0849c7182c54bcd789829b3c96661dc.tar.bz2
Fix [54fe7a5e71]: crash with destroy and text widget embedded windows. Test textWind-18.3 now passes.
Diffstat (limited to 'generic/tkTextWind.c')
-rw-r--r--generic/tkTextWind.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c
index fb7cbdf..46f84b0 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.c
@@ -568,7 +568,7 @@ EmbWinStructureProc(
static void
EmbWinRequestProc(
ClientData clientData, /* Pointer to record for window item. */
- TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */
+ TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */
{
TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
TkTextSegment *ewPtr = client->parent;
@@ -576,7 +576,15 @@ EmbWinRequestProc(
index.tree = ewPtr->body.ew.sharedTextPtr->tree;
index.linePtr = ewPtr->body.ew.linePtr;
- index.byteIndex = TkTextSegToOffset(ewPtr, ewPtr->body.ew.linePtr);
+
+ /*
+ * ewPtr->body.ew.tkwin == NULL means the embedded window is already
+ * destroyed. The ewPtr segment is no longer linked, TkTextSegToOffset
+ * cannot find it within the line pointed by ewPtr->body.ew.linePtr.
+ */
+
+ index.byteIndex = ewPtr->body.ew.tkwin ?
+ TkTextSegToOffset(ewPtr, ewPtr->body.ew.linePtr) : 0;
TkTextChanged(ewPtr->body.ew.sharedTextPtr, NULL, &index, &index);
TkTextInvalidateLineMetrics(ewPtr->body.ew.sharedTextPtr, NULL,
index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY);