cppuhelper/source/propshlp.cxx | 3 - cppuhelper/source/unourl.cxx | 73 ++++++++++++++++++---------------------- include/cppuhelper/propshlp.hxx | 3 - include/cppuhelper/unourl.hxx | 11 ++---- 4 files changed, 40 insertions(+), 50 deletions(-)
New commits: commit 0866023fafe4665f488eaea65a32cd1364e21594 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Jan 27 10:03:01 2015 +0100 Get rid of std::auto_ptr in stable URE interface ...the deprecation-warning noise is getting ever louder, and eventually auto_ptr will just disappear. Just surrender and use good-old plain pointer and deletion in dtor---it's probably the best to do in this stable interface. The change is backwards compatible. For one, in all relevant standard libraries (libstdc++, even in debug mode; libc++; msvcrt) sizeof(auto_ptr<T>) equals sizeof(T*). And for another, the removed UnoUrlDescriptor ctor was only called from within cppuhelper and had deliberately been left out of cppuhelper/source/gcc3.map (so isn't exported at least on Linux)---marking it SAL_DLLPRIVATE had probably just been forgotten when retrofitting cppuhelper with CPPUHELPER_DLLPUBLIC annotations. Change-Id: Ic8bce29d93938f2b2e0a264baee85132668e1294 diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx index 509019c..0f1239d 100644 --- a/cppuhelper/source/propshlp.cxx +++ b/cppuhelper/source/propshlp.cxx @@ -199,6 +199,7 @@ OPropertySetHelper2::OPropertySetHelper2( */ OPropertySetHelper::~OPropertySetHelper() { + delete m_pReserved; } OPropertySetHelper2::~OPropertySetHelper2() { @@ -631,8 +632,6 @@ void OPropertySetHelper::fire sal_Bool bVetoable ) { - OSL_ENSURE( m_pReserved.get(), "No OPropertySetHelper::Impl" ); - if (! m_pReserved->m_bFireEvents) return; diff --git a/cppuhelper/source/unourl.cxx b/cppuhelper/source/unourl.cxx index 14bde29..b73f176 100644 --- a/cppuhelper/source/unourl.cxx +++ b/cppuhelper/source/unourl.cxx @@ -31,6 +31,7 @@ #include <sal/types.h> #include <map> +#include <memory> using cppu::UnoUrl; using cppu::UnoUrlDescriptor; @@ -137,49 +138,47 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) } UnoUrlDescriptor::UnoUrlDescriptor(rtl::OUString const & rDescriptor): - m_xImpl(new Impl(rDescriptor)) + m_pImpl(new Impl(rDescriptor)) {} -SAL_WNODEPRECATED_DECLARATIONS_PUSH -UnoUrlDescriptor::UnoUrlDescriptor(std::auto_ptr< Impl > & rImpl): - m_xImpl(rImpl) -{} -SAL_WNODEPRECATED_DECLARATIONS_POP - UnoUrlDescriptor::UnoUrlDescriptor(UnoUrlDescriptor const & rOther): - m_xImpl(rOther.m_xImpl->clone()) + m_pImpl(rOther.m_pImpl->clone()) {} UnoUrlDescriptor::~UnoUrlDescriptor() -{} +{ + delete m_pImpl; +} UnoUrlDescriptor & UnoUrlDescriptor::operator =(UnoUrlDescriptor const & rOther) { - m_xImpl.reset(rOther.m_xImpl->clone()); + std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone()); + delete m_pImpl; + m_pImpl = newImpl.release(); return *this; } rtl::OUString const & UnoUrlDescriptor::getDescriptor() const { - return m_xImpl->m_aDescriptor; + return m_pImpl->m_aDescriptor; } rtl::OUString const & UnoUrlDescriptor::getName() const { - return m_xImpl->m_aName; + return m_pImpl->m_aName; } bool UnoUrlDescriptor::hasParameter(rtl::OUString const & rKey) const { - return m_xImpl->m_aParameters.find(rKey.toAsciiLowerCase()) - != m_xImpl->m_aParameters.end(); + return m_pImpl->m_aParameters.find(rKey.toAsciiLowerCase()) + != m_pImpl->m_aParameters.end(); } rtl::OUString UnoUrlDescriptor::getParameter(rtl::OUString const & rKey) const { Impl::Parameters::const_iterator - aIt(m_xImpl->m_aParameters.find(rKey.toAsciiLowerCase())); - return aIt == m_xImpl->m_aParameters.end() ? rtl::OUString() : aIt->second; + aIt(m_pImpl->m_aParameters.find(rKey.toAsciiLowerCase())); + return aIt == m_pImpl->m_aParameters.end() ? rtl::OUString() : aIt->second; } class UnoUrl::Impl @@ -196,15 +195,13 @@ public: static inline Impl * create(rtl::OUString const & rUrl); private: -SAL_WNODEPRECATED_DECLARATIONS_PUSH - Impl(std::auto_ptr< UnoUrlDescriptor::Impl > & rConnection, - std::auto_ptr< UnoUrlDescriptor::Impl > & rProtocol, - rtl::OUString const & rObjectName): - m_aConnection(rConnection), - m_aProtocol(rProtocol), + Impl(rtl::OUString const & rConnectionDescriptor, + rtl::OUString const & rProtocolDescriptor, + rtl::OUString const & rObjectName): + m_aConnection(rConnectionDescriptor), + m_aProtocol(rProtocolDescriptor), m_aObjectName(rObjectName) {} -SAL_WNODEPRECATED_DECLARATIONS_POP }; inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) @@ -217,19 +214,13 @@ inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) if (j < 0) throw rtl::MalformedUriException( rtl::OUString("UNO URL has too few semicolons")); - SAL_WNODEPRECATED_DECLARATIONS_PUSH - std::auto_ptr< UnoUrlDescriptor::Impl > - xConnection(new UnoUrlDescriptor::Impl(rUrl.copy(i, j - i))); - SAL_WNODEPRECATED_DECLARATIONS_POP + rtl::OUString aConnection(rUrl.copy(i, j - i)); i = j + 1; j = rUrl.indexOf(0x3B, i); // ';' if (j < 0) throw rtl::MalformedUriException( rtl::OUString("UNO URL has too few semicolons")); - SAL_WNODEPRECATED_DECLARATIONS_PUSH - std::auto_ptr< UnoUrlDescriptor::Impl > - xProtocol(new UnoUrlDescriptor::Impl(rUrl.copy(i, j - i))); - SAL_WNODEPRECATED_DECLARATIONS_POP + rtl::OUString aProtocol(rUrl.copy(i, j - i)); i = j + 1; if (i == rUrl.getLength()) throw rtl::MalformedUriException( @@ -247,37 +238,41 @@ inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) throw rtl::MalformedUriException( rtl::OUString("UNO URL contains invalid ObjectName")); } - return new Impl(xConnection, xProtocol, rUrl.copy(i)); + return new Impl(aConnection, aProtocol, rUrl.copy(i)); } -UnoUrl::UnoUrl(rtl::OUString const & rUrl): m_xImpl(Impl::create(rUrl)) +UnoUrl::UnoUrl(rtl::OUString const & rUrl): m_pImpl(Impl::create(rUrl)) {} -UnoUrl::UnoUrl(UnoUrl const & rOther): m_xImpl(rOther.m_xImpl->clone()) +UnoUrl::UnoUrl(UnoUrl const & rOther): m_pImpl(rOther.m_pImpl->clone()) {} UnoUrl::~UnoUrl() -{} +{ + delete m_pImpl; +} UnoUrl & UnoUrl::operator =(UnoUrl const & rOther) { - m_xImpl.reset(rOther.m_xImpl->clone()); + std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone()); + delete m_pImpl; + m_pImpl = newImpl.release(); return *this; } UnoUrlDescriptor const & UnoUrl::getConnection() const { - return m_xImpl->m_aConnection; + return m_pImpl->m_aConnection; } UnoUrlDescriptor const & UnoUrl::getProtocol() const { - return m_xImpl->m_aProtocol; + return m_pImpl->m_aProtocol; } rtl::OUString const & UnoUrl::getObjectName() const { - return m_xImpl->m_aObjectName; + return m_pImpl->m_aObjectName; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/propshlp.hxx b/include/cppuhelper/propshlp.hxx index 8cf0159..c652822 100644 --- a/include/cppuhelper/propshlp.hxx +++ b/include/cppuhelper/propshlp.hxx @@ -29,7 +29,6 @@ #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XFastPropertySet.hpp> -#include <memory> #include <cppuhelper/cppuhelperdllapi.h> @@ -649,7 +648,7 @@ protected: /** reserved for future use. finally, the future has arrived... */ - const std::auto_ptr<Impl> m_pReserved; + Impl * const m_pReserved; private: OPropertySetHelper( const OPropertySetHelper & ); diff --git a/include/cppuhelper/unourl.hxx b/include/cppuhelper/unourl.hxx index 9928709..64608b1 100644 --- a/include/cppuhelper/unourl.hxx +++ b/include/cppuhelper/unourl.hxx @@ -20,7 +20,8 @@ #ifndef INCLUDED_CPPUHELPER_UNOURL_HXX #define INCLUDED_CPPUHELPER_UNOURL_HXX -#include <memory> +#include <sal/config.h> + #include <cppuhelper/cppuhelperdllapi.h> namespace rtl { class OUString; } @@ -49,10 +50,6 @@ public: */ explicit UnoUrlDescriptor(rtl::OUString const & rDescriptor); - /// @cond INTERNAL - explicit UnoUrlDescriptor(std::auto_ptr< Impl > & rImpl); - /// @endcond - UnoUrlDescriptor(UnoUrlDescriptor const & rOther); ~UnoUrlDescriptor(); @@ -98,7 +95,7 @@ public: rtl::OUString getParameter(rtl::OUString const & rKey) const; private: - std::auto_ptr< Impl > m_xImpl; + Impl * m_pImpl; }; /** Parse UNO URLs into their components. @@ -175,7 +172,7 @@ public: private: class Impl; - std::auto_ptr< Impl > m_xImpl; + Impl * m_pImpl; }; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits