]> git.lyx.org Git - features.git/commitdiff
Fix bug #7345: Crash when right clicking on displayed math with selection
authorVincent van Ravesteijn <vfr@lyx.org>
Sat, 19 Mar 2011 13:14:13 +0000 (13:14 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Sat, 19 Mar 2011 13:14:13 +0000 (13:14 +0000)
Two things have been fixed here:
1) the selection should not be cleared when the user right clicks a math inset that is part of the selection,
2) the type of context menu should be determined at mouse-press, because that is the moment when the cursor is set. However, we should do it after setting the cursor, because setting the cursor might change the selection status and this influences the choice for the type of context menu.

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

src/frontends/qt4/GuiWorkArea.cpp
src/mathed/InsetMathNest.cpp

index 880706eb366aa3d3153e4ce3d45ed4564c94317a..6e0494202da7ac513a9d73d83d5004a82b8dc55b 100644 (file)
@@ -772,18 +772,20 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
                return;
        }
 
+       inputContext()->reset();
+
+       FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
+               q_button_state(e->button()));
+       dispatch(cmd, q_key_state(e->modifiers()));
+
        // Save the context menu on mouse press, because also the mouse
        // cursor is set on mouse press. Afterwards, we can either release
        // the mousebutton somewhere else, or the cursor might have moved
-       // due to the DEPM.
+       // due to the DEPM. We need to do this after the mouse has been
+       // set in dispatch(), because the selection state might change.
        if (e->button() == Qt::RightButton)
                context_menu_name_ = buffer_view_->contextMenu(e->x(), e->y());
 
-       inputContext()->reset();
-
-       FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
-               q_button_state(e->button()));
-       dispatch(cmd, q_key_state(e->modifiers()));
        e->accept();
 }
 
index 438039196fb903c6335b14ac5e79b133669775e1..21bfdfeea225ed913261ee1ab7834cc937a04f0d 100644 (file)
@@ -1464,6 +1464,15 @@ void InsetMathNest::lfunMousePress(Cursor & cur, FuncRequest & cmd)
 {
        //lyxerr << "## lfunMousePress: buttons: " << cmd.button() << endl;
        BufferView & bv = cur.bv();
+       if (cmd.button() == mouse_button::button3) {
+               // Don't do anything if we right-click a
+               // selection, a context menu will popup.
+               if (bv.cursor().selection() && cur >= bv.cursor().selectionBegin()
+                     && cur < bv.cursor().selectionEnd()) {
+                       cur.noScreenUpdate();
+                       return;
+               }
+       }
        bool do_selection = cmd.button() == mouse_button::button1
                && cmd.argument() == "region-select";
        bv.mouseSetCursor(cur, do_selection);