diff --git a/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h b/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h index 190f7e1305172296394eda287b11c8690990d327..d0bc9c6d865d03e4d95023ce864022599ea9fd33 100644 --- a/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h +++ b/plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h @@ -80,6 +80,7 @@ class AccessibilityWatcher { static std::string getBrowserURL(AtspiAccessible*); static bool getKixCaret (FocusInfo&, const AtspiEvent*); static std::tuple> recurseFindCursor(AtspiAccessible*, std::vector &path); + static void cleanupPaths(); static AtspiAccessible* getChildFromVector(std::vector path, AtspiAccessible* startPoint); static void getAlternativeCaret(FocusInfo& focus, const AtspiEvent* event); diff --git a/plugins/focuspoll/src/accessibilitywatcher.cpp b/plugins/focuspoll/src/accessibilitywatcher.cpp index e3c5063970a076f7c59e60311060962a11cfb122..1d6f4a36556b067cbcddb1eea5f6dbf172538dc4 100644 --- a/plugins/focuspoll/src/accessibilitywatcher.cpp +++ b/plugins/focuspoll/src/accessibilitywatcher.cpp @@ -120,7 +120,8 @@ void AccessibilityWatcher::registerEvent (const AtspiEvent *event, const std::st g_object_unref (parent); parent = child; } - g_object_unref (parent); + if (parent) + g_object_unref (parent); } AtspiComponent* component; @@ -489,6 +490,7 @@ AccessibilityWatcher::getKixCaret (FocusInfo& focus, const AtspiEvent* event) pathFound.pop_back (); pathFound.pop_back (); AccessibilityWatcher::getInstance ()->optimizedPaths.insert (AccessibilityWatcher::getInstance ()->optimizedPaths.begin (), pathFound); + cleanupPaths(); } else { // add the found path to the base path, making it more precise pathFound.pop_back (); @@ -503,6 +505,15 @@ AccessibilityWatcher::getKixCaret (FocusInfo& focus, const AtspiEvent* event) return false; } +void +AccessibilityWatcher::cleanupPaths() +{ + while (AccessibilityWatcher::getInstance ()->optimizedPaths.size() > 3) + { + AccessibilityWatcher::getInstance ()->optimizedPaths.pop_back(); + } +} + AtspiAccessible* AccessibilityWatcher::getChildFromVector (std::vector path, AtspiAccessible* target)