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

wxGUI/g.gui.mapswipe: fix hit Apply button if first and second raster aren't chosen #1042

Merged
merged 1 commit into from
Oct 27, 2020

Conversation

tmszi
Copy link
Member

@tmszi tmszi commented Oct 22, 2020

To Reproduce:

  1. Launch Map Swipe window g.gui.mapswipe
  2. On the Select raster maps dialog (don't choose any first and second raster map)
  3. Hit Apply button

Error message:

Traceback (most recent call last):
  File "/usr/lib64/grass79/gui/wxpython/mapswipe/dialogs.py", line 69, in <lambda>
    self.btnApply.Bind(wx.EVT_BUTTON, lambda evt: self._apply())
  File "/usr/lib64/grass79/gui/wxpython/mapswipe/dialogs.py", line 231, in _apply
    self.applyChanges.emit()
  File "/usr/lib64/grass79/etc/python/grass/pydispatch/signal.py", line 230, in emit
    dispatcher.send(signal=self, *args, **kwargs)
  File "/usr/lib64/grass79/etc/python/grass/pydispatch/dispatcher.py", line 350, in send
    **named
  File "/usr/lib64/grass79/etc/python/grass/pydispatch/robustapply.py", line 60, in robustApply
    return receiver(*arguments, **named)
  File "/usr/lib64/grass79/gui/wxpython/mapswipe/frame.py", line 399, in OnApplyInputChanges
    res1 = self.SetFirstRaster(name=self.rasters['first'])
  File "/usr/lib64/grass79/gui/wxpython/mapswipe/frame.py", line 424, in SetFirstRaster
    if raster['fullname']:
KeyError: 'fullname'

Show error message dialog if you don't choose first and second raster map:

g_gui_mapswipe_error_message_dialog

@tmszi tmszi added bug Something isn't working GUI wxGUI related labels Oct 22, 2020
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you enter invalid raster name in one field and leave the other one empty, you won't get any error, so I think this case should be fixed.

gui/wxpython/mapswipe/frame.py Outdated Show resolved Hide resolved
@tmszi tmszi force-pushed the fix-g-gui-mapswipe-apply-btn branch from 2e85895 to c805d16 Compare October 23, 2020 05:47
@tmszi tmszi requested a review from petrasovaa October 23, 2020 05:49
@tmszi tmszi force-pushed the fix-g-gui-mapswipe-apply-btn branch from c805d16 to aa4666f Compare October 23, 2020 05:52
@tmszi tmszi changed the title wxGUI/g.gui.mapswipe: show error message dialog if you don't choose first and second raster map wxGUI/g.gui.mapswipe: fix hit Apply button if first and second raster aren't choosed Oct 23, 2020
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I further suggest these changes to cover cases when one raster is empty and the other is invalid:

+++ b/gui/wxpython/mapswipe/frame.py
@@ -398,14 +398,15 @@ class SwipeMapFrame(DoubleMapFrame):
             self.rasters['first'], self.rasters['second'] = first, second
             res1 = self.SetFirstRaster(name=self.rasters['first'])
             res2 = self.SetSecondRaster(name=self.rasters['second'])
-            if not (res1 and res2) and first and second:
+            if not (res1 and res2) and (first or second):
                 message = ''
-                if not res1:
+                if first and not res1:
                     message += _("Map <%s> not found. ") % self.rasters[
                         'first']
-                if not res2:
+                if second and not res2:
                     message += _("Map <%s> not found.") % self.rasters[
                         'second']
+                if message:
                     GError(parent=self, message=message)
                     return
             self.ZoomToMap()

… aren't choosed

Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
@tmszi tmszi force-pushed the fix-g-gui-mapswipe-apply-btn branch from aa4666f to 7027116 Compare October 25, 2020 08:21
@tmszi tmszi requested a review from petrasovaa October 25, 2020 08:45
@petrasovaa petrasovaa merged commit b1431df into OSGeo:master Oct 27, 2020
neteler pushed a commit that referenced this pull request Oct 28, 2020
@neteler neteler added this to the 7.8.5 milestone Oct 28, 2020
@tmszi tmszi deleted the fix-g-gui-mapswipe-apply-btn branch October 29, 2020 04:42
@neteler neteler changed the title wxGUI/g.gui.mapswipe: fix hit Apply button if first and second raster aren't choosed wxGUI/g.gui.mapswipe: fix hit Apply button if first and second raster aren't chosen Dec 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GUI wxGUI related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants