Check-in [8891f0f092]
Not logged in

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

Overview
Comment:fixes in ttk object caching
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8891f0f0927cb84475227193edca3669490676d7
User & Date: chw 2023-11-26 07:48:33
Context
2023-11-26
14:34
some fixes in tk's library in order to support multiple display connections check-in: 08edf82b9b user: chw tags: trunk
07:48
fixes in ttk object caching check-in: 8891f0f092 user: chw tags: trunk
2023-11-25
13:00
fixes in tk's font rendering when using libxft check-in: 843e00e7fc user: chw tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jni/sdl2tk/generic/ttk/ttkCache.c.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 * resource cache instead of directly from Tk; the cache
 * holds a semipermanent reference to the resource to keep
 * it from being deallocated.
 *
 * The plumbing and control flow here is quite contorted;
 * it would be better to address this problem in the core instead.
 *
 * @@@ BUGS/TODO: Need distinct caches for each combination
 * of display, visual, and colormap.
 *
 * @@@ Colormap flashing on PseudoColor visuals is still possible,
 * but this will be a transient effect.
 */

#include "tkInt.h"
#include "ttkTheme.h"








<
<
<







17
18
19
20
21
22
23



24
25
26
27
28
29
30
 * resource cache instead of directly from Tk; the cache
 * holds a semipermanent reference to the resource to keep
 * it from being deallocated.
 *
 * The plumbing and control flow here is quite contorted;
 * it would be better to address this problem in the core instead.
 *



 * @@@ Colormap flashing on PseudoColor visuals is still possible,
 * but this will be a transient effect.
 */

#include "tkInt.h"
#include "ttkTheme.h"

263
264
265
266
267
268
269
270
271
272














273
274
275
276
277
278
279
    Tcl_Interp *interp,
    Tcl_HashTable *table,
    Allocator allocate,
    Tk_Window tkwin,
    Tcl_Obj *objPtr)
{
    int newEntry;
    Tcl_HashEntry *entryPtr =
	Tcl_CreateHashEntry(table,Tcl_GetString(objPtr),&newEntry);
    Tcl_Obj *cacheObj;















    if (!newEntry) {
	return Tcl_GetHashValue(entryPtr);
    }

    cacheObj = Tcl_DuplicateObj(objPtr);
    Tcl_IncrRefCount(cacheObj);







|
<

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







260
261
262
263
264
265
266
267

268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
    Tcl_Interp *interp,
    Tcl_HashTable *table,
    Allocator allocate,
    Tk_Window tkwin,
    Tcl_Obj *objPtr)
{
    int newEntry;
    Tcl_HashEntry *entryPtr;

    Tcl_Obj *cacheObj;
#if defined(PLATFORM_SDL) || defined(_WIN32) || defined(MAC_OSX_TK)
    entryPtr = Tcl_CreateHashEntry(table, Tcl_GetString(objPtr), &newEntry);
#else
    Tcl_DString ds;
    char buffer[64];

    Tcl_DStringInit(&ds);
    Tcl_DStringAppend(&ds, Tcl_GetString(objPtr), -1);
    sprintf(buffer, ",%d,%lu,%lu", ConnectionNumber(Tk_Display(tkwin)),
	Tk_Visual(tkwin)->visualid, (unsigned long) Tk_Colormap(tkwin));
    Tcl_DStringAppend(&ds, buffer, -1);
    entryPtr = Tcl_CreateHashEntry(table, Tcl_DStringValue(&ds), &newEntry);
    Tcl_DStringFree(&ds);
#endif

    if (!newEntry) {
	return Tcl_GetHashValue(entryPtr);
    }

    cacheObj = Tcl_DuplicateObj(objPtr);
    Tcl_IncrRefCount(cacheObj);
337
338
339
340
341
342
343
344
345
346
347
348















349
350
351
352
353
354
355
 * Ttk_UseImage --
 * 	Acquire a Tk_Image from the cache.
 */
Tk_Image Ttk_UseImage(Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
{
    const char *imageName = Tcl_GetString(objPtr);
    int newEntry;
    Tcl_HashEntry *entryPtr =
	Tcl_CreateHashEntry(&cache->imageTable,imageName,&newEntry);
    Tk_Image image;

    InitCacheWindow(cache, tkwin);
















    if (!newEntry) {
	return Tcl_GetHashValue(entryPtr);
    }

    image = Tk_GetImage(cache->interp, tkwin, imageName, NullImageChanged,0);
    Tcl_SetHashValue(entryPtr, image);







|
<



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







347
348
349
350
351
352
353
354

355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
 * Ttk_UseImage --
 * 	Acquire a Tk_Image from the cache.
 */
Tk_Image Ttk_UseImage(Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
{
    const char *imageName = Tcl_GetString(objPtr);
    int newEntry;
    Tcl_HashEntry *entryPtr;

    Tk_Image image;

    InitCacheWindow(cache, tkwin);
#if defined(PLATFORM_SDL) || defined(_WIN32) || defined(MAC_OSX_TK)
    entryPtr = Tcl_CreateHashEntry(&cache->imageTable, imageName, &newEntry);
#else
    Tcl_DString ds;
    char buffer[64];

    Tcl_DStringInit(&ds);
    Tcl_DStringAppend(&ds, imageName, -1);
    sprintf(buffer, ",%d,%lu,%lu", ConnectionNumber(Tk_Display(tkwin)),
	Tk_Visual(tkwin)->visualid, (unsigned long) Tk_Colormap(tkwin));
    Tcl_DStringAppend(&ds, buffer, -1);
    entryPtr = Tcl_CreateHashEntry(&cache->imageTable,
	    Tcl_DStringValue(&ds), &newEntry);
    Tcl_DStringFree(&ds);
#endif

    if (!newEntry) {
	return Tcl_GetHashValue(entryPtr);
    }

    image = Tk_GetImage(cache->interp, tkwin, imageName, NullImageChanged,0);
    Tcl_SetHashValue(entryPtr, image);