From b032e2dfafbf1e86918dd0cd66e5de602edeee00 Mon Sep 17 00:00:00 2001 From: Guillaume Munch Date: Thu, 2 Jun 2016 18:13:55 +0100 Subject: [PATCH] Replace support/shared_ptr.h and boost::shared_ptr with std::shared_ptr shared_ptrs now only require the header. --- src/Buffer.cpp | 4 ++-- src/BufferParams.cpp | 2 +- src/DocumentClassPtr.h | 6 +++--- src/KeyMap.h | 5 ++--- src/OutputParams.h | 5 +++-- src/ServerSocket.cpp | 3 +-- src/ServerSocket.h | 5 ++--- src/Toc.h | 9 ++++----- src/TocBackend.cpp | 19 ++++++++----------- src/TocBackend.h | 4 +++- src/frontends/qt4/Menus.cpp | 6 +----- src/frontends/qt4/TocModel.cpp | 4 ++-- src/frontends/qt4/TocModel.h | 6 ++---- src/graphics/GraphicsCache.h | 7 +++---- src/graphics/GraphicsCacheItem.cpp | 8 ++++---- src/graphics/GraphicsLoader.cpp | 5 +++-- src/graphics/PreviewLoader.cpp | 5 +++-- src/insets/InsetTabular.cpp | 8 ++++---- src/insets/InsetTabular.h | 6 ++++-- src/output_xhtml.h | 8 ++++---- src/support/ForkedCalls.cpp | 2 +- src/support/ForkedCalls.h | 8 ++++++-- src/support/Makefile.am | 1 - src/support/shared_ptr.h | 25 ------------------------- 24 files changed, 66 insertions(+), 95 deletions(-) delete mode 100644 src/support/shared_ptr.h diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 431f3f6c92..084b94c03f 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -107,12 +107,12 @@ #include "support/types.h" #include "support/bind.h" -#include "support/shared_ptr.h" #include #include #include #include +#include #include #include #include @@ -3847,7 +3847,7 @@ public: /// virtual shared_ptr clone() const { - return shared_ptr(new AutoSaveBuffer(*this)); + return make_shared(*this); } /// int start() diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index bcf8d64503..2d113bad45 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2205,7 +2205,7 @@ bool BufferParams::hasClassDefaults() const DocumentClass const & BufferParams::documentClass() const { - return *doc_class_.get(); + return *doc_class_; } diff --git a/src/DocumentClassPtr.h b/src/DocumentClassPtr.h index eef9ac2675..b2c95a0023 100644 --- a/src/DocumentClassPtr.h +++ b/src/DocumentClassPtr.h @@ -12,13 +12,13 @@ #ifndef DOCUMENT_CLASS_PTR_H #define DOCUMENT_CLASS_PTR_H -#include "support/shared_ptr.h" +#include namespace lyx { class DocumentClass; -typedef shared_ptr DocumentClassPtr; -typedef shared_ptr DocumentClassConstPtr; +typedef std::shared_ptr DocumentClassPtr; +typedef std::shared_ptr DocumentClassConstPtr; } #endif // DISPATCH_RESULT_H diff --git a/src/KeyMap.h b/src/KeyMap.h index cd28782356..f6a82c082c 100644 --- a/src/KeyMap.h +++ b/src/KeyMap.h @@ -19,8 +19,7 @@ #include "support/strfwd.h" -#include "support/shared_ptr.h" - +#include #include @@ -163,7 +162,7 @@ private: /// Modifier masks ModifierPair mod; /// Keymap for prefix keys - shared_ptr prefixes; + std::shared_ptr prefixes; /// Action for !prefix keys FuncRequest func; }; diff --git a/src/OutputParams.h b/src/OutputParams.h index 16fe7c4a76..ccb0783a2a 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -13,9 +13,10 @@ #define OUTPUTPARAMS_H -#include "support/shared_ptr.h" #include "Changes.h" +#include + namespace lyx { @@ -182,7 +183,7 @@ public: This is a hack: Make it possible to add stuff to constant OutputParams instances. */ - shared_ptr exportdata; + std::shared_ptr exportdata; /** Whether we are inside a comment inset. Insets that are including * external files like InsetGraphics, InsetInclude and InsetExternal diff --git a/src/ServerSocket.cpp b/src/ServerSocket.cpp index fb6e3bf75c..72a70d4eda 100644 --- a/src/ServerSocket.cpp +++ b/src/ServerSocket.cpp @@ -110,8 +110,7 @@ void ServerSocket::serverCallback() } // Register the new client. - clients[client_fd] = - shared_ptr(new LyXDataSocket(client_fd)); + clients[client_fd] = make_shared(client_fd); theApp()->registerSocketCallback( client_fd, bind(&ServerSocket::dataCallback, diff --git a/src/ServerSocket.h b/src/ServerSocket.h index 7364250e17..c66658042f 100644 --- a/src/ServerSocket.h +++ b/src/ServerSocket.h @@ -16,10 +16,9 @@ #include "support/FileName.h" -#include "support/shared_ptr.h" - #include #include +#include namespace lyx { @@ -60,7 +59,7 @@ private: MAX_CLIENTS = 10 }; /// All connections - std::map > clients; + std::map> clients; }; diff --git a/src/Toc.h b/src/Toc.h index 82f7ce1701..bd6bdf2d4b 100644 --- a/src/Toc.h +++ b/src/Toc.h @@ -15,9 +15,8 @@ #ifndef TOC_H #define TOC_H -#include "support/shared_ptr.h" - #include +#include #include #include @@ -29,12 +28,12 @@ class TocItem; typedef std::vector Toc; -class TocList : public std::map > +class TocList : public std::map> { private: // TocList should never map to null pointers. - // We forbid the following method which creates null pointers. - using std::map >::operator[]; + // We hide the following methods which create null pointers. + using std::map>::operator[]; }; diff --git a/src/TocBackend.cpp b/src/TocBackend.cpp index 6526c57537..e8c430d8eb 100644 --- a/src/TocBackend.cpp +++ b/src/TocBackend.cpp @@ -153,7 +153,7 @@ Toc::iterator TocBackend::findItem(Toc & toc, int depth, docstring const & str) /////////////////////////////////////////////////////////////////////////// TocBuilder::TocBuilder(shared_ptr toc) - : toc_(toc ? toc : lyx::make_shared()), + : toc_(toc ? toc : make_shared()), stack_() { LATTEST(toc); @@ -214,13 +214,11 @@ void TocBuilder::pop() /////////////////////////////////////////////////////////////////////////// shared_ptr TocBuilderStore::get(string const & type, - shared_ptr toc) + shared_ptr toc) { map_t::const_iterator it = map_.find(type); - if (it == map_.end()) { - it = map_.insert(std::make_pair(type, - lyx::make_shared(toc))).first; - } + if (it == map_.end()) + it = map_.insert(make_pair(type, make_shared(toc))).first; return it->second; } @@ -236,7 +234,7 @@ shared_ptr TocBackend::toc(string const & type) const { // Is the type already supported? TocList::const_iterator it = tocs_.find(type); - LASSERT(it != tocs_.end(), { return lyx::make_shared(); }); + LASSERT(it != tocs_.end(), { return make_shared(); }); return it->second; } @@ -244,9 +242,8 @@ shared_ptr TocBackend::toc(string const & type) const shared_ptr TocBackend::toc(string const & type) { TocList::const_iterator it = tocs_.find(type); - if (it == tocs_.end()) { - it = tocs_.insert(std::make_pair(type, lyx::make_shared())).first; - } + if (it == tocs_.end()) + it = tocs_.insert(make_pair(type, make_shared())).first; return it->second; } @@ -357,7 +354,7 @@ void TocBackend::writePlaintextTocList(string const & type, } -docstring TocBackend::outlinerName(std::string const & type) const +docstring TocBackend::outlinerName(string const & type) const { return translateIfPossible( buffer_->params().documentClass().outlinerName(type)); diff --git a/src/TocBackend.h b/src/TocBackend.h index 2520927406..1579cf2fdc 100644 --- a/src/TocBackend.h +++ b/src/TocBackend.h @@ -25,6 +25,8 @@ #include +using std::shared_ptr; + namespace lyx { class Buffer; @@ -156,7 +158,7 @@ public: /// void clear() { map_.clear(); }; private: - typedef std::map > map_t; + typedef std::map> map_t; map_t map_; }; diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index ea32aace5b..0d80b56f1a 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -78,9 +78,8 @@ #include #endif -#include "support/shared_ptr.h" - #include +#include #include using namespace std; @@ -217,9 +216,6 @@ public: func_.setOrigin(origin); } - // shared_ptr needs this apprently... - ~MenuItem() {} - /// The label of a given menuitem QString label() const { diff --git a/src/frontends/qt4/TocModel.cpp b/src/frontends/qt4/TocModel.cpp index 9fb94813d2..eb6e610a1b 100644 --- a/src/frontends/qt4/TocModel.cpp +++ b/src/frontends/qt4/TocModel.cpp @@ -74,7 +74,7 @@ public: TocModel::TocModel(QObject * parent) : model_(new TocTypeModel(parent)), sorted_model_(new QSortFilterProxyModel(parent)), - is_sorted_(false), toc_(lyx::make_shared()), + is_sorted_(false), toc_(new Toc()), maxdepth_(0), mindepth_(0) { sorted_model_->setSortLocaleAware(true); @@ -102,7 +102,7 @@ void TocModel::clear() { model_->blockSignals(true); model_->clear(); - toc_ = lyx::make_shared(); + toc_ = make_shared(); model_->blockSignals(false); } diff --git a/src/frontends/qt4/TocModel.h b/src/frontends/qt4/TocModel.h index f0f9efa319..7b22ce6230 100644 --- a/src/frontends/qt4/TocModel.h +++ b/src/frontends/qt4/TocModel.h @@ -14,8 +14,6 @@ #include "Toc.h" -#include "support/shared_ptr.h" - #include #include @@ -41,7 +39,7 @@ public: /// TocModel(QObject * parent); /// - void reset(shared_ptr); + void reset(std::shared_ptr); /// void reset(); /// @@ -73,7 +71,7 @@ private: /// bool is_sorted_; /// - shared_ptr toc_; + std::shared_ptr toc_; /// int maxdepth_; /// diff --git a/src/graphics/GraphicsCache.h b/src/graphics/GraphicsCache.h index e6d810ff42..66cfc85bf6 100644 --- a/src/graphics/GraphicsCache.h +++ b/src/graphics/GraphicsCache.h @@ -20,10 +20,9 @@ #ifndef GRAPHICSCACHE_H #define GRAPHICSCACHE_H -#include "support/shared_ptr.h" - -#include +#include #include +#include namespace lyx { @@ -65,7 +64,7 @@ public: * * You have been warned! */ - typedef shared_ptr ItemPtr; + typedef std::shared_ptr ItemPtr; /// ItemPtr const item(support::FileName const & file) const; diff --git a/src/graphics/GraphicsCacheItem.cpp b/src/graphics/GraphicsCacheItem.cpp index 2d004c93e6..0b262ad241 100644 --- a/src/graphics/GraphicsCacheItem.cpp +++ b/src/graphics/GraphicsCacheItem.cpp @@ -109,7 +109,7 @@ public: bool remove_loaded_file_; /// The image and its loading status. - shared_ptr image_; + std::shared_ptr image_; /// ImageStatus status_; @@ -244,7 +244,7 @@ void CacheItem::Impl::reset() if (cc_.connected()) cc_.disconnect(); - if (converter_.get()) + if (converter_) converter_.reset(); } @@ -264,8 +264,8 @@ void CacheItem::Impl::imageConverted(bool success) string const text = success ? "succeeded" : "failed"; LYXERR(Debug::GRAPHICS, "Image conversion " << text << '.'); - file_to_load_ = converter_.get() ? - FileName(converter_->convertedFile()) : FileName(); + file_to_load_ = converter_ ? FileName(converter_->convertedFile()) + : FileName(); converter_.reset(); cc_.disconnect(); diff --git a/src/graphics/GraphicsLoader.cpp b/src/graphics/GraphicsLoader.cpp index 23ebb62394..79f5d9d5f3 100644 --- a/src/graphics/GraphicsLoader.cpp +++ b/src/graphics/GraphicsLoader.cpp @@ -22,8 +22,9 @@ #include "support/bind.h" -#include #include +#include +#include using namespace std; using namespace lyx::support; @@ -159,7 +160,7 @@ void LoaderQueue::touch(Cache::ItemPtr const & item) // ///////////////////////////////////////////////////////////////////// -typedef shared_ptr ImagePtr; +typedef std::shared_ptr ImagePtr; class Loader::Impl : public boost::signals::trackable { public: diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index 88320e4517..b273aa4a69 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -40,9 +40,10 @@ #include "support/bind.h" #include "support/TempFile.h" -#include #include #include +#include +#include #include @@ -229,7 +230,7 @@ private: /** cache_ allows easy retrieval of already-generated images * using the LaTeX snippet as the identifier. */ - typedef shared_ptr PreviewImagePtr; + typedef std::shared_ptr PreviewImagePtr; /// typedef map Cache; /// diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index f56991470c..c88888aa79 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -1102,7 +1102,7 @@ void Tabular::setAlignment(idx_type cell, LyXAlignment align, dpoint = from_utf8(lyxrc.default_decimal_point); } else { cellInfo(cell).alignment = align; - cellInset(cell).get()->setContentAlignment(align); + cellInset(cell)->setContentAlignment(align); } } @@ -2605,7 +2605,7 @@ void Tabular::TeXRow(otexstream & os, row_type row, if (getAlignment(cell) == LYX_ALIGN_DECIMAL) { // copy cell and split in 2 - InsetTableCell head = InsetTableCell(*cellInset(cell).get()); + InsetTableCell head = InsetTableCell(*cellInset(cell)); head.setBuffer(buffer()); DocIterator dit = cellInset(cell)->getText(0)->macrocontextPosition(); dit.pop_back(); @@ -3615,7 +3615,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const // determine horizontal offset because of decimal align (if necessary) int decimal_width = 0; if (tabular.getAlignment(cell) == LYX_ALIGN_DECIMAL) { - InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell).get()); + InsetTableCell tail = InsetTableCell(*tabular.cellInset(cell)); tail.setBuffer(tabular.buffer()); // we need to set macrocontext position everywhere // otherwise we crash with nested insets (e.g. footnotes) @@ -4934,7 +4934,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, } // check if there is already a caption bool have_caption = false; - InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx()).get()); + InsetTableCell itc = InsetTableCell(*tabular.cellInset(cur.idx())); ParagraphList::const_iterator pit = itc.paragraphs().begin(); ParagraphList::const_iterator pend = itc.paragraphs().end(); for (; pit != pend; ++pit) { diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index f63b84af42..f57cbaea13 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -28,12 +28,14 @@ #include "InsetText.h" #include "Length.h" -#include "support/shared_ptr.h" - #include #include +#include #include + +using std::shared_ptr; + namespace lyx { class Buffer; diff --git a/src/output_xhtml.h b/src/output_xhtml.h index 473ebe335a..a2eac95ab4 100644 --- a/src/output_xhtml.h +++ b/src/output_xhtml.h @@ -15,10 +15,11 @@ #include "LayoutEnums.h" #include "support/docstream.h" -#include "support/shared_ptr.h" #include "support/strfwd.h" #include +#include + namespace lyx { @@ -275,12 +276,11 @@ private: // own these pointers and how they will be deleted, so we use shared // pointers. /// - typedef shared_ptr TagPtr; + typedef std::shared_ptr TagPtr; typedef std::deque TagDeque; /// template - shared_ptr makeTagPtr(T const & tag) - { return shared_ptr(new T(tag)); } + TagPtr makeTagPtr(T const & tag) { return std::make_shared(tag); } /// TagDeque pending_tags_; /// diff --git a/src/support/ForkedCalls.cpp b/src/support/ForkedCalls.cpp index 14be7af6eb..56582a3346 100644 --- a/src/support/ForkedCalls.cpp +++ b/src/support/ForkedCalls.cpp @@ -553,7 +553,7 @@ string const getChildErrorMessage() namespace ForkedCallsController { -typedef shared_ptr ForkedProcessPtr; +typedef std::shared_ptr ForkedProcessPtr; typedef list ListType; typedef ListType::iterator iterator; diff --git a/src/support/ForkedCalls.h b/src/support/ForkedCalls.h index 191a2b5950..a4cb766c47 100644 --- a/src/support/ForkedCalls.h +++ b/src/support/ForkedCalls.h @@ -14,7 +14,6 @@ #ifndef FORKEDCALLS_H #define FORKEDCALLS_H -#include "support/shared_ptr.h" #include "support/strfwd.h" #include @@ -22,6 +21,11 @@ # include #endif +#include + + +using std::shared_ptr; + namespace lyx { namespace support { @@ -154,7 +158,7 @@ public: std::string const & lpath = empty_string()); /// virtual shared_ptr clone() const { - return shared_ptr(new ForkedCall(*this)); + return std::make_shared(*this); } /** Start the child process. diff --git a/src/support/Makefile.am b/src/support/Makefile.am index d926e868f8..1487285d69 100644 --- a/src/support/Makefile.am +++ b/src/support/Makefile.am @@ -96,7 +96,6 @@ liblyxsupport_a_SOURCES = \ Systemcall.cpp \ Systemcall.h \ SystemcallPrivate.h \ - shared_ptr.h \ TempFile.cpp \ TempFile.h \ textutils.h \ diff --git a/src/support/shared_ptr.h b/src/support/shared_ptr.h deleted file mode 100644 index ef9e1ade57..0000000000 --- a/src/support/shared_ptr.h +++ /dev/null @@ -1,25 +0,0 @@ -// -*- C++ -*- -/** - * \file shared_ptr.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Peter Kümmel - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef LYX_SHARED_PTR_H -#define LYX_SHARED_PTR_H - -#include - -namespace lyx -{ - using std::shared_ptr; - using std::make_shared; - using std::const_pointer_cast; -} - - -#endif -- 2.39.2