summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkInt.h3
-rw-r--r--generic/tkWindow.c1
-rw-r--r--generic/ttk/ttkTheme.c30
3 files changed, 23 insertions, 11 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 35b7e67..7568585 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1092,10 +1092,11 @@ extern "C" {
#endif
/*
- * Themed widget set init function:
+ * Themed widget set init function, and handler called when Tk is destroyed.
*/
MODULE_SCOPE int Ttk_Init(Tcl_Interp *interp);
+MODULE_SCOPE void Ttk_TkDestroyedHandler(Tcl_Interp *interp);
/*
* Internal functions shared among Tk modules but not exported to the outside
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index fa25553..59c1243 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -1621,6 +1621,7 @@ Tk_DestroyWindow(
TkFontPkgFree(winPtr->mainPtr);
TkFocusFree(winPtr->mainPtr);
TkStylePkgFree(winPtr->mainPtr);
+ Ttk_TkDestroyedHandler(winPtr->mainPtr->interp);
/*
* When embedding Tk into other applications, make sure that all
diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c
index 711c410..3cea404 100644
--- a/generic/ttk/ttkTheme.c
+++ b/generic/ttk/ttkTheme.c
@@ -403,8 +403,6 @@ typedef struct
int themeChangePending; /* scheduled ThemeChangedProc call? */
} StylePackageData;
-static void ThemeChangedProc(void *); /* Forward */
-
/* Ttk_StylePkgFree --
* Cleanup procedure for StylePackageData.
*/
@@ -418,13 +416,6 @@ static void Ttk_StylePkgFree(
Cleanup *cleanup;
/*
- * Cancel any pending ThemeChanged calls:
- */
- if (pkgPtr->themeChangePending) {
- Tcl_CancelIdleCall(ThemeChangedProc, pkgPtr);
- }
-
- /*
* Free themes.
*/
entryPtr = Tcl_FirstHashEntry(&pkgPtr->themeTable, &search);
@@ -486,7 +477,7 @@ static StylePackageData *GetStylePackageData(Tcl_Interp *interp)
void Ttk_RegisterCleanup(
Tcl_Interp *interp, ClientData clientData, Ttk_CleanupProc *cleanupProc)
{
- StylePackageData *pkgPtr = (StylePackageData *)GetStylePackageData(interp);
+ StylePackageData *pkgPtr = GetStylePackageData(interp);
Cleanup *cleanup = (Cleanup *)ckalloc(sizeof(*cleanup));
cleanup->clientData = clientData;
@@ -531,6 +522,25 @@ static void ThemeChanged(StylePackageData *pkgPtr)
}
}
+/* Ttk_TkDestroyedHandler --
+ * See bug [310c74ecf440]: idle calls to ThemeChangedProc()
+ * need to be canceled when Tk is destroyed, since the interp
+ * may still be active afterward; canceling them from
+ * Ttk_StylePkgFree() would be too late.
+ */
+void Ttk_TkDestroyedHandler(
+ Tcl_Interp* interp)
+{
+ StylePackageData* pkgPtr = GetStylePackageData(interp);
+
+ /*
+ * Cancel any pending ThemeChanged calls:
+ */
+ if (pkgPtr->themeChangePending) {
+ Tcl_CancelIdleCall(ThemeChangedProc, pkgPtr);
+ }
+}
+
/*
* Ttk_CreateTheme --
* Create a new theme and register it in the global theme table.