Commit 49aa1fd3c6028b2ea2a09f54bf11f768f55c200f

Authored by ksamak
1 parent 192ab1f0

focuspoll: added cleanup of old optimized paths

plugins/focuspoll/include/accessibilitywatcher/accessibilitywatcher.h
... ... @@ -80,6 +80,7 @@ class AccessibilityWatcher {
80 80 static std::string getBrowserURL(AtspiAccessible*);
81 81 static bool getKixCaret (FocusInfo&, const AtspiEvent*);
82 82 static std::tuple<AtspiAccessible*, std::vector<int>> recurseFindCursor(AtspiAccessible*, std::vector<int> &path);
  83 + static void cleanupPaths();
83 84 static AtspiAccessible* getChildFromVector(std::vector<int> path, AtspiAccessible* startPoint);
84 85 static void getAlternativeCaret(FocusInfo& focus, const AtspiEvent* event);
85 86  
... ...
plugins/focuspoll/src/accessibilitywatcher.cpp
... ... @@ -120,7 +120,8 @@ void AccessibilityWatcher::registerEvent (const AtspiEvent *event, const std::st
120 120 g_object_unref (parent);
121 121 parent = child;
122 122 }
123   - g_object_unref (parent);
  123 + if (parent)
  124 + g_object_unref (parent);
124 125 }
125 126  
126 127 AtspiComponent* component;
... ... @@ -489,6 +490,7 @@ AccessibilityWatcher::getKixCaret (FocusInfo&amp; focus, const AtspiEvent* event)
489 490 pathFound.pop_back ();
490 491 pathFound.pop_back ();
491 492 AccessibilityWatcher::getInstance ()->optimizedPaths.insert (AccessibilityWatcher::getInstance ()->optimizedPaths.begin (), pathFound);
  493 + cleanupPaths();
492 494 } else {
493 495 // add the found path to the base path, making it more precise
494 496 pathFound.pop_back ();
... ... @@ -503,6 +505,15 @@ AccessibilityWatcher::getKixCaret (FocusInfo&amp; focus, const AtspiEvent* event)
503 505 return false;
504 506 }
505 507  
  508 +void
  509 +AccessibilityWatcher::cleanupPaths()
  510 +{
  511 + while (AccessibilityWatcher::getInstance ()->optimizedPaths.size() > 3)
  512 + {
  513 + AccessibilityWatcher::getInstance ()->optimizedPaths.pop_back();
  514 + }
  515 +}
  516 +
506 517 AtspiAccessible*
507 518 AccessibilityWatcher::getChildFromVector (std::vector<int> path,
508 519 AtspiAccessible* target)
... ...