]> git.lyx.org Git - features.git/commitdiff
Fix another crash due to BufferView::last_inset_ being an invalid pointer.
authorVincent van Ravesteijn <vfr@lyx.org>
Sun, 2 May 2010 19:12:25 +0000 (19:12 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Sun, 2 May 2010 19:12:25 +0000 (19:12 +0000)
Now, we only want to let the last_inset_ pointer point at insets that accept the mouse_hover setting. Otherwise, the pointer is not cleared on deletion of the inset.

See also r33908, r34117, r34348, r34353 and bug #3900.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34354 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp

index 0d852f500e11da857257b974340d76f17a946c3c..3050a7b498e5d03b1674cfa47726e76666bd17c2 100644 (file)
@@ -1895,18 +1895,22 @@ void BufferView::updateHoveredInset() const
                return;
 
        bool need_redraw = false;
-       if (d->last_inset_)
+       if (d->last_inset_) {
                // Remove the hint on the last hovered inset (if any).
                need_redraw |= d->last_inset_->setMouseHover(this, false);
+               d->last_inset_ = 0;
+       }
        
        // const_cast because of setMouseHover().
        Inset * inset = const_cast<Inset *>(covering_inset);
-       if (inset)
-               // Highlight the newly hovered inset (if any).
-               need_redraw |= inset->setMouseHover(this, true);
+       if (inset && inset->setMouseHover(this, true)) {
+               need_redraw = true;
+               // Only the insets that accept the hover state, do 
+               // clear the last_inset_, so only set the last_inset_
+               // member if the hovered setting is accepted.
+               d->last_inset_ = inset;
+       }
 
-       d->last_inset_ = inset;
-       
        if (need_redraw) {
                LYXERR(Debug::PAINTING, "Mouse hover detected at: ("
                                << d->mouse_position_cache_.x_ << ", "