Skip to content

Commit

Permalink
wxGUI/colorrules: fix OnOK when preview is updated after window is de…
Browse files Browse the repository at this point in the history
…stroyed (#443)
  • Loading branch information
petrasovaa committed Mar 22, 2020
1 parent 0d89737 commit e3c74e5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions gui/wxpython/modules/colorrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ def OnCloseWindow(self, event):
self.OnCancel(event)

def OnApply(self, event):
return self._apply()

def _apply(self, updatePreview=True):
"""Apply selected color table
:return: True on success otherwise False
Expand All @@ -620,7 +623,8 @@ def OnApply(self, event):
GMessage(parent=self, message=_("No valid color rules given."))
else:
# re-render preview and current map window
self.OnPreview(None)
if updatePreview:
self.OnPreview(None)
display = self.layerTree.GetMapDisplay()
if display and display.IsAutoRendered():
display.GetWindow().UpdateMap(render=True)
Expand All @@ -629,7 +633,7 @@ def OnApply(self, event):

def OnOK(self, event):
"""Apply selected color table and close the dialog"""
if self.OnApply(event):
if self._apply(updatePreview=False):
self.OnCancel(event)

def OnCancel(self, event):
Expand Down Expand Up @@ -1846,7 +1850,7 @@ def OnCancel(self, event):
self.Map.Clean()
self.Destroy()

def OnApply(self, event):
def _apply(self, updatePreview=True):
"""Apply selected color table
:return: True on success otherwise False
Expand All @@ -1861,7 +1865,7 @@ def OnApply(self, event):

self.UseAttrColumn(True)

return ColorTable.OnApply(self, event)
return ColorTable._apply(self, updatePreview)


class ThematicVectorTable(VectorColorTable):
Expand All @@ -1880,7 +1884,7 @@ def _initLayer(self):
self.selectionInput.SetValue(self.inmap)
self.selectionInput.Disable()

def OnApply(self, event):
def _apply(self, updatePreview=True):
"""Apply selected color table
:return: True on success otherwise False
Expand Down

0 comments on commit e3c74e5

Please sign in to comment.