]> git.lyx.org Git - features.git/commitdiff
avoid an infinite loop while scrolling
authorAlfredo Braunstein <abraunst@lyx.org>
Sun, 20 Mar 2005 17:13:17 +0000 (17:13 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Sun, 20 Mar 2005 17:13:17 +0000 (17:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9724 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/gtk/ChangeLog
src/frontends/gtk/GWorkArea.C
src/frontends/gtk/GWorkArea.h

index b5751582bb164898b11fca5fc0ca3f4cc685556e..4d1fba6832bff1f9a65de49304d711fcc9bad8cb 100644 (file)
@@ -1,3 +1,9 @@
+
+2005-03-20  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * GWorkArea.[Ch] (onScroll, setScrollbarParams): add an adjusting_
+       flag to avoid signal reentrance.
+
 2005-03-20  John Spray  <spray_john@users.sf.net>
 
        * ghelpers.C: use Gtk::Stock::PROPERTIES icon for document
index da1199a13ac54bdc7ef2d7e4adc39dc16226a0cb..ed2e07e4bcfd8c139ebd56bffaabe56b429fea59 100644 (file)
@@ -172,7 +172,8 @@ void inputCommitRelay(GtkIMContext */*imcontext*/, gchar * str, GWorkArea * area
 
 
 GWorkArea::GWorkArea(LyXView & owner, int width, int height)
-       : workAreaPixmap_(0), painter_(*this), draw_(0), colorHandler_(*this)
+       : workAreaPixmap_(0), painter_(*this), draw_(0), colorHandler_(*this),
+         adjusting_(false)
 {
        workArea_.set_size_request(width, height);
        workArea_.set_double_buffered(false);
@@ -337,6 +338,11 @@ bool GWorkArea::onConfigure(GdkEventConfigure * /*event*/)
 
 void GWorkArea::setScrollbarParams(int height, int pos, int line_height)
 {
+       if (adjusting_)
+               return;
+       
+       adjusting_ = true;
+       
        Gtk::Adjustment * adjustment = vscrollbar_.get_adjustment();
        adjustment->set_lower(0);
        int workAreaHeight = workHeight();
@@ -345,6 +351,7 @@ void GWorkArea::setScrollbarParams(int height, int pos, int line_height)
                adjustment->set_page_size(workAreaHeight);
                adjustment->set_value(0);
                adjustment->changed();
+               adjusting_ = false;
                return;
        }
        adjustment->set_step_increment(line_height * 3);
@@ -355,13 +362,20 @@ void GWorkArea::setScrollbarParams(int height, int pos, int line_height)
        adjustment->set_page_size(workAreaHeight);
        adjustment->set_value(pos);
        adjustment->changed();
+       adjusting_ = false;
 }
 
 
 void GWorkArea::onScroll()
 {
+       if (adjusting_)
+               return;
+
+       adjusting_ = true;
+       
        double val = vscrollbar_.get_adjustment()->get_value();
        scrollDocView(static_cast<int>(val));
+       adjusting_ = false;
 }
 
 
index eaeb971e08d51815c61ed2662b4a23393ccaffc8..09e2de0b4cac354b206e886c770ac57761337794 100644 (file)
@@ -109,6 +109,7 @@ private:
        ColorHandler colorHandler_;
        GtkIMContext * imContext_;
        std::string inputCache_;
+       bool adjusting_;
 };
 
 } // namespace frontend