From 79a947c9041a92805e9ac4b65594753410016fa5 Mon Sep 17 00:00:00 2001 From: Guillaume Munch Date: Wed, 28 Sep 2016 21:57:54 +0200 Subject: [PATCH] Work around dangling pointer A better solution would be to entirely get rid of this borrowed pointer with unclear lifetime, but this requires to introduce a new signal for when the buffer view attached to the GuiView has changed. --- src/frontends/qt4/GuiViewSource.cpp | 8 ++++---- src/frontends/qt4/GuiViewSource.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index db50b47c3c..31013a79c9 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -310,11 +310,11 @@ void ViewSourceWidget::realUpdateView() } -docstring ViewSourceWidget::currentFormatName() const +docstring ViewSourceWidget::currentFormatName(BufferView const * bv) const { // Compute the actual format used - string const format = !bv_ ? "" - : flavor2format(bv_->buffer().params().getOutputFlavor(view_format_)); + string const format = !bv ? "" + : flavor2format(bv->buffer().params().getOutputFlavor(view_format_)); Format const * f = formats.getFormat(format.empty() ? view_format_ : format); return f ? f->prettyname() : from_utf8(view_format_); } @@ -454,7 +454,7 @@ bool GuiViewSource::initialiseParams(string const & /*source*/) void GuiViewSource::updateTitle() { - docstring const format = widget_->currentFormatName(); + docstring const format = widget_->currentFormatName(bufferview()); QString const title = format.empty() ? qt_("Code Preview") : qt_("%1[[preview format name]] Preview") .arg(toqstr(translateIfPossible(format))); diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index e4718d71b2..055bef31eb 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -71,7 +71,7 @@ public Q_SLOTS: /// void gotoCursor(); /// Name of the current format. Empty if none. - docstring currentFormatName() const; + docstring currentFormatName(BufferView const * bv) const; Q_SIGNALS: void formatChanged() const; -- 2.39.2