Later Tcl 8.5 versions learned to return the current theme by omitting
the final argument to "[ttk::style theme use]", but this throws an
error on earlier 8.5 versions (e.g., 8.5.7).

InitTheme works around this by catching the error and reading
::ttk::currentTheme instead.

A call to "[ttk::style theme use]" was added to ttext in 30508bc
("Amend tab ordering and text widget border and highlighting.",
2016-10-02).  Break out InitTheme's workaround into its own
get_current_theme proc and use it in both places.

Signed-off-by: Pete Harlan <p...@tento.net>
---

Note: Applies to the upstream git-gui repo, http://repo.or.cz/git-gui .
To apply to Git itself, apply in the git-gui directory.

Issue entered Git in v2.10.1-537-g3eae30870.

 lib/themed.tcl | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/themed.tcl b/lib/themed.tcl
index 351a712..85c157b 100644
--- a/lib/themed.tcl
+++ b/lib/themed.tcl
@@ -28,10 +28,7 @@ proc InitTheme {} {
                }
        }

-       # Handle either current Tk or older versions of 8.5
-       if {[catch {set theme [ttk::style theme use]}]} {
-               set theme  $::ttk::currentTheme
-       }
+       set theme [get_current_theme]

        if {[lsearch -exact {default alt classic clam} $theme] != -1} {
                # Simple override of standard ttk::entry to change the field
@@ -248,7 +245,7 @@ proc tspinbox {w args} {
 proc ttext {w args} {
        global use_ttk
        if {$use_ttk} {
-               switch -- [ttk::style theme use] {
+               switch -- [get_current_theme] {
                        "vista" - "xpnative" {
                                lappend args -highlightthickness 0
-borderwidth 0
                        }
@@ -343,6 +340,16 @@ proc on_choosefont {familyvar sizevar font} {
        set size [dict get $font -size]
 }

+# Get current theme in a backwards-compatible way.
+proc get_current_theme {} {
+       # Handle either current Tk or older versions of 8.5
+       if {[catch {set theme [ttk::style theme use]}]} {
+               set theme $::ttk::currentTheme
+       }
+
+       return $theme
+}
+
 # Local variables:
 # mode: tcl
 # indent-tabs-mode: t

Reply via email to