summaryrefslogtreecommitdiffstats
path: root/win/tkWinScrlbr.c
diff options
context:
space:
mode:
authornijtmans <nijtmans@noemail.net>2010-02-16 21:12:56 (GMT)
committernijtmans <nijtmans@noemail.net>2010-02-16 21:12:56 (GMT)
commit7f462491c2d731d7849663f97b2153c6f1924d35 (patch)
treeb566e3894b84ff71cec41746404929097ffb61c6 /win/tkWinScrlbr.c
parente219e22b792ba07eb8da4e3b6307bded30b611a0 (diff)
downloadtk-7f462491c2d731d7849663f97b2153c6f1924d35.zip
tk-7f462491c2d731d7849663f97b2153c6f1924d35.tar.gz
tk-7f462491c2d731d7849663f97b2153c6f1924d35.tar.bz2
tkWindow.c/tkStubInit.c adapted from stub changes in Tcl
tkArgv.c make defaultTable const tkScrollbar.c Store default for "-with" in static non-const memory tkWinInt.h make tkWinProcs const, and 5 tkWinX.c procs MODULE_SCOPE tkWinColor.c make sysColors const tkWinKey.c make keymap const tkWinScrlbr.c Simplify copying of "-with" default value. tkUnixWm.c make TkSetTransientFor static tests/textImage.test textImage-1.13 depends on hash-order FossilOrigin-Name: 43e4c59ecfb38812036e330064ece8e6f7a37a83
Diffstat (limited to 'win/tkWinScrlbr.c')
-rw-r--r--win/tkWinScrlbr.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c
index b87731c..9e848c7 100644
--- a/win/tkWinScrlbr.c
+++ b/win/tkWinScrlbr.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinScrlbr.c,v 1.18 2010/01/13 23:08:11 nijtmans Exp $
+ * RCS: @(#) $Id: tkWinScrlbr.c,v 1.19 2010/02/16 21:12:56 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -54,18 +54,11 @@ typedef struct WinScrollbar {
static int initialized = 0;
static int hArrowWidth, hThumb; /* Horizontal control metrics. */
-static int vArrowWidth, vArrowHeight, vThumb; /* Vertical control metrics. */
+static int vArrowHeight, vThumb; /* Vertical control metrics. */
TCL_DECLARE_MUTEX(winScrlbrMutex)
/*
- * This variable holds the default width for a scrollbar in string form for
- * use in a Tk_ConfigSpec.
- */
-
-static char defWidth[TCL_INTEGER_SPACE];
-
-/*
* Declarations for functions defined in this file.
*/
@@ -363,19 +356,22 @@ TkpDestroyScrollbar(
void
UpdateScrollbarMetrics(void)
{
- Tk_ConfigSpec *specPtr;
+ int arrowWidth = GetSystemMetrics(SM_CXVSCROLL);
+ const Tk_ConfigSpec *specPtr;
hArrowWidth = GetSystemMetrics(SM_CXHSCROLL);
hThumb = GetSystemMetrics(SM_CXHTHUMB);
- vArrowWidth = GetSystemMetrics(SM_CXVSCROLL);
vArrowHeight = GetSystemMetrics(SM_CYVSCROLL);
vThumb = GetSystemMetrics(SM_CYVTHUMB);
- sprintf(defWidth, "%d", vArrowWidth);
for (specPtr = tkpScrollbarConfigSpecs; specPtr->type != TK_CONFIG_END;
specPtr++) {
+ /* Make sure that the default value belonging to the "-width"
+ * option of TkScrollbar points to static non-const space,
+ * otherwise the following sprintf results in a crash!
+ */
if (specPtr->offset == Tk_Offset(TkScrollbar, width)) {
- specPtr->defValue = defWidth;
+ sprintf((char *)specPtr->defValue, "%d", arrowWidth);
}
}
}