From c9b9748cee687e709e9e48dd2c78e054d8ea29a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Thu, 22 Apr 2010 11:37:32 +0000 Subject: [PATCH] msvcUsing "using namespace std" with msvc10 makes also std::tr1::shared_ptr visible and generates conflicts with boost::shared_ptr. Solution: don't use boost::shared_ptr for msvc10 (could also be extended to several GCC versions) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34259 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 6 +++--- src/KeyMap.h | 4 ++-- src/OutputParams.h | 4 ++-- src/ServerSocket.cpp | 2 +- src/ServerSocket.h | 4 ++-- src/frontends/qt4/GuiView.cpp | 2 +- src/frontends/qt4/Menus.cpp | 4 ++-- src/graphics/GraphicsCache.h | 6 +++--- src/graphics/GraphicsCacheItem.cpp | 2 +- src/graphics/GraphicsLoader.cpp | 2 +- src/graphics/PreviewLoader.cpp | 2 +- src/graphics/Previews.cpp | 2 +- src/insets/InsetTabular.cpp | 1 - src/insets/InsetTabular.h | 14 +++++++------- src/insets/InsetText.cpp | 2 ++ src/support/ForkedCalls.cpp | 2 +- src/support/ForkedCalls.h | 10 +++++----- src/support/shared_ptr.h | 28 ++++++++++++++++++++++++++++ 18 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 src/support/shared_ptr.h diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b91322ad94..005a460332 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -103,7 +103,7 @@ #include "support/types.h" #include "support/bind.h" -#include +#include "support/shared_ptr.h" #include #include @@ -3067,9 +3067,9 @@ public: AutoSaveBuffer(Buffer const & buffer, FileName const & fname) : buffer_(buffer), fname_(fname) {} /// - virtual boost::shared_ptr clone() const + virtual shared_ptr clone() const { - return boost::shared_ptr(new AutoSaveBuffer(*this)); + return shared_ptr(new AutoSaveBuffer(*this)); } /// int start() diff --git a/src/KeyMap.h b/src/KeyMap.h index 1a37a1fc99..e2d0f3aac0 100644 --- a/src/KeyMap.h +++ b/src/KeyMap.h @@ -19,7 +19,7 @@ #include "support/strfwd.h" -#include +#include "support/shared_ptr.h" #include @@ -163,7 +163,7 @@ private: /// Modifier masks ModifierPair mod; /// Keymap for prefix keys - boost::shared_ptr prefixes; + shared_ptr prefixes; /// Action for !prefix keys FuncRequest func; }; diff --git a/src/OutputParams.h b/src/OutputParams.h index 6f9d306ac9..5717226113 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -13,7 +13,7 @@ #define OUTPUTPARAMS_H -#include +#include "support/shared_ptr.h" #include "Changes.h" @@ -165,7 +165,7 @@ public: This is a hack: Make it possible to add stuff to constant OutputParams instances. */ - boost::shared_ptr exportdata; + 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 12386af838..9b19a57315 100644 --- a/src/ServerSocket.cpp +++ b/src/ServerSocket.cpp @@ -40,7 +40,7 @@ using namespace std; using namespace lyx::support; -using boost::shared_ptr; + namespace lyx { diff --git a/src/ServerSocket.h b/src/ServerSocket.h index 420089984c..2b2ddd11d2 100644 --- a/src/ServerSocket.h +++ b/src/ServerSocket.h @@ -17,7 +17,7 @@ #include "support/FileName.h" #include "support/socktools.h" -#include +#include "support/shared_ptr.h" #include #include @@ -61,7 +61,7 @@ private: MAX_CLIENTS = 10 }; /// All connections - std::map > clients; + std::map > clients; }; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index e3aa1ecab9..b9815221c5 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -191,7 +191,7 @@ private: /// Toolbar store providing access to individual toolbars by name. typedef map ToolbarMap; -typedef boost::shared_ptr DialogPtr; +typedef shared_ptr DialogPtr; } // namespace anon diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index 9529e0e952..5e4665499e 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -69,7 +69,7 @@ #include #include -#include +#include "support/shared_ptr.h" #include #include @@ -190,7 +190,7 @@ public: func_.setOrigin(origin); } - // boost::shared_ptr needs this apprently... + // shared_ptr needs this apprently... ~MenuItem() {} /// The label of a given menuitem diff --git a/src/graphics/GraphicsCache.h b/src/graphics/GraphicsCache.h index 0eb35a36fb..e6d810ff42 100644 --- a/src/graphics/GraphicsCache.h +++ b/src/graphics/GraphicsCache.h @@ -20,7 +20,7 @@ #ifndef GRAPHICSCACHE_H #define GRAPHICSCACHE_H -#include +#include "support/shared_ptr.h" #include #include @@ -59,13 +59,13 @@ public: * Returns an empty container if there is no such item. * * IMPORTANT: whatever uses an image must make a local copy of this - * ItemPtr. The boost::shared_ptr<>::use_count() function is + * ItemPtr. The shared_ptr<>::use_count() function is * used to ascertain whether or not to remove the item from the cache * when remove(file) is called. * * You have been warned! */ - typedef boost::shared_ptr ItemPtr; + typedef shared_ptr ItemPtr; /// ItemPtr const item(support::FileName const & file) const; diff --git a/src/graphics/GraphicsCacheItem.cpp b/src/graphics/GraphicsCacheItem.cpp index e2df63d4bc..8331718218 100644 --- a/src/graphics/GraphicsCacheItem.cpp +++ b/src/graphics/GraphicsCacheItem.cpp @@ -107,7 +107,7 @@ public: bool remove_loaded_file_; /// The image and its loading status. - boost::shared_ptr image_; + shared_ptr image_; /// ImageStatus status_; diff --git a/src/graphics/GraphicsLoader.cpp b/src/graphics/GraphicsLoader.cpp index 559c3a7af9..3e6664651e 100644 --- a/src/graphics/GraphicsLoader.cpp +++ b/src/graphics/GraphicsLoader.cpp @@ -159,7 +159,7 @@ void LoaderQueue::touch(Cache::ItemPtr const & item) // ///////////////////////////////////////////////////////////////////// -typedef boost::shared_ptr ImagePtr; +typedef shared_ptr ImagePtr; class Loader::Impl : public boost::signals::trackable { public: diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index bca80c2816..1981a420dd 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -222,7 +222,7 @@ private: /** cache_ allows easy retrieval of already-generated images * using the LaTeX snippet as the identifier. */ - typedef boost::shared_ptr PreviewImagePtr; + typedef shared_ptr PreviewImagePtr; /// typedef map Cache; /// diff --git a/src/graphics/Previews.cpp b/src/graphics/Previews.cpp index 7c50618a9a..dc1c167fa3 100644 --- a/src/graphics/Previews.cpp +++ b/src/graphics/Previews.cpp @@ -32,7 +32,7 @@ LyXRC_PreviewStatus Previews::status() namespace { -typedef boost::shared_ptr PreviewLoaderPtr; +typedef shared_ptr PreviewLoaderPtr; /// typedef map LyxCacheType; /// diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index ad0d6f37b1..c8ef61183d 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -70,7 +70,6 @@ using namespace std; using namespace lyx::support; -using boost::shared_ptr; namespace lyx { diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 9e3f532f39..7e0bc205a3 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -28,7 +28,7 @@ #include "Layout.h" #include "Length.h" -#include +#include "support/shared_ptr.h" #include #include @@ -451,13 +451,13 @@ public: /// // end longtable support /// - boost::shared_ptr cellInset(idx_type cell) const; + shared_ptr cellInset(idx_type cell) const; /// - boost::shared_ptr cellInset(row_type row, + shared_ptr cellInset(row_type row, col_type column) const; /// void setCellInset(row_type row, col_type column, - boost::shared_ptr) const; + shared_ptr) const; /// Search for \param inset in the tabular, with the /// void validate(LaTeXFeatures &) const; @@ -509,7 +509,7 @@ public: /// Length p_width; // this is only set for multicolumn!!! /// - boost::shared_ptr inset; + shared_ptr inset; }; CellData & cellInfo(idx_type cell) const; /// @@ -807,9 +807,9 @@ public: /// number of cells size_t nargs() const { return tabular.numberofcells; } /// - boost::shared_ptr cell(idx_type) const; + shared_ptr cell(idx_type) const; /// - boost::shared_ptr cell(idx_type); + shared_ptr cell(idx_type); /// Text * getText(int) const; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index f427118e75..c4240ab7ff 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -61,6 +61,8 @@ #include "support/bind.h" #include "support/lassert.h" + + using namespace std; using namespace lyx::support; diff --git a/src/support/ForkedCalls.cpp b/src/support/ForkedCalls.cpp index e59c008557..fb9dd608f8 100644 --- a/src/support/ForkedCalls.cpp +++ b/src/support/ForkedCalls.cpp @@ -520,7 +520,7 @@ string const getChildErrorMessage() namespace ForkedCallsController { -typedef boost::shared_ptr ForkedProcessPtr; +typedef shared_ptr ForkedProcessPtr; typedef list ListType; typedef ListType::iterator iterator; diff --git a/src/support/ForkedCalls.h b/src/support/ForkedCalls.h index c45211f7a2..caeba526e0 100644 --- a/src/support/ForkedCalls.h +++ b/src/support/ForkedCalls.h @@ -14,7 +14,7 @@ #ifndef FORKEDCALLS_H #define FORKEDCALLS_H -#include +#include "support/shared_ptr.h" #include #ifdef HAVE_SYS_TYPES_H @@ -41,7 +41,7 @@ public: /// virtual ~ForkedProcess() {} /// - virtual boost::shared_ptr clone() const = 0; + virtual shared_ptr clone() const = 0; /** A SignalType signal can be emitted once the forked process * has finished. It passes: @@ -62,7 +62,7 @@ public: * * It doesn't matter if the slot disappears, SigC takes care of that. */ - typedef boost::shared_ptr SignalTypePtr; + typedef shared_ptr SignalTypePtr; /** Invoking the following methods makes sense only if the command * is running asynchronously! @@ -151,8 +151,8 @@ private: class ForkedCall : public ForkedProcess { public: /// - virtual boost::shared_ptr clone() const { - return boost::shared_ptr(new ForkedCall(*this)); + virtual shared_ptr clone() const { + return shared_ptr(new ForkedCall(*this)); } /** Start the child process. diff --git a/src/support/shared_ptr.h b/src/support/shared_ptr.h new file mode 100644 index 0000000000..6976a5b4c5 --- /dev/null +++ b/src/support/shared_ptr.h @@ -0,0 +1,28 @@ +// -*- 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 + +#if defined(_MSC_VER) && (_MSC_VER >= 1600) + +#include +using std::tr1::shared_ptr; + +#else + +#include +using boost::shared_ptr; + +#endif + + +#endif