Abdelrazak Younes wrote:
// If this is the only object on the row, we can make it wide
for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
InsetBase const * const in = par.getInset(i);
if (in) {
InsetText const * const t = in->asTextInset();
if (t)
t->Wide() = in_inset_alone_on_row;
}
}
I stand corrected but a const method giving non-const reference access a
mutable variable is not very nice.
I've changed that and added a FIXME.
Abdel.
Author: younes
Date: Tue Nov 7 16:21:47 2006
New Revision: 15779
URL: http://www.lyx.org/trac/changeset/15779
Log:
* InsetText:
- wide_inset_ is not mutable any more
- Wide(): split up in Wide() and setWide()
* rowpainter.C:
- paintPar(): use a const_cast instead of the mutable InsetText::Wide()
Modified:
lyx-devel/trunk/src/insets/insettext.h
lyx-devel/trunk/src/rowpainter.C
Modified: lyx-devel/trunk/src/insets/insettext.h
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/insets/insettext.h?rev=15779
==============================================================================
--- lyx-devel/trunk/src/insets/insettext.h (original)
+++ lyx-devel/trunk/src/insets/insettext.h Tue Nov 7 16:21:47 2006
@@ -133,7 +133,9 @@
///
InsetText(InsetText const &);
///
- bool & Wide() const { return wide_inset_; }
+ bool Wide() const { return wide_inset_; }
+ ///
+ void setWide(bool wide_inset) { wide_inset_ = wide_inset; }
protected:
///
@@ -156,7 +158,7 @@
///
static int border_;
///
- mutable bool wide_inset_;
+ bool wide_inset_;
public:
///
mutable LyXText text_;
Modified: lyx-devel/trunk/src/rowpainter.C
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/rowpainter.C?rev=15779
==============================================================================
--- lyx-devel/trunk/src/rowpainter.C (original)
+++ lyx-devel/trunk/src/rowpainter.C Tue Nov 7 16:21:47 2006
@@ -880,12 +880,17 @@
text);
// If this is the only object on the row, we can make it wide
+ //
+ // FIXME: there is a const_cast here because paintPar() is not
supposed
+ // to touch the paragraph contents. So either we move this
"wide"
+ // property out of InsetText or we localize the feature to the
painting
+ // done here.
for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
InsetBase const * const in = par.getInset(i);
if (in) {
- InsetText const * const t = in->asTextInset();
+ InsetText * t = const_cast<InsetText
*>(in->asTextInset());
if (t)
- t->Wide() = in_inset_alone_on_row;
+ t->setWide(in_inset_alone_on_row);
}
}