mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Fix bug #5796: Context menu of one inset asks status of another inset.
Store the position for the context menu on mouse press. This is also done in qt but then only on the widget level. This avoids that e.g. the edit menu will call getStatus() of math (which causes a crash actually). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30807 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3e9489d870
commit
6e39c317fb
@ -239,7 +239,8 @@ GuiWorkArea::GuiWorkArea(QWidget *)
|
||||
: buffer_view_(0), lyx_view_(0),
|
||||
cursor_visible_(false),
|
||||
need_resize_(false), schedule_redraw_(false),
|
||||
preedit_lines_(1), completer_(new GuiCompleter(this))
|
||||
preedit_lines_(1), completer_(new GuiCompleter(this)),
|
||||
context_target_pos_()
|
||||
{
|
||||
}
|
||||
|
||||
@ -248,7 +249,8 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & gv)
|
||||
: buffer_view_(0), lyx_view_(0),
|
||||
cursor_visible_(false),
|
||||
need_resize_(false), schedule_redraw_(false),
|
||||
preedit_lines_(1), completer_(new GuiCompleter(this))
|
||||
preedit_lines_(1), completer_(new GuiCompleter(this)),
|
||||
context_target_pos_()
|
||||
{
|
||||
setGuiView(gv);
|
||||
setBuffer(buffer);
|
||||
@ -661,7 +663,12 @@ bool GuiWorkArea::event(QEvent * e)
|
||||
|
||||
void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
|
||||
{
|
||||
QPoint pos = e->pos();
|
||||
QPoint pos;
|
||||
if (e->reason() == QContextMenuEvent::Mouse)
|
||||
// the position is set on mouse press
|
||||
pos = context_target_pos_;
|
||||
else
|
||||
pos = e->pos();
|
||||
Cursor const & cur = buffer_view_->cursor();
|
||||
if (e->reason() == QContextMenuEvent::Keyboard && cur.inTexted()) {
|
||||
// Do not access the context menu of math right in front of before
|
||||
@ -729,6 +736,9 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
|
||||
return;
|
||||
}
|
||||
|
||||
if (e->button() == Qt::RightButton)
|
||||
context_target_pos_ = e->pos();
|
||||
|
||||
inputContext()->reset();
|
||||
|
||||
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
|
||||
|
@ -260,6 +260,10 @@ private:
|
||||
/// Special mode in which Esc and Enter (with or without Shift)
|
||||
/// are ignored
|
||||
bool dialog_mode_;
|
||||
/// store the position of the rightclick when the mouse is
|
||||
/// pressed. This is used to get the correct context menu
|
||||
/// when the menu is actually shown (after releasing on Windwos).
|
||||
QPoint context_target_pos_;
|
||||
}; // GuiWorkArea
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user