Hi Yuriy,

I’m seeing a crash after this commit when using File->Open recent.

I’m having 5 files in list and the first entry has nullptr as private data.

@frame 4$ print lastfiles
(lyx::LastFilesSection::LastFiles) $0 = size=5 {
  [0] = {
    d = 0x0000000000000000
  }
  [1] = {
    d = 0x000000012a896df0
  }
  [2] = {
    d = 0x000000012a8921e0
  }
  [3] = {
    d = 0x000000012a8923e0
  }
  [4] = {
    d = 0x000000012a894ed0
  }
}

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS 
(code=1, address=0x0)
    frame #0: 0x00007fff6dfdc695 libc++.1.dylib`std::__1::basic_string<char, 
std::__1::char_traits<char>, std::__1::allocator<char> >::assign(char const*, 
unsigned long) + 19
    frame #1: 0x00007fff6dfdc671 libc++.1.dylib`std::__1::basic_string<char, 
std::__1::char_traits<char>, std::__1::allocator<char> 
>::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, 
std::__1::allocator<char> > const&) + 47
  * frame #2: 0x000000010102c984 
LyX`lyx::support::FileName::operator=(this=0x000000012b8027d0, 
rhs=0x00007ffeefbfb030) at FileName.cpp:178:10
    frame #3: 0x00000001004650a4 LyX`std::__1::vector<lyx::support::FileName, 
std::__1::allocator<lyx::support::FileName> >::insert(this=0x000000012b801770 
size=5, __position=std::__1::vector<lyx::support::FileName, 
std::__1::allocator<lyx::support::FileName> >::const_iterator @ 
0x00007ffeefbfab00, __x=0x00007ffeefbfb030) at vector:1792:18
    frame #4: 0x0000000100464d0d 
LyX`lyx::LastFilesSection::add(this=0x000000012b801760, 
file=0x00007ffeefbfb030) at Session.cpp:89:12
    frame #5: 0x0000000100edb89c 
LyX`lyx::frontend::GuiView::loadDocument(this=0x000000012b85ace0, 
filename=0x00007ffeefbfb030, tolastfiles=true) at GuiView.cpp:2445:28
    frame #6: 0x0000000100edc47a 
LyX`lyx::frontend::GuiView::openDocument(this=0x000000012b85ace0, 
fname="/Users/stephan/Documents/lyxtest/tickets/7349/Dokument1.lyx") at 
GuiView.cpp:2517:17
    frame #7: 0x0000000100bbfd60 
LyX`lyx::frontend::GuiApplication::dispatch(this=0x0000000105fab890, 
cmd=0x000000012ba4f688, dr=0x00007ffeefbfcff0) at GuiApplication.cpp:1773:19
    frame #8: 0x0000000100bbcebd 
LyX`lyx::frontend::GuiApplication::dispatch(this=0x0000000105fab890, 
cmd=0x000000012ba4f688) at GuiApplication.cpp:1484:3
    frame #9: 0x000000010039c14a LyX`lyx::dispatch(action=0x000000012ba4f688) 
at LyX.cpp:1477:19
…

Stephan

> Am 09.01.2021 um 10:24 schrieb Yuriy Skalko <yuriy.ska...@gmail.com>:
> 
> commit 854c9de8faf9eb357adc353fc9116996445d5e38
> Author: Yuriy Skalko <yuriy.ska...@gmail.com>
> Date:   Thu Jan 7 02:27:31 2021 +0200
> 
>    Add move constructor and move assignment operator for FileName class
> ---
> src/support/FileName.cpp |   16 ++++++++++++++++
> src/support/FileName.h   |   14 ++++++++++----
> 2 files changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp
> index 5295741..b9a1d43 100644
> --- a/src/support/FileName.cpp
> +++ b/src/support/FileName.cpp
> @@ -158,6 +158,13 @@ FileName::FileName(FileName const & rhs) : d(new Private)
> }
> 
> 
> +FileName::FileName(FileName && rhs) noexcept
> +     : d(rhs.d)
> +{
> +     rhs.d = nullptr;
> +}
> +
> +
> FileName::FileName(FileName const & rhs, string const & suffix) : d(new 
> Private)
> {
>       set(rhs, suffix);
> @@ -174,6 +181,15 @@ FileName & FileName::operator=(FileName const & rhs)
> }
> 
> 
> +FileName & FileName::operator=(FileName && rhs) noexcept
> +{
> +     auto temp = rhs.d;
> +     rhs.d = d;
> +     d = temp;
> +     return *this;
> +}
> +
> +
> bool FileName::empty() const
> {
>       return d->name.empty();
> diff --git a/src/support/FileName.h b/src/support/FileName.h
> index 1cf1e73..2bc2e48 100644
> --- a/src/support/FileName.h
> +++ b/src/support/FileName.h
> @@ -42,15 +42,21 @@ public:
>        */
>       explicit FileName(std::string const & abs_filename);
> 
> -     /// copy constructor.
> +     /// copy constructor
>       FileName(FileName const &);
> 
> -     /// constructor with base name and suffix.
> +     /// move constructor
> +     FileName(FileName &&) noexcept;
> +
> +     /// constructor with base name and suffix
>       FileName(FileName const & fn, std::string const & suffix);
> 
> -     ///
> +     /// copy assign
>       FileName & operator=(FileName const &);
> 
> +     /// move assign
> +     FileName & operator=(FileName &&) noexcept;
> +
>       virtual ~FileName();
>       /** Set a new filename.
>        * \param filename the file in question. Must have an absolute path.
> @@ -219,7 +225,7 @@ private:
>       bool copyTo(FileName const &, bool, FileNameSet &) const;
>       ///
>       struct Private;
> -     Private * const d;
> +     Private * d;
> };
> 
> 
> -- 
> lyx-cvs mailing list
> lyx-...@lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-cvs

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to