Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7c4781

Browse files
authored
gh-71383: Backport fix for unnecessary Theme-related warnings in Tk (#29)
Adapted from https://core.tcl-lang.org/tk/info/b1876b9ebc4b
1 parent a0c46cb commit a7c4781

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

generic/tkInt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,10 +1092,11 @@ extern "C" {
10921092
#endif
10931093

10941094
/*
1095-
* Themed widget set init function:
1095+
* Themed widget set init function, and handler called when Tk is destroyed.
10961096
*/
10971097

10981098
MODULE_SCOPE int Ttk_Init(Tcl_Interp *interp);
1099+
MODULE_SCOPE void Ttk_TkDestroyedHandler(Tcl_Interp *interp);
10991100

11001101
/*
11011102
* Internal functions shared among Tk modules but not exported to the outside

generic/tkWindow.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,7 @@ Tk_DestroyWindow(
16211621
TkFontPkgFree(winPtr->mainPtr);
16221622
TkFocusFree(winPtr->mainPtr);
16231623
TkStylePkgFree(winPtr->mainPtr);
1624+
Ttk_TkDestroyedHandler(winPtr->mainPtr->interp);
16241625

16251626
/*
16261627
* When embedding Tk into other applications, make sure that all

generic/ttk/ttkTheme.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,6 @@ static void Ttk_StylePkgFree(
417417
Tcl_HashEntry *entryPtr;
418418
Cleanup *cleanup;
419419

420-
/*
421-
* Cancel any pending ThemeChanged calls:
422-
*/
423-
if (pkgPtr->themeChangePending) {
424-
Tcl_CancelIdleCall(ThemeChangedProc, pkgPtr);
425-
}
426-
427420
/*
428421
* Free themes.
429422
*/
@@ -531,6 +524,25 @@ static void ThemeChanged(StylePackageData *pkgPtr)
531524
}
532525
}
533526

527+
/* Ttk_TkDestroyedHandler --
528+
* See bug [310c74ecf440]: idle calls to ThemeChangedProc()
529+
* need to be canceled when Tk is destroyed, since the interp
530+
* may still be active afterward; canceling them from
531+
* Ttk_StylePkgFree() would be too late.
532+
*/
533+
void Ttk_TkDestroyedHandler(
534+
Tcl_Interp* interp)
535+
{
536+
StylePackageData* pkgPtr = GetStylePackageData(interp);
537+
538+
/*
539+
* Cancel any pending ThemeChanged calls:
540+
*/
541+
if (pkgPtr->themeChangePending) {
542+
Tcl_CancelIdleCall(ThemeChangedProc, pkgPtr);
543+
}
544+
}
545+
534546
/*
535547
* Ttk_CreateTheme --
536548
* Create a new theme and register it in the global theme table.

0 commit comments

Comments
 (0)