From ca8709aaf5f5f14aae1978403e13aac3a93506aa Mon Sep 17 00:00:00 2001 From: Guillaume Munch Date: Thu, 2 Jun 2016 23:49:36 +0100 Subject: [PATCH] Replace boost::scoped_ptr with unique_ptr --- 3rdparty/boost/extract.sh | 1 - src/Buffer.cpp | 5 ++--- src/CutAndPaste.cpp | 4 +++- src/LyX.cpp | 17 ++++++++--------- src/LyXVC.cpp | 5 ----- src/LyXVC.h | 6 ++---- src/client/client.cpp | 8 +++----- src/graphics/GraphicsCacheItem.cpp | 2 +- src/insets/InsetExternal.h | 4 ++-- src/insets/InsetIPA.h | 5 +++-- src/insets/InsetInclude.cpp | 2 +- src/insets/InsetInclude.h | 5 +++-- src/insets/InsetPreview.h | 5 +++-- src/insets/InsetTabular.cpp | 5 ++--- src/mathed/InsetMathHull.h | 4 ++-- src/mathed/InsetMathSymbol.cpp | 7 +++---- 16 files changed, 38 insertions(+), 47 deletions(-) diff --git a/3rdparty/boost/extract.sh b/3rdparty/boost/extract.sh index 64ffbe4a43..4525cf09b3 100755 --- a/3rdparty/boost/extract.sh +++ b/3rdparty/boost/extract.sh @@ -26,7 +26,6 @@ bcp --boost=$1 \ boost/cstdint.hpp \ boost/lexical_cast.hpp \ boost/regex.hpp \ - boost/scoped_ptr.hpp \ boost/signal.hpp \ boost/signals/connection.hpp \ boost/signals/trackable.hpp \ diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b75ddd0d70..431f3f6c92 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1397,9 +1397,8 @@ bool Buffer::save() const // proper location once that has been done successfully. that // way we preserve the original file if something goes wrong. string const justname = fileName().onlyFileNameWithoutExt(); - boost::scoped_ptr - tempfile(new TempFile(fileName().onlyPath(), - justname + "-XXXXXX.lyx")); + auto tempfile = make_unique(fileName().onlyPath(), + justname + "-XXXXXX.lyx"); bool const symlink = fileName().isSymLink(); if (!symlink) tempfile->setAutoRemove(false); diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 44bcb5e962..4d90c6c120 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -62,6 +62,7 @@ #include "support/lstrings.h" #include "support/lyxalgo.h" #include "support/TempFile.h" +#include "support/unique_ptr.h" #include "frontends/alert.h" #include "frontends/Clipboard.h" @@ -1055,7 +1056,8 @@ docstring selection(size_t sel_index, DocumentClassConstPtr docclass) if (sel_index >= theCuts.size()) return docstring(); - boost::scoped_ptr buffer(copyToTempBuffer(theCuts[sel_index].first, docclass)); + unique_ptr buffer(copyToTempBuffer(theCuts[sel_index].first, + docclass)); if (!buffer) return docstring(); diff --git a/src/LyX.cpp b/src/LyX.cpp index d2484d152e..b7b1edf915 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -50,6 +50,7 @@ #include "frontends/alert.h" #include "frontends/Application.h" +#include "support/bind.h" #include "support/ConsoleApplication.h" #include "support/lassert.h" #include "support/debug.h" @@ -61,9 +62,7 @@ #include "support/Messages.h" #include "support/os.h" #include "support/Package.h" - -#include "support/bind.h" -#include +#include "support/unique_ptr.h" #include #include @@ -150,13 +149,13 @@ struct LyX::Impl { /// CmdDef toplevel_cmddef_; /// - boost::scoped_ptr lyx_server_; + unique_ptr lyx_server_; /// - boost::scoped_ptr lyx_socket_; + unique_ptr lyx_socket_; /// - boost::scoped_ptr application_; + unique_ptr application_; /// lyx session, containing lastfiles, lastfilepos, and lastopened - boost::scoped_ptr session_; + unique_ptr session_; /// Files to load at start. vector files_to_load_; @@ -1415,7 +1414,7 @@ Server & theServer() // FIXME: this should not be use_gui dependent LWARNIF(use_gui); LAPPERR(singleton_); - return *singleton_->pimpl_->lyx_server_.get(); + return *singleton_->pimpl_->lyx_server_; } @@ -1424,7 +1423,7 @@ ServerSocket & theServerSocket() // FIXME: this should not be use_gui dependent LWARNIF(use_gui); LAPPERR(singleton_); - return *singleton_->pimpl_->lyx_socket_.get(); + return *singleton_->pimpl_->lyx_socket_; } diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index d48031102b..b28139fb61 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -41,11 +41,6 @@ LyXVC::LyXVC() } -// for the sake of boost::scoped_ptr -LyXVC::~LyXVC() -{} - - bool LyXVC::fileInVC(FileName const & fn) { if (!RCS::findFile(fn).empty()) diff --git a/src/LyXVC.h b/src/LyXVC.h index 3036a396e3..27d935ed73 100644 --- a/src/LyXVC.h +++ b/src/LyXVC.h @@ -12,7 +12,7 @@ #ifndef LYX_VC_H #define LYX_VC_H -#include +#include "support/unique_ptr.h" #include @@ -48,8 +48,6 @@ public: }; /// LyXVC(); - /// - ~LyXVC(); /// Is \p fn under version control? static bool fileInVC(support::FileName const & fn); /** Not a good name perhaps. This function should be called whenever @@ -190,7 +188,7 @@ private: Buffer * owner_; /// - boost::scoped_ptr vcs; + unique_ptr vcs; }; diff --git a/src/client/client.cpp b/src/client/client.cpp index 9c7856014b..f303c1833e 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -19,8 +19,7 @@ #include "support/lstrings.h" #include "support/Messages.h" #include "support/unicode.h" - -#include +#include "support/unique_ptr.h" // getpid(), getppid() #ifdef HAVE_SYS_TYPES_H @@ -61,11 +60,10 @@ #include #include + using namespace std; using namespace lyx::support; -using ::boost::scoped_ptr; - namespace lyx { // Dummy LyXRC support @@ -618,7 +616,7 @@ int LyXClientApp::run() return EXIT_FAILURE; } - scoped_ptr server; + unique_ptr server; if (!cmdline::serverAddress.empty()) { server.reset(new LyXDataSocket(FileName(to_utf8(cmdline::serverAddress)))); diff --git a/src/graphics/GraphicsCacheItem.cpp b/src/graphics/GraphicsCacheItem.cpp index 2e8c415f36..2d004c93e6 100644 --- a/src/graphics/GraphicsCacheItem.cpp +++ b/src/graphics/GraphicsCacheItem.cpp @@ -120,7 +120,7 @@ public: boost::signals::connection cc_; /// - boost::scoped_ptr converter_; + unique_ptr converter_; }; diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index 813e933a0a..70cfaa2510 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -17,8 +17,8 @@ #include "ExternalTemplate.h" #include "support/FileName.h" +#include "support/unique_ptr.h" -#include #include @@ -169,7 +169,7 @@ private: /// The current params InsetExternalParams params_; /// The thing that actually draws the image on LyX's screen. - boost::scoped_ptr renderer_; + unique_ptr renderer_; /// changes color of the button when mouse enters/leaves this inset mutable std::map mouse_hover_; }; diff --git a/src/insets/InsetIPA.h b/src/insets/InsetIPA.h index 783871d8a4..9b702c92b3 100644 --- a/src/insets/InsetIPA.h +++ b/src/insets/InsetIPA.h @@ -16,7 +16,8 @@ #include "Dimension.h" -#include +#include "support/unique_ptr.h" + namespace lyx { @@ -93,7 +94,7 @@ protected: void preparePreview(DocIterator const & pos) const; /// - boost::scoped_ptr preview_; + unique_ptr preview_; }; diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index e9b9600075..1031f3a557 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -1067,7 +1067,7 @@ void InsetInclude::fileChanged() const return; preview_->removePreview(*buffer); - add_preview(*preview_.get(), *this, *buffer); + add_preview(*preview_, *this, *buffer); preview_->startLoading(*buffer); } diff --git a/src/insets/InsetInclude.h b/src/insets/InsetInclude.h index 78d308008c..c844075489 100644 --- a/src/insets/InsetInclude.h +++ b/src/insets/InsetInclude.h @@ -17,7 +17,8 @@ #include "RenderButton.h" -#include +#include "support/unique_ptr.h" + namespace lyx { @@ -164,7 +165,7 @@ private: docstring const include_label; /// The pointer never changes although *preview_'s contents may. - boost::scoped_ptr const preview_; + unique_ptr const preview_; /// mutable bool failedtoload_; diff --git a/src/insets/InsetPreview.h b/src/insets/InsetPreview.h index 1c80f3efd6..d6d693da75 100644 --- a/src/insets/InsetPreview.h +++ b/src/insets/InsetPreview.h @@ -16,7 +16,8 @@ #include "Dimension.h" -#include +#include "support/unique_ptr.h" + namespace lyx { @@ -80,7 +81,7 @@ protected: void preparePreview(DocIterator const & pos) const; /// - boost::scoped_ptr preview_; + unique_ptr preview_; }; diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 6477ef3fe6..f56991470c 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -61,8 +61,7 @@ #include "support/gettext.h" #include "support/lassert.h" #include "support/lstrings.h" - -#include +#include "support/unique_ptr.h" #include #include @@ -96,7 +95,7 @@ int const WIDTH_OF_LINE = 5; // space between double lines /// -boost::scoped_ptr paste_tabular; +unique_ptr paste_tabular; struct TabularFeature { diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index c12fcc7593..1fdf0d098a 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -17,7 +17,7 @@ #include "DocIterator.h" #include "OutputEnums.h" -#include +#include "support/unique_ptr.h" namespace lyx { @@ -258,7 +258,7 @@ private: /// std::vector label_; /// - boost::scoped_ptr preview_; + unique_ptr preview_; /// DocIterator docit_; /// diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp index a04f6e0bcf..5a86536b52 100644 --- a/src/mathed/InsetMathSymbol.cpp +++ b/src/mathed/InsetMathSymbol.cpp @@ -22,8 +22,7 @@ #include "support/debug.h" #include "support/docstream.h" #include "support/textutils.h" - -#include +#include "support/unique_ptr.h" namespace lyx { @@ -255,9 +254,9 @@ void InsetMathSymbol::octave(OctaveStream & os) const void InsetMathSymbol::write(WriteStream & os) const { - boost::scoped_ptr ensurer; + unique_ptr ensurer; if (currentMode() != TEXT_MODE) - ensurer.reset(new MathEnsurer(os)); + ensurer = make_unique(os); os << '\\' << name(); // $,#, etc. In theory the restriction based on catcodes, but then