Unnamed Fossil Project

Diff
Login

Diff

Differences From Artifact [6c437e300a]:

To Artifact [fe690bdb09]:


1
2
3
4
5
6
7

8
9
10
11
12
13
14
1
2
3
4
5
6

7
8
9
10
11
12
13
14






-
+







/*
 * cache.c --
 *      Tile theme engine, resource cache.
 *
 * Copyright (c) 2004, Joe English
 *
 * $Id: cache.c,v 1.2 2004/02/12 22:41:33 jenglish Exp $
 * $Id: cache.c,v 1.3 2004/02/12 22:52:46 jenglish Exp $
 *
 * The problem:
 *
 * Tk maintains reference counts for fonts, colors, and images,
 * and deallocates them when the reference count goes to zero.
 * With the theme engine, resources are allocated right before
 * drawing an element and released immediately after.
70
71
72
73
74
75
76

77
78



79
80
81
82
83
84
85
86
87
88
89

90
91



92
93
94
95
96
97
98
99
100
101
102

103
104



105
106
107
108
109
110
111
112
113
114
115

116


117
118
119
120
121
122
123
70
71
72
73
74
75
76
77


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107


108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

123
124
125
126
127
128
129
130
131







+
-
-
+
+
+











+
-
-
+
+
+











+
-
-
+
+
+











+
-
+
+








    /*
     * Free fonts:
     */
    entryPtr = Tcl_FirstHashEntry(&cache->fontTable, &search);
    while (entryPtr != NULL) {
	Tcl_Obj *fontObj = (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
	if (fontObj) {
	Tk_FreeFontFromObj(cache->tkwin, fontObj);
	Tcl_DecrRefCount(fontObj);
	    Tk_FreeFontFromObj(cache->tkwin, fontObj);
	    Tcl_DecrRefCount(fontObj);
	}
	entryPtr = Tcl_NextHashEntry(&search);
    }
    Tcl_DeleteHashTable(&cache->fontTable);
    Tcl_InitHashTable(&cache->fontTable, TCL_STRING_KEYS);

    /*
     * Free colors:
     */
    entryPtr = Tcl_FirstHashEntry(&cache->colorTable, &search);
    while (entryPtr != NULL) {
	Tcl_Obj *colorObj = (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
	if (colorObj) {
	Tk_FreeColorFromObj(cache->tkwin, colorObj);
	Tcl_DecrRefCount(colorObj);
	    Tk_FreeColorFromObj(cache->tkwin, colorObj);
	    Tcl_DecrRefCount(colorObj);
	}
	entryPtr = Tcl_NextHashEntry(&search);
    }
    Tcl_DeleteHashTable(&cache->colorTable);
    Tcl_InitHashTable(&cache->colorTable, TCL_STRING_KEYS);

    /*
     * Free borders:
     */
    entryPtr = Tcl_FirstHashEntry(&cache->borderTable, &search);
    while (entryPtr != NULL) {
	Tcl_Obj *borderObj = (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
	if (borderObj) {
	Tk_Free3DBorderFromObj(cache->tkwin, borderObj);
	Tcl_DecrRefCount(borderObj);
	    Tk_Free3DBorderFromObj(cache->tkwin, borderObj);
	    Tcl_DecrRefCount(borderObj);
	}
	entryPtr = Tcl_NextHashEntry(&search);
    }
    Tcl_DeleteHashTable(&cache->borderTable);
    Tcl_InitHashTable(&cache->borderTable, TCL_STRING_KEYS);

    /*
     * Free images:
     */
    entryPtr = Tcl_FirstHashEntry(&cache->imageTable, &search);
    while (entryPtr != NULL) {
	Tk_Image image = (Tk_Image)Tcl_GetHashValue(entryPtr);
	if (image) {
	Tk_FreeImage(image);
	    Tk_FreeImage(image);
	}
	entryPtr = Tcl_NextHashEntry(&search);
    }
    Tcl_DeleteHashTable(&cache->imageTable);
    Tcl_InitHashTable(&cache->imageTable, TCL_STRING_KEYS);

    return;
}