ctc-oss / fapolicy-analyzer

Tools to assist with the configuration and management of fapolicyd.
https://ctc-oss.github.io/fapolicy-analyzer
GNU General Public License v3.0
11 stars 5 forks source link

Transition away from profiler fails on unsaved changes check #940

Closed jw3 closed 9 months ago

jw3 commented 9 months ago

The logic looking at unsaved changes causes failure when navigating away from the profiler page.

  1. Navigate to the profiler
  2. Navigate away from the profiler
  3. Observe stack trace
Traceback (most recent call last):
  File "/usr/lib64/python3.11/site-packages/fapolicy_analyzer/ui/main_window.py", line 479, in on_configAdminMenu_activate
    self.__pack_main_content(router(PAGE_SELECTION.CONFIG))
  File "/usr/lib64/python3.11/site-packages/fapolicy_analyzer/ui/main_window.py", line 180, in __pack_main_content
    if hasattr(self.__page, "_unsaved_changes") and self.__page._unsaved_changes:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/events/events.py", line 93, in __getattr__
    raise EventsException("Event '%s' is not declared" % name)
events.events.EventsException: Event '_unsaved_changes' is not declared

main_window.py", line 180

ht: https://github.com/ctc-oss/fapolicy-analyzer/discussions/916#discussioncomment-7442237

921

jw3 commented 9 months ago

This issue was weird because it only failed on some UI pages. Looking at the events code

events.py 91

        if hasattr(self, '__events__'):
            if name not in self.__events__:
                raise EventsException("Event '%s' is not declared" % name)

So if the page had declared an __events__ list, the thing has to be in it, otherwise its happy to just introspect the properties of the object.