]> git.lyx.org Git - lyx.git/commitdiff
Towards bug http://bugzilla.lyx.org/show_bug.cgi?id=4830
authorPavel Sanda <sanda@lyx.org>
Tue, 29 Jul 2008 01:51:20 +0000 (01:51 +0000)
committerPavel Sanda <sanda@lyx.org>
Tue, 29 Jul 2008 01:51:20 +0000 (01:51 +0000)
(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

src/frontends/Selection.h
src/frontends/qt4/GuiSelection.cpp
src/frontends/qt4/GuiSelection.h

index ac902ffc1eaafcaef57e201ddf59fd9ff5d8ab73..fb835e7ffb95cce93d7af020100ce5b2d92fc475 100644 (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
index f483a3b1b2cd3b03ea3db14ff5dd6e8bebb21bd5..0f6fb88ac5ebc9d84e27d855c764a4733d2dea21 100644 (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_;
 }
 
index c7f2096aa82ae93f3ece9864adca99b3021776cb..f76dc2642c99cf92e4613a2e0cafc7aec428c9a3 100644 (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_;
 };