Contextbrowser: Minor improvement to tooltip showing behavior

Authored by thomassc on Jul 21 2019, 6:07 PM.


Contextbrowser: Minor improvement to tooltip showing behavior

The aim is to decide properly when the currently shown tooltip needs to be updated and when it doesn't, based on the problems and declaration that are currently being displayed in the tooltip (stored in m_currentToolTipProblems and m_currentToolTipDeclaration), and the new problems and declaration that are under the cursor now (in problems and decl).

Old line 612: The old version always keeps showing the current tooltip if the problems haven't changed and there is no declaration. But there might have been a declaration before, and in this case this declaration's info would incorrectly be continued to be shown. The new version fixes that by removing the "!decl" part and thus always also testing for existence/equality of the declaration.

Old lines 616 .. 648: In case there is no declaration (!decl), the old version does not remember this in m_currentToolTipDeclaration at the top of this block. But the problems are always remembered. In the new version, the logic is clarified: If either there are problems or there is a declaration, then the current state concerning both is remembered in m_currentToolTipProblems and m_currentToolTipDeclaration, and corresponding widgets will be created in the code below. If not, m_currentToolTipProblems and m_currentToolTipDeclaration aren't touched yet, since there is additional code below that handles additional cases.

New lines 665 .. 669: Here the check is extended to also test for equality of the declaration, i.e., for no declaration, since this case is about to show a problems-only tooltip.

New line 672: Here the code is extended to remember the current state of both the problems and the declaration in the tooltip.

New line 684: If the execution reaches this point, neither a problem nor a declaration has been found that shall be displayed. So, instead of returning nullptr and thus continuing to show whatever tooltip is currently being shown, the correct behavior should be to stop showing the tooltip if there is any.