Bug 94205 - Use o3tl::make_unique instead of new + std::move
Summary: Use o3tl::make_unique instead of new + std::move
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:5.3.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2015-09-14 08:03 UTC by Stephan Bergmann
Modified: 2017-02-14 08:57 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Bergmann 2015-09-14 08:03:13 UTC
Some places across the code base that currently instantiate a local std::unique_ptr and then std::move it into a function call can make use of std::make_unique instead (which is only C++14, so we have o3tl::make_unique for now, #include <o3tl/make_unique.hxx>).

For example:

> diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
> index a9b8c69..bab81f6 100644
> --- a/basctl/source/basicide/moduldl2.cxx
> +++ b/basctl/source/basicide/moduldl2.cxx
> @@ -58,7 +58,6 @@
>  #include <cppuhelper/implbase.hxx>
>  
>  #include <cassert>
> -#include <memory>
>  
>  namespace basctl
>  {
> @@ -254,9 +253,9 @@ void CheckBox::InitEntry(SvTreeListEntry* pEntry, const OUString& rTxt,
>          for ( sal_uInt16 nCol = 1; nCol < nCount; ++nCol )
>          {
>              SvLBoxString& rCol = static_cast<SvLBoxString&>(pEntry->GetItem( nCol ));
> -            std::unique_ptr<LibLBoxString> pStr(
> -                   new LibLBoxString( pEntry, 0, rCol.GetText()));
> -            pEntry->ReplaceItem(std::move(pStr), nCol);
> +            pEntry->ReplaceItem(
> +                o3tl::make_unique<LibLBoxString>(pEntry, 0, rCol.GetText()),
> +                nCol);
>          }
>      }
>  }
Comment 1 Berk Gureken 2015-10-01 10:56:35 UTC
I started to work on this bug: 
https://gerrit.libreoffice.org/#/c/19071/
Comment 2 Commit Notification 2015-10-02 15:25:57 UTC
bureken committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=86a8c08a3f7f8412fd1a8659a3e9db5f0d1d8846

tdf#94205 Use o3tl::make_unique instead of new + std::move

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 3 Robinson Tryon (qubit) 2015-12-13 11:04:04 UTC Comment hidden (obsolete)
Comment 4 Commit Notification 2016-01-05 11:49:25 UTC
Sheikha AL-Hinai committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d75b9fd582f0aa83bd2fc99028b3f83eb7171d61

tdf#94205: Use o3tl::make_unique insted of new+std::move.

It will be available in 5.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Robinson Tryon (qubit) 2016-02-18 14:52:00 UTC Comment hidden (obsolete)
Comment 6 Commit Notification 2016-05-30 07:13:45 UTC
krishna keshav committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a7e2d4923b220900f41d0b70904377c771939e6f

tdf#94205  Use o3tl::make_unique instead of new + std::move

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2016-05-30 07:24:37 UTC
apurvapriyadarshi committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=04068eb6f9c153950e4fda75733728fc8922f668

tdf#94205 Use o3tl::make_unique instead of new + std::move

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2016-05-31 11:38:08 UTC
krishna keshav committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9eb08b9534567801988c4137281ff153117edd32

tdf#94205  Use o3tl::make_unique instead of new + std::move

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 jani 2016-06-14 10:00:07 UTC
Seems solved
Comment 10 Commit Notification 2016-06-14 16:19:48 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=83360372383fdcbab18560a5113c92115b166cd5

tdf#94205: Some remaining new+std::move -> o3tl::make_unique

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Stephan Bergmann 2016-06-14 16:21:13 UTC
(In reply to jan iversen from comment #9)
> Seems solved

Yeah, a quick and dirty grep only found a handful of cases now; fixed those with the commit from comment 10.