(selection issues on more LyX instances)

This fixes for me the worst cases. Still some selection
problem appear from time to time and it will be tricky
to get this completely right since the performance 'hacks'
our code uses.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25950 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2008-07-29 01:51:20 +00:00
parent 716626c736
commit 609878cf00
3 changed files with 19 additions and 7 deletions

View File

@ -62,7 +62,7 @@ public:
* This does always return true on systems that don't have a real
* selection.
*/
virtual bool empty() const = 0;
virtual bool empty() = 0;
};
} // namespace frontend

View File

@ -91,19 +91,21 @@ void GuiSelection::put(docstring const & str)
void GuiSelection::on_dataChanged()
{
text_selection_empty_ = qApp->clipboard()->
text(QClipboard::Selection).isEmpty();
LYXERR(Debug::SELECTION, "GuiSelection::on_dataChanged::filled: " << !text_selection_empty_);
schedule_check_ = true;
LYXERR(Debug::SELECTION, "GuiSelection::on_dataChanged");
}
bool GuiSelection::empty() const
bool GuiSelection::empty()
{
if (!selection_supported_)
return true;
LYXERR(Debug::SELECTION, "GuiSelection::filled: " << !text_selection_empty_);
if (schedule_check_)
text_selection_empty_ = qApp->clipboard()->
text(QClipboard::Selection).isEmpty();
LYXERR(Debug::SELECTION, "GuiSelection::filled: " << !text_selection_empty_);
return text_selection_empty_;
}

View File

@ -37,14 +37,24 @@ public:
void haveSelection(bool own);
docstring const get() const;
void put(docstring const & str);
bool empty() const;
bool empty();
//@}
private Q_SLOTS:
void on_dataChanged();
private:
// Cache which is to speed up selection-status read
// (4 calls when openi Edit menu).
bool text_selection_empty_;
// Direct call clipboard()->text(QClipboard::Selection) inside onDataChanged causes
// selection to be obtained. Now imagine the some LyX instance A, when making selection -
// each change triggers onDataChange in all others instances for each mouse
// or keyboard move. This in turn causes many calls of requestSelection in A
// which interferes with the selecting itself. As a result middle button pasting
// for more instances don't work and debugging is a hell. So we just schedule
// obtaining of selection on the time empty() is actually called.
bool schedule_check_;
bool const selection_supported_;
};