[LyX/master] When a displayed inset is aligned left, align it left

José Matos jaomatos at gmail.com
Mon Mar 6 11:02:04 UTC 2023


On Sun, 2023-03-05 at 19:57 +0100, Jean-Marc Lasgouttes wrote:
> commit 7d78078838710ed154638cd6bd38885ffe927248
> Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
> Date:   Sun Mar 5 20:54:39 2023 +0100
> 
>     When a displayed inset is aligned left, align it left
>     
>     The use of LYX_ALIGN_BLOCK was a mistake.
>     
>     Fixes bug #12683.
> ---
>  src/TextMetrics.cpp |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
> index 995b09c..7acf5ff 100644
> --- a/src/TextMetrics.cpp
> +++ b/src/TextMetrics.cpp
> @@ -621,7 +621,7 @@ LyXAlignment TextMetrics::getAlign(Paragraph
> const & par, Row const & row) const
>         if (Inset const * inset = par.getInset(row.pos())) {
>                 if (inset->rowFlags() & Display) {
>                         if (inset->rowFlags() & AlignLeft)
> -                               align = LYX_ALIGN_BLOCK;
> +                               align = LYX_ALIGN_LEFT;
>                         else if (inset->rowFlags() & AlignRight)
>                                 align = LYX_ALIGN_RIGHT;
>                         else

Previous disclaimer: What I am sending is not result of the change
above but I it noticed because when updating the code
src/TextMetrics.cpp had to compiled again.

There I saw this warning that follows attached:

warning: possibly dangling reference to a temporary

I think that we discussed this but I do not remember any more its
outcome.

The complete warning follows attached,
-- 
José Abílio
-------------- next part --------------
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp: In member function ‘int lyx::TextMetrics::labelFill(const lyx::Row&) const’:
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp:782:29: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  782 |         FontMetrics const & fm
      |                             ^~
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp:783:33: note: the temporary was destroyed at the end of the full expression ‘lyx::theFontMetrics(((lyx::Text*)((const lyx::TextMetrics*)this)->lyx::TextMetrics::text_)->lyx::Text::labelFont((* & par)))’
  783 |                 = theFontMetrics(text_->labelFont(par));
      |                   ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp: In member function ‘lyx::Row lyx::TextMetrics::tokenizeParagraph(lyx::pit_type) const’:
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp:898:45: warning: possibly dangling reference to a temporary [-Wdangling-reference]
  898 |                         FontMetrics const & fm = theFontMetrics(text_->labelFont(par));
      |                                             ^~
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp:898:64: note: the temporary was destroyed at the end of the full expression ‘lyx::theFontMetrics(((lyx::Text*)((const lyx::TextMetrics*)this)->lyx::TextMetrics::text_)->lyx::Text::labelFont((* & par)))’
  898 |                         FontMetrics const & fm = theFontMetrics(text_->labelFont(par));
      |                                                  ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp: In member function ‘int lyx::TextMetrics::leftMargin(lyx::pit_type, lyx::pos_type) const’:
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp:1755:29: warning: possibly dangling reference to a temporary [-Wdangling-reference]
 1755 |         FontMetrics const & bfm = theFontMetrics(buffer.params().getFont());
      |                             ^~~
/home/jamatos/lyx/lyx.anon/src/TextMetrics.cpp:1755:49: note: the temporary was destroyed at the end of the full expression ‘lyx::theFontMetrics((&(& buffer)->lyx::Buffer::params())->lyx::BufferParams::getFont())’
 1755 |         FontMetrics const & bfm = theFontMetrics(buffer.params().getFont());
      |                                   ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~


More information about the lyx-devel mailing list