Fix segfault when document is closed while annotation is selected

Prevent MouseAnnotation from accessing PageViewItem widgets any longer
after PageView deletes them in PageView::notifySetup().

BUGS: 378696
REVIEW: 130087
remotes/origin/Applications/17.04 v17.04.0
Tobias Deiminger 9 years ago committed by Albert Astals Cid
parent b23df4ef98
commit 69dca1e7dd
  1. 3
      ui/pageview.cpp
  2. 7
      ui/pageviewmouseannotation.cpp
  3. 3
      ui/pageviewmouseannotation.h

@ -956,6 +956,9 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
return;
}
// mouseAnnotation must not access our PageViewItem widgets any longer
d->mouseAnnotation->reset();
// delete all widgets (one for each page in pageSet)
QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd();
for ( ; dIt != dEnd; ++dIt )

@ -414,6 +414,13 @@ void MouseAnnotation::cancel()
}
}
void MouseAnnotation::reset()
{
cancel();
m_focusedAnnotation.invalidate();
m_mouseOverAnnotation.invalidate();
}
/* Handle state changes for the focused annotation. */
void MouseAnnotation::setState( MouseAnnotationState state, const AnnotationDescription & ad )
{

@ -93,6 +93,9 @@ public:
/* Cancel the current selection or action, if any. */
void cancel();
/* Reset to initial state. Cancel current action and relinquish references to PageViewItem widgets. */
void reset();
Okular::Annotation * annotation() const;
/* Return true, if MouseAnnotation demands control for a mouse click on the current cursor position. */

Loading…
Cancel
Save