Author: vfr
Date: Tue Jan 4 01:00:20 2011
New Revision: 37096
URL: http://www.lyx.org/trac/changeset/37096
Log:
Fix bug #5600: View source panel isn't updating after restart.
Modified:
lyx-devel/trunk/src/frontends/qt4/GuiViewSource.cpp
lyx-devel/trunk/src/frontends/qt4/GuiViewSource.h
Modified: lyx-devel/trunk/src/frontends/qt4/GuiViewSource.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiViewSource.cpp Tue Jan 4 00:29:52
2011 (r37095)
+++ lyx-devel/trunk/src/frontends/qt4/GuiViewSource.cpp Tue Jan 4 01:00:20
2011 (r37096)
@@ -43,12 +43,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)),
@@ -89,7 +90,7 @@
\return true if the content has changed since last call.
*/
static bool getContent(BufferView const * view, bool fullSource,
- QString & qstr, string const format)
+ QString & qstr, string const format, bool
force_getcontent)
{
// get the *top* level paragraphs that contain the cursor,
// or the selected text
@@ -110,7 +111,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);
@@ -120,11 +121,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_) {
@@ -139,7 +149,8 @@
outputFormatCO->currentIndex()).toString());
QString content;
- if (getContent(bv_, viewFullSourceCB->isChecked(), content, format))
+ if (getContent(bv_, viewFullSourceCB->isChecked(), content,
+ format, force_getcontent_))
document_->setPlainText(content);
CursorSlice beg = bv_->cursor().selectionBegin().bottom();
Modified: lyx-devel/trunk/src/frontends/qt4/GuiViewSource.h
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiViewSource.h Tue Jan 4 00:29:52
2011 (r37095)
+++ lyx-devel/trunk/src/frontends/qt4/GuiViewSource.h Tue Jan 4 01:00:20
2011 (r37096)
@@ -46,6 +46,8 @@
void updateView();
///
void updateDefaultFormat();
+ ///
+ void fullSourceChanged();
private:
///
@@ -54,6 +56,8 @@
QTextDocument * document_;
/// LaTeX syntax highlighter
LaTeXHighlighter * highlighter_;
+ ///
+ bool force_getcontent_;
};