Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-71383: add upstream fix #29

Merged
merged 1 commit into from Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion generic/tkInt.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions generic/tkWindow.c
Expand Up @@ -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
Expand Down
26 changes: 19 additions & 7 deletions generic/ttk/ttkTheme.c
Expand Up @@ -417,13 +417,6 @@ static void Ttk_StylePkgFree(
Tcl_HashEntry *entryPtr;
Cleanup *cleanup;

/*
* Cancel any pending ThemeChanged calls:
*/
if (pkgPtr->themeChangePending) {
Tcl_CancelIdleCall(ThemeChangedProc, pkgPtr);
}

/*
* Free themes.
*/
Expand Down Expand Up @@ -531,6 +524,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.
Expand Down