Change to use c++11 unique_ptr instead of deprecated auto_ptr

Signed-off-by: OBATA Akio <obache@wizdas.com>
(cherry picked from commit 0d168f7ecd)
r14.0.x
OBATA Akio 3 years ago committed by Slávek Banko
parent 6388395cd3
commit 0baef91f71
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -282,20 +282,20 @@ const CDSCMEDIA* KDSC::page_media() const
return _cdsc->page_media; return _cdsc->page_media;
} }
auto_ptr<KDSCBBOX> KDSC::bbox() const unique_ptr<KDSCBBOX> KDSC::bbox() const
{ {
if( _cdsc->bbox == 0 ) if( _cdsc->bbox == nullptr )
return auto_ptr<KDSCBBOX>( 0 ); return unique_ptr<KDSCBBOX>( nullptr );
else else
return auto_ptr<KDSCBBOX>( new KDSCBBOX( *_cdsc->bbox ) ); return unique_ptr<KDSCBBOX>( new KDSCBBOX( *_cdsc->bbox ) );
} }
auto_ptr<KDSCBBOX> KDSC::page_bbox() const unique_ptr<KDSCBBOX> KDSC::page_bbox() const
{ {
if( _cdsc->page_bbox == 0 ) if( _cdsc->page_bbox == nullptr )
return auto_ptr<KDSCBBOX>( 0 ); return unique_ptr<KDSCBBOX>( nullptr );
else else
return auto_ptr<KDSCBBOX>( new KDSCBBOX( *_cdsc->page_bbox ) ); return unique_ptr<KDSCBBOX>( new KDSCBBOX( *_cdsc->page_bbox ) );
} }
TQString KDSC::dsc_title() const TQString KDSC::dsc_title() const

@ -28,51 +28,6 @@
#include "dscparse.h" #include "dscparse.h"
#if defined(__GNUC__)
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 93)
/*
* We add a quick 'n' dirty inline implementation of auto_ptr for older
* releases of GCC, which don't include an auto_ptr implementation in
* <memory>.
*/
template <class T> class auto_ptr {
private:
T* _ptr;
public:
typedef T element_type;
explicit auto_ptr(T* p = 0) : _ptr(p) {}
auto_ptr(auto_ptr& a) : _ptr(a.release()) {}
template <class T1> auto_ptr(auto_ptr<T1>& a) : _ptr(a.release()) {}
auto_ptr& operator=(auto_ptr& a) {
if (&a != this) {
delete _ptr;
_ptr = a.release();
}
return *this;
}
template <class T1>
auto_ptr& operator=(auto_ptr<T1>& a) {
if (a.get() != this->get()) {
delete _ptr;
_ptr = a.release();
}
return *this;
}
~auto_ptr() { delete _ptr; }
T& operator*() const { return *_ptr; }
T* operator->() const { return _ptr; }
T* get() const { return _ptr; }
T* release() { T* tmp = _ptr; _ptr = 0; return tmp; }
void reset(T* p = 0) { delete _ptr; _ptr = p; }
};
#endif
#endif
class KDSCBBOX class KDSCBBOX
{ {
public: public:
@ -304,13 +259,8 @@ public:
CDSCMEDIA** media() const; CDSCMEDIA** media() const;
const CDSCMEDIA* page_media() const; const CDSCMEDIA* page_media() const;
#if defined(__GNUC__) && (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 93)) std::unique_ptr<KDSCBBOX> bbox() const;
auto_ptr<KDSCBBOX> bbox() const; std::unique_ptr<KDSCBBOX> page_bbox() const;
auto_ptr<KDSCBBOX> page_bbox() const;
#else
std::auto_ptr<KDSCBBOX> bbox() const;
std::auto_ptr<KDSCBBOX> page_bbox() const;
#endif
// CDSCDOSEPS *doseps; // CDSCDOSEPS *doseps;

@ -171,7 +171,7 @@ bool KGVDocument::uncompressFile()
// If the file is gzipped, gunzip it to the temporary file _tmpUnzipped. // If the file is gzipped, gunzip it to the temporary file _tmpUnzipped.
kdDebug(4500) << "KGVDocument::uncompressFile()" << endl; kdDebug(4500) << "KGVDocument::uncompressFile()" << endl;
auto_ptr<TQIODevice> filterDev( KFilterDev::deviceForFile( _fileName, _mimetype, true ) ); unique_ptr<TQIODevice> filterDev( KFilterDev::deviceForFile( _fileName, _mimetype, true ) );
if ( !filterDev.get() ) { if ( !filterDev.get() ) {
KMimeType::Ptr mt = KMimeType::mimeType(_mimetype); KMimeType::Ptr mt = KMimeType::mimeType(_mimetype);
if ( (_fileName.right( 3 ) == ".gz") || mt->is("application/x-gzip") ) { if ( (_fileName.right( 3 ) == ".gz") || mt->is("application/x-gzip") ) {

@ -241,7 +241,7 @@ bool GSCreator::create(const TQString &path, int width, int height, TQImage &img
char translation[64] = ""; char translation[64] = "";
char pagesize[32] = ""; char pagesize[32] = "";
char resopt[32] = ""; char resopt[32] = "";
std::auto_ptr<KDSCBBOX> bbox = dsc.bbox(); std::unique_ptr<KDSCBBOX> bbox = dsc.bbox();
if (is_encapsulated) { if (is_encapsulated) {
// GhostScript's rendering at the extremely low resolutions // GhostScript's rendering at the extremely low resolutions
// required for thumbnails leaves something to be desired. To // required for thumbnails leaves something to be desired. To

Loading…
Cancel
Save