diff mbox

gui/semanagePage: Close "edit" and "add" dialogues when successfull

Message ID 20180222132933.5643-1-vmojzis@redhat.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Vit Mojzis Feb. 22, 2018, 1:29 p.m. UTC
"Edit" and "add" dialogues weren't closed after successful transaction
("add" and "edit" methods return "None" if successful).

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
 gui/semanagePage.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stephen Smalley Feb. 26, 2018, 2:51 p.m. UTC | #1
On 02/22/2018 08:29 AM, Vit Mojzis wrote:
> "Edit" and "add" dialogues weren't closed after successful transaction
> ("add" and "edit" methods return "None" if successful).

I see the bug, but the behavior after applying the patch also seems to
be wrong:
Traceback (most recent call last):
  File "/usr/share/system-config-selinux/system-config-selinux.py", line
136, in add
    self.tabs[self.notebook.get_current_page()].addDialog()
  File "/usr/share/system-config-selinux/semanagePage.py", line 143, in
addDialog
    if self.add() is False:
  File "/usr/share/system-config-selinux/fcontextPage.py", line 192, in add
    ftype = list_model.get_value(it, 0)
TypeError: Argument 1 does not allow None as a value

> 
> Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
> ---
>  gui/semanagePage.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/gui/semanagePage.py b/gui/semanagePage.py
> index 560ec077..4127804f 100644
> --- a/gui/semanagePage.py
> +++ b/gui/semanagePage.py
> @@ -140,7 +140,7 @@ class semanagePage:
>  
>          while self.dialog.run() == Gtk.ResponseType.OK:
>              try:
> -                if not self.add():
> +                if self.add() is False:
>                      continue
>                  break
>              except ValueError as e:
> @@ -153,7 +153,7 @@ class semanagePage:
>          self.dialog.set_position(Gtk.WindowPosition.MOUSE)
>          while self.dialog.run() == Gtk.ResponseType.OK:
>              try:
> -                if not self.modify():
> +                if self.modify() is False:
>                      continue
>                  break
>              except ValueError as e:
>
Vit Mojzis March 1, 2018, 10:59 a.m. UTC | #2
The traceback was caused by leaving the object class combo box blank (therefore is not directly connected to this patch).
But I agree that is's undesirable behavior. I can either add a check that would notify the user that they left the option blank, or set a default value.
diff mbox

Patch

diff --git a/gui/semanagePage.py b/gui/semanagePage.py
index 560ec077..4127804f 100644
--- a/gui/semanagePage.py
+++ b/gui/semanagePage.py
@@ -140,7 +140,7 @@  class semanagePage:
 
         while self.dialog.run() == Gtk.ResponseType.OK:
             try:
-                if not self.add():
+                if self.add() is False:
                     continue
                 break
             except ValueError as e:
@@ -153,7 +153,7 @@  class semanagePage:
         self.dialog.set_position(Gtk.WindowPosition.MOUSE)
         while self.dialog.run() == Gtk.ResponseType.OK:
             try:
-                if not self.modify():
+                if self.modify() is False:
                     continue
                 break
             except ValueError as e: