Author: vfr
Date: Tue Jan  4 11:12:40 2011
New Revision: 37103
URL: http://www.lyx.org/trac/changeset/37103

Log:
branch: Fix bug #5600: View source panel isn't updating after restart.

see r37096.

Modified:
   lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/GuiViewSource.cpp
   lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/GuiViewSource.h
   lyx-devel/branches/BRANCH_1_6_X/status.16x

Modified: lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/GuiViewSource.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/GuiViewSource.cpp Tue Jan 
 4 10:49:30 2011        (r37102)
+++ lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/GuiViewSource.cpp Tue Jan 
 4 11:12:40 2011        (r37103)
@@ -42,12 +42,13 @@
 
 ViewSourceWidget::ViewSourceWidget()
        :       bv_(0), document_(new QTextDocument(this)),
-               highlighter_(new LaTeXHighlighter(document_))
+               highlighter_(new LaTeXHighlighter(document_)),
+               force_getcontent_(true)
 {
        setupUi(this);
 
        connect(viewFullSourceCB, SIGNAL(clicked()),
-               this, SLOT(updateView()));
+               this, SLOT(fullSourceChanged()));
        connect(autoUpdateCB, SIGNAL(toggled(bool)),
                updatePB, SLOT(setDisabled(bool)));
        connect(autoUpdateCB, SIGNAL(toggled(bool)),
@@ -85,7 +86,8 @@
        \param fullSource get full source code
        \return true if the content has changed since last call.
  */
-static bool getContent(BufferView const * view, bool fullSource, QString & 
qstr)
+static bool getContent(BufferView const * view, bool fullSource,
+                      QString & qstr, bool force_getcontent)
 {
        // get the *top* level paragraphs that contain the cursor,
        // or the selected text
@@ -106,7 +108,7 @@
        docstring s = ostr.str();
        static size_t crc = 0;
        size_t newcrc = crcCheck(s);
-       if (newcrc == crc)
+       if (newcrc == crc && !force_getcontent)
                return false;
        crc = newcrc;
        qstr = toqstr(s);
@@ -116,11 +118,20 @@
 
 void ViewSourceWidget::setBufferView(BufferView const * bv)
 {
+       if (bv_ != bv)
+               force_getcontent_ = true;
        bv_ = bv;
        setEnabled(bv ?  true : false);
 }
 
 
+void ViewSourceWidget::fullSourceChanged()
+{
+       if (autoUpdateCB->isChecked())
+               updateView();
+}
+
+
 void ViewSourceWidget::updateView()
 {
        if (!bv_) {
@@ -132,7 +143,8 @@
        setEnabled(true);
 
        QString content;
-       if (getContent(bv_, viewFullSourceCB->isChecked(), content))
+       if (getContent(bv_, viewFullSourceCB->isChecked(), content,
+                 force_getcontent_))
                document_->setPlainText(content);
 
        CursorSlice beg = bv_->cursor().selectionBegin().bottom();

Modified: lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/GuiViewSource.h
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/GuiViewSource.h   Tue Jan 
 4 10:49:30 2011        (r37102)
+++ lyx-devel/branches/BRANCH_1_6_X/src/frontends/qt4/GuiViewSource.h   Tue Jan 
 4 11:12:40 2011        (r37103)
@@ -44,6 +44,8 @@
 public Q_SLOTS:
        // update content
        void updateView();
+       ///
+       void fullSourceChanged();
 
 private:
        ///
@@ -52,6 +54,8 @@
        QTextDocument * document_;
        /// LaTeX syntax highlighter
        LaTeXHighlighter * highlighter_;
+       ///
+       bool force_getcontent_;
 };
 
 

Modified: lyx-devel/branches/BRANCH_1_6_X/status.16x
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/status.16x  Tue Jan  4 10:49:30 2011        
(r37102)
+++ lyx-devel/branches/BRANCH_1_6_X/status.16x  Tue Jan  4 11:12:40 2011        
(r37103)
@@ -163,6 +163,9 @@
   statusbar for recent files items; absolute paths in tooltips of
   tabs; and longer paths in the window title (bug 7182).
 
+- Fix the response of the update button of the view source window
+  after reopening a file (bug 5600).
+
 
 * DOCUMENTATION AND LOCALIZATION
 

Reply via email to