From 42d79d543b236e56edd3fb9b83157a90a7d85094 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 13 May 2008 21:28:04 +0000 Subject: [PATCH] Fix bug http://bugzilla.lyx.org/show_bug.cgi?id=4860 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24754 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiViewSource.cpp | 24 +++++++++++++++++------- src/frontends/qt4/GuiViewSource.h | 3 +-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index cbd10f7c18..97536d734e 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -68,8 +68,15 @@ ViewSourceWidget::ViewSourceWidget(GuiViewSource & controller) void ViewSourceWidget::updateView() { + BufferView * view = controller_.bufferview(); + if (!view) { + document_->setPlainText(QString()); + setEnabled(false); + return; + } if (autoUpdateCB->isChecked()) - update(viewFullSourceCB->isChecked()); + document_->setPlainText(controller_.getContent( + viewFullSourceCB->isChecked())); GuiViewSource::Row row = controller_.getRows(); QTextCursor c = QTextCursor(viewSourceTV->document()); @@ -81,12 +88,6 @@ void ViewSourceWidget::updateView() } -void ViewSourceWidget::update(bool full_source) -{ - document_->setPlainText(controller_.getContent(full_source)); -} - - GuiViewSource::GuiViewSource(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags) : DockView(parent, "view-source", qt_("LaTeX Source"), area, flags) @@ -108,6 +109,15 @@ void GuiViewSource::updateView() } +void GuiViewSource::enableView(bool enable) +{ + if (!enable) + // In the opposite case, updateView() will be called anyway. + widget_->updateView(); + widget_->setEnabled(enable); +} + + bool GuiViewSource::initialiseParams(string const & /*source*/) { setWindowTitle(title()); diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index 51a3e94cb6..c409f7cff8 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -44,8 +44,6 @@ public: public Q_SLOTS: // update content void updateView(); - /// - void update(bool full_source); private: /// @@ -78,6 +76,7 @@ public: bool canApply() const { return true; } bool canApplyToReadOnly() const { return true; } void updateView(); + void enableView(bool enable); ///@} /// The title displayed by the dialog reflects source type.