Tk Source Code

View Ticket
Login
Ticket UUID: 0ec9336873bc987caa85537904e96a7d4dc7247
Title: --disable-bidi does not disable base chunks and drawing in context on X11
Type: Bug Version: 9.1b1
Submitter: serhiy.storchaka Created on: 2026-09-24 11:50:14
Subsystem: 84. Unix Build Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-09-25 10:45:37
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-09-25 10:45:37
Description:

unix/tkUnixInt.h (added by [8ce823d20c]) defines TK_DRAW_IN_CONTEXT and TK_LAYOUT_WITH_BASE_CHUNKS as 1 with HAVE_BIDI and as 0 without it. But tkTextDisp.c and tkFont.c only test whether they are defined (#ifdef, #ifndef, defined()), so both features are enabled also in builds configured with --disable-bidi. In such a build, the preprocessed tkTextDisp.c contains the base-chunk variant of CharInfo and all uses of baseCharChunkPtr. This also exposes such builds to [a0c1a9c6c6] (base chunks are not thread-safe).

Two ways to fix it:

  1. Do not define the macros without HAVE_BIDI in unix/tkUnixInt.h. This is consistent with Windows and macOS, which define them as 1 or not at all, and changes only one file.
  2. Keep the 0/1 definitions and test the values: replace the 38 #ifdef/#ifndef/defined() tests with #if, and define both macros as 0 by default (e.g. in tkInt.h) for platforms that do not define them, because Tk is compiled with -Wundef. This is more robust against the same mistake in future, but touches more code.

User Comments: jan.nijtmans added on 2026-09-25 10:45:37:

--disable-bidi build fixed [ 808a0c7a|here]

Thanks (again)!


serhiy.storchaka added on 2026-09-25 07:28:30:

After this fix ([3d18c59227]) builds with --disable-bidi no longer compile: three uses of CharInfo.isRtl and ChunkIsRtl() added in [8ce823d20c] are outside #ifdef TK_LAYOUT_WITH_BASE_CHUNKS. This breaks the macOS CI build of main. With that fixed, every text widget hangs: CharChunkMeasureChars() returns 0 when the chunk has no CharInfo yet, which is always the case during layout without base chunks.

Proposed fix in branch text-disable-bidi-build ([c4ad2e418f]). With it the text tests pass with and without --disable-bidi.


jan.nijtmans added on 2026-09-24 12:51:10:

Fixed [3d18c59227780790|here]

This is a no-brainer IMHO. Thanks for catching this!