diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 88ffe6241..28cf77df9 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -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 ) diff --git a/ui/pageviewmouseannotation.cpp b/ui/pageviewmouseannotation.cpp index dbd483a5d..e0e7992fc 100644 --- a/ui/pageviewmouseannotation.cpp +++ b/ui/pageviewmouseannotation.cpp @@ -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 ) { diff --git a/ui/pageviewmouseannotation.h b/ui/pageviewmouseannotation.h index 6a131d01c..be8e5c0c0 100644 --- a/ui/pageviewmouseannotation.h +++ b/ui/pageviewmouseannotation.h @@ -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. */