From 384e8936ee8f4826db8273ae8423213c0aa59e45 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 14 Dec 2023 12:58:38 +0000 Subject: Add Tk_Window parameter to TtkSelectImage(). Not used yet --- generic/ttk/ttkImage.c | 9 ++++++--- generic/ttk/ttkLabel.c | 4 ++-- generic/ttk/ttkTheme.h | 2 +- tests/menu.test | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c index e33a9de..c47e432 100644 --- a/generic/ttk/ttkImage.c +++ b/generic/ttk/ttkImage.c @@ -156,7 +156,10 @@ void TtkFreeImageSpec(Ttk_ImageSpec *imageSpec) /* TtkSelectImage -- * Return a state-specific image from an ImageSpec */ -Tk_Image TtkSelectImage(Ttk_ImageSpec *imageSpec, Ttk_State state) +Tk_Image TtkSelectImage( + Ttk_ImageSpec *imageSpec, + TCL_UNUSED(Tk_Window), + Ttk_State state) { int i; for (i = 0; i < imageSpec->mapCount; ++i) { @@ -307,10 +310,10 @@ static void ImageElementDraw( } } if (!image) { - image = TtkSelectImage(imageData->imageSpec, state); + image = TtkSelectImage(imageData->imageSpec, tkwin, state); } #else - image = TtkSelectImage(imageData->imageSpec, state); + image = TtkSelectImage(imageData->imageSpec, tkwin, state); #endif if (!image) { diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index f1de5de..54ecabd 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -282,7 +282,7 @@ static int ImageSetup( if (!image->imageSpec) { return 0; } - image->tkimg = TtkSelectImage(image->imageSpec, state); + image->tkimg = TtkSelectImage(image->imageSpec, tkwin, state); if (!image->tkimg) { TtkFreeImageSpec(image->imageSpec); return 0; @@ -356,7 +356,7 @@ static void ImageDraw( if (state & TTK_STATE_DISABLED) { - if (TtkSelectImage(image->imageSpec, 0ul) == image->tkimg) { + if (TtkSelectImage(image->imageSpec, tkwin, 0ul) == image->tkimg) { #ifndef MAC_OSX_TK StippleOver(image, tkwin, d, b.x,b.y); #endif diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h index cf0a07c..c927209 100644 --- a/generic/ttk/ttkTheme.h +++ b/generic/ttk/ttkTheme.h @@ -379,7 +379,7 @@ TTKAPI Ttk_ImageSpec *TtkGetImageSpec(Tcl_Interp *, Tk_Window, Tcl_Obj *); TTKAPI Ttk_ImageSpec *TtkGetImageSpecEx(Tcl_Interp *, Tk_Window, Tcl_Obj *, Tk_ImageChangedProc *, ClientData); TTKAPI void TtkFreeImageSpec(Ttk_ImageSpec *); -TTKAPI Tk_Image TtkSelectImage(Ttk_ImageSpec *, Ttk_State); +TTKAPI Tk_Image TtkSelectImage(Ttk_ImageSpec *, Tk_Window, Ttk_State); /*------------------------------------------------------------------------ * +++ Miscellaneous enumerations. diff --git a/tests/menu.test b/tests/menu.test index 23c28b0..7fed665 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -4116,7 +4116,7 @@ test menu-40.1 {Use-after-free if menu destroyed while posted - bug 09a11fb1228f } -constraints {pressbutton} -body { set done false event generate {} -x 100 -y 100 - toplevel .t + toplevel .t menu .t.m .t.m add command -command {puts Marco} -label Marco .t.m add command -command {puts Polo} -label Polo @@ -4131,7 +4131,7 @@ test menu-40.2 {Use-after-free if menu destroyed while posted - bug 09a11fb1228f } -constraints {movemouse} -body { set done false event generate {} -x 100 -y 100 - toplevel .t + toplevel .t menu .t.m .t.m add command -command {puts Marco} -label Marco .t.m add command -command {puts Polo} -label Polo -- cgit v0.12