]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/Dialog.cpp
Amend f441590c
[lyx.git] / src / frontends / qt4 / Dialog.cpp
index dca7ded900f0d22c35447e613ed2c12ca9bba176..a9c1250b6eb5276660816435c370d06f2b8eae11 100644 (file)
@@ -118,16 +118,14 @@ BufferView const * Dialog::bufferview() const
 
 Buffer const & Dialog::buffer() const
 {
-       LAPPERR(lyxview_->currentBufferView(),
-               _("Dialog has no associated Buffer!"));
+       LAPPERR(lyxview_->currentBufferView());
        return lyxview_->currentBufferView()->buffer();
 }
 
 
 Buffer const & Dialog::documentBuffer() const
 {
-       LAPPERR(lyxview_->currentBufferView(),
-               _("Dialog has no associated Buffer!"));
+       LAPPERR(lyxview_->documentBufferView());
        return lyxview_->documentBufferView()->buffer();
 }
 
@@ -221,11 +219,23 @@ bool Dialog::isVisibleView() const
 
 Inset const * Dialog::inset(InsetCode code) const
 {
+       // ins: the innermost inset of the type we look for
+       //      that contains the cursor
        Inset * ins = bufferview()->cursor().innerInsetOfType(code);
-       if (!ins)
-               ins = bufferview()->cursor().nextInset();
-       if (!ins || ins->lyxCode() != code)
-               return 0;
+       // next: a potential inset at cursor position
+       Inset * next = bufferview()->cursor().nextInset();
+       // Check if next is of the type we look for
+       if (next)
+               if (next->lyxCode() != code)
+                       next = 0;
+       if (ins) {
+               // prefer next if it is of the requested type (bug 8716)
+               if (next)
+                       ins = next;
+       } else
+               // no containing inset of requested type
+               // use next (which might also be 0)
+               ins = next;
        return ins;
 }