fix commit "lazy initialization of highlight pens and brushes
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 21 Sep 2017 16:06:51 +0300
changeset 1823 1e9a67d68612
parent 1822 1d7bf584eb7f
child 1824 5765bea3dbd1
fix commit "lazy initialization of highlight pens and brushes
for DebugVariableViewer" (5562f34f)
controls/DebugVariablePanel/DebugVariableGraphicViewer.py
controls/DebugVariablePanel/DebugVariableViewer.py
--- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Thu Sep 21 15:04:15 2017 +0300
+++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Thu Sep 21 16:06:51 2017 +0300
@@ -1398,15 +1398,15 @@
         # If highlight to display is resize, draw thick grey line at bottom
         # side of canvas
         if self.Highlight == HIGHLIGHT_RESIZE:
-            destGC.SetPen(HIGHLIGHT_RESIZE_PEN)
-            destGC.SetBrush(HIGHLIGHT_RESIZE_BRUSH)
+            destGC.SetPen(HIGHLIGHT['RESIZE_PEN'])
+            destGC.SetBrush(HIGHLIGHT['RESIZE_BRUSH'])
             destGC.DrawRectangle(0, height - 5, width, 5)
 
         # If highlight to display is merging graph, draw 50% transparent blue
         # rectangle on left or right part of figure depending on highlight type
         elif self.Highlight in [HIGHLIGHT_LEFT, HIGHLIGHT_RIGHT]:
-            destGC.SetPen(HIGHLIGHT_DROP_PEN)
-            destGC.SetBrush(HIGHLIGHT_DROP_BRUSH)
+            destGC.SetPen(HIGHLIGHT['DROP_PEN'])
+            destGC.SetBrush(HIGHLIGHT['DROP_BRUSH'])
 
             x_offset = (bbox.width / 2
                         if self.Highlight == HIGHLIGHT_RIGHT
--- a/controls/DebugVariablePanel/DebugVariableViewer.py	Thu Sep 21 15:04:15 2017 +0300
+++ b/controls/DebugVariablePanel/DebugVariableViewer.py	Thu Sep 21 16:06:51 2017 +0300
@@ -41,10 +41,8 @@
  HIGHLIGHT_RESIZE] = range(6)
 
 # Viewer highlight styles
-HIGHLIGHT_DROP_PEN = None
-HIGHLIGHT_DROP_BRUSH = None
-HIGHLIGHT_RESIZE_PEN = None
-HIGHLIGHT_RESIZE_BRUSH = None
+HIGHLIGHT = {
+}
 
 # -------------------------------------------------------------------------------
 #                        Base Debug Variable Viewer Class
@@ -85,11 +83,12 @@
         """
         Init global pens and brushes
         """
-        if HIGHLIGHT_DROP_PEN is None:
-            HIGHLIGHT_DROP_PEN = wx.Pen(wx.Colour(0, 128, 255))
-            HIGHLIGHT_DROP_BRUSH = wx.Brush(wx.Colour(0, 128, 255, 128))
-            HIGHLIGHT_RESIZE_PEN = wx.Pen(wx.Colour(200, 200, 200))
-            HIGHLIGHT_RESIZE_BRUSH = wx.Brush(wx.Colour(200, 200, 200))
+        global HIGHLIGHT
+        if not HIGHLIGHT:
+            HIGHLIGHT['DROP_PEN'] = wx.Pen(wx.Colour(0, 128, 255))
+            HIGHLIGHT['DROP_BRUSH'] = wx.Brush(wx.Colour(0, 128, 255, 128))
+            HIGHLIGHT['RESIZE_PEN'] = wx.Pen(wx.Colour(200, 200, 200))
+            HIGHLIGHT['RESIZE_BRUSH'] = wx.Brush(wx.Colour(200, 200, 200))
 
     def GetIndex(self):
         """
@@ -281,8 +280,8 @@
         width, height = self.GetSize()
 
         # Set dc styling for drop before or drop after highlight
-        dc.SetPen(HIGHLIGHT_DROP_PEN)
-        dc.SetBrush(HIGHLIGHT_DROP_BRUSH)
+        dc.SetPen(HIGHLIGHT['DROP_PEN'])
+        dc.SetBrush(HIGHLIGHT['DROP_BRUSH'])
 
         # Draw line at upper side of Viewer if highlight is drop before
         if self.Highlight == HIGHLIGHT_BEFORE: