Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

use smart pointer for m_imp

Shinya Kitaoka262a92f13086
diff --git a/toonz/sources/common/expressions/texpression.cpp b/toonz/sources/common/expressions/texpression.cpp
index 04f930379..f8d395d8d 100644
--- a/toonz/sources/common/expressions/texpression.cpp
+++ b/toonz/sources/common/expressions/texpression.cpp
@@ -46,7 +46,6 @@ TExpression::TExpression()
TExpression::~TExpression()
{
- delete m_imp;
}
//--------------------------------------------------------------------------
diff --git a/toonz/sources/common/expressions/tgrammar.cpp b/toonz/sources/common/expressions/tgrammar.cpp
index 6d5de6b73..f0d05bd30 100644
--- a/toonz/sources/common/expressions/tgrammar.cpp
+++ b/toonz/sources/common/expressions/tgrammar.cpp
@@ -1319,7 +1319,6 @@ Grammar::Grammar()
Grammar::~Grammar()
{
- delete m_imp;
}
void Grammar::addPattern(Pattern *pattern)
diff --git a/toonz/sources/common/expressions/tparser.cpp b/toonz/sources/common/expressions/tparser.cpp
index aecc98d38..17140e49c 100644
--- a/toonz/sources/common/expressions/tparser.cpp
+++ b/toonz/sources/common/expressions/tparser.cpp
@@ -92,7 +92,6 @@ Parser::Parser(const Grammar *grammar)
Parser::~Parser()
{
- delete m_imp;
}
//-------------------------------------------------------------------
diff --git a/toonz/sources/common/tapptools/tcli.cpp b/toonz/sources/common/tapptools/tcli.cpp
index b73519c47..baac4c5ff 100644
--- a/toonz/sources/common/tapptools/tcli.cpp
+++ b/toonz/sources/common/tapptools/tcli.cpp
@@ -785,13 +785,12 @@ void UsageImp::resetValues()
//---------------------------------------------------------
Usage::Usage(string progName)
+ : m_imp(new UsageImp(progName))
{
- m_imp = new UsageImp(progName);
}
Usage::~Usage()
{
- delete m_imp;
}
void Usage::add(const UsageLine &ul)
diff --git a/toonz/sources/common/tapptools/ttimer.cpp b/toonz/sources/common/tapptools/ttimer.cpp
index 8c7289cc0..0e631ee70 100644
--- a/toonz/sources/common/tapptools/ttimer.cpp
+++ b/toonz/sources/common/tapptools/ttimer.cpp
@@ -292,15 +292,14 @@ public:
//===============================================================================
TTimer::TTimer(const string &name, UINT timerRes, Type type)
+ : m_imp(new TTimer::Imp(name, timerRes, type, this))
{
- m_imp = new TTimer::Imp(name, timerRes, type, this);
}
//--------------------------------------------------------------------------------
TTimer::~TTimer()
{
- delete m_imp;
}
//--------------------------------------------------------------------------------
diff --git a/toonz/sources/common/tcache/timagecache.cpp b/toonz/sources/common/tcache/timagecache.cpp
index 3bed35cef..7b139efee 100644
--- a/toonz/sources/common/tcache/timagecache.cpp
+++ b/toonz/sources/common/tcache/timagecache.cpp
@@ -1127,7 +1127,6 @@ TImageCache::~TImageCache()
{
assert(check == magic);
check = -1;
- delete m_imp;
CacheInstance = 0;
}
diff --git a/toonz/sources/common/tcore/tundo.cpp b/toonz/sources/common/tcore/tundo.cpp
index ebfcc3138..5cb4d38e8 100644
--- a/toonz/sources/common/tcore/tundo.cpp
+++ b/toonz/sources/common/tcore/tundo.cpp
@@ -174,7 +174,6 @@ TUndoManager *TUndoManager::manager()
TUndoManager::TUndoManager()
: m_imp(new TUndoManagerImp)
{
- // cout << "Creato undo manager" << endl;
}
//-----------------------------------------------------------------------------
@@ -184,7 +183,6 @@ TUndoManager::~TUndoManager()
//cout << "Distrutto undo manager" << endl;
assert(m_imp->m_blockStack.empty());
reset();
- delete m_imp;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/common/tfx/tfx.cpp b/toonz/sources/common/tfx/tfx.cpp
index 02cfbeab2..293bb657b 100644
--- a/toonz/sources/common/tfx/tfx.cpp
+++ b/toonz/sources/common/tfx/tfx.cpp
@@ -292,8 +292,7 @@ DEFINE_CLASS_CODE(TFx, 3)
TFx::TFx()
: TSmartObject(m_classCode) // TPersist(TFxImp::m_instances)
- ,
- m_imp(new TFxImp(this))
+ , m_imp(new TFxImp(this))
{
}
diff --git a/toonz/sources/common/tfx/tfxcachemanager.cpp b/toonz/sources/common/tfx/tfxcachemanager.cpp
index 66ca96386..786119dd9 100644
--- a/toonz/sources/common/tfx/tfxcachemanager.cpp
+++ b/toonz/sources/common/tfx/tfxcachemanager.cpp
@@ -162,8 +162,6 @@ TFxCacheManager::~TFxCacheManager()
std::set<std::string>::iterator it;
for (it = m_staticCacheIds.begin(); it != m_staticCacheIds.end(); ++it)
TImageCache::instance()->remove(*it);
-
- delete m_imp;
}
//-----------------------------------------------------------------------------------
diff --git a/toonz/sources/common/tfx/tpredictivecachemanager.cpp b/toonz/sources/common/tfx/tpredictivecachemanager.cpp
index e432dec57..3aa79c321 100644
--- a/toonz/sources/common/tfx/tpredictivecachemanager.cpp
+++ b/toonz/sources/common/tfx/tpredictivecachemanager.cpp
@@ -67,18 +67,30 @@ public:
std::map<TCacheResourceP, PredictionData> m_resources;
QMutex m_mutex;
-public:
- //Active getResource(..) callback
- typedef void (TPredictiveCacheManager::Imp::*GetResourceFuncPtr)(TCacheResourceP &resource, const string &alias,
- const TFxP &fx, double frame, const TRenderSettings &rs,
- ResourceDeclaration *resData);
-
- GetResourceFuncPtr m_getResFuncPtr;
-
public:
Imp()
- : m_renderStatus(TRenderer::IDLE), m_getResFuncPtr(&Imp::getResourceComputing), m_enabled(TRenderer::instance().isPrecomputingEnabled()) {}
+ : m_renderStatus(TRenderer::IDLE)
+ , m_enabled(TRenderer::instance().isPrecomputingEnabled())
+ {
+ }
+ void run(
+ TCacheResourceP &resource, const string &alias,
+ const TFxP &fx, double frame, const TRenderSettings &rs,
+ ResourceDeclaration *resData)
+ {
+ switch (m_renderStatus) {
+ case TRenderer::IDLE:
+ case TRenderer::COMPUTING:
+ getResourceComputing(resource, alias, fx, frame, rs, resData);
+ break;
+ case TRenderer::TESTRUN:
+ getResourceTestRun(resource, alias, fx, frame, rs, resData);
+ break;
+ }
+ }
+
+private:
void getResourceTestRun(
TCacheResourceP &resource, const string &alias,
const TFxP &fx, double frame, const TRenderSettings &rs,
@@ -103,7 +115,6 @@ TPredictiveCacheManager::TPredictiveCacheManager()
TPredictiveCacheManager::~TPredictiveCacheManager()
{
- delete m_imp;
}
//---------------------------------------------------------------------------
@@ -128,7 +139,7 @@ void TPredictiveCacheManager::getResource(
if (!m_imp->m_enabled)
return;
- (m_imp->*(m_imp->m_getResFuncPtr))(resource, alias, fx, frame, rs, resData);
+ m_imp->run(resource, alias, fx, frame, rs, resData);
}
//************************************************************************************************
@@ -207,11 +218,6 @@ void TPredictiveCacheManager::Imp::getResourceComputing(
void TPredictiveCacheManager::onRenderStatusStart(int renderStatus)
{
m_imp->m_renderStatus = renderStatus;
- switch (renderStatus) {
- case TRenderer::TESTRUN:
- m_imp->m_getResFuncPtr = &TPredictiveCacheManager::Imp::getResourceTestRun;
- CASE TRenderer::COMPUTING : m_imp->m_getResFuncPtr = &TPredictiveCacheManager::Imp::getResourceComputing;
- }
}
//---------------------------------------------------------------------------
diff --git a/toonz/sources/common/tgl/tstencilcontrol.cpp b/toonz/sources/common/tgl/tstencilcontrol.cpp
index 57aaaebb2..fae7e40c2 100644
--- a/toonz/sources/common/tgl/tstencilcontrol.cpp
+++ b/toonz/sources/common/tgl/tstencilcontrol.cpp
@@ -130,7 +130,6 @@ TStencilControl::TStencilControl()
TStencilControl::~TStencilControl()
{
- delete m_imp;
}
//---------------------------------------------------------
diff --git a/toonz/sources/common/tmeshimage/tmeshimage.cpp b/toonz/sources/common/tmeshimage/tmeshimage.cpp
index da809c936..62b368de9 100644
--- a/toonz/sources/common/tmeshimage/tmeshimage.cpp
+++ b/toonz/sources/common/tmeshimage/tmeshimage.cpp
@@ -330,8 +330,8 @@ TMeshImage::TMeshImage()
//-----------------------------------------------------------------------
-TMeshImage::TMeshImage(Imp *imp)
- : m_imp(imp)
+TMeshImage::TMeshImage(std::shared_ptr<Imp> imp)
+ : m_imp(std::move(imp))
{
}
@@ -339,7 +339,6 @@ TMeshImage::TMeshImage(Imp *imp)
TMeshImage::~TMeshImage()
{
- delete m_imp;
}
//-----------------------------------------------------------------------
diff --git a/toonz/sources/common/tparam/tdoubleparam.cpp b/toonz/sources/common/tparam/tdoubleparam.cpp
index ca3770cdb..7c3813bd6 100644
--- a/toonz/sources/common/tparam/tdoubleparam.cpp
+++ b/toonz/sources/common/tparam/tdoubleparam.cpp
@@ -351,16 +351,16 @@ public:
~Imp() {}
- void copy(Imp *src)
+ void copy(Imp& src)
{
- m_grammar = src->m_grammar;
- m_measureName = src->m_measureName;
- m_measure = src->m_measure;
- m_defaultValue = src->m_defaultValue;
- m_minValue = src->m_minValue;
- m_maxValue = src->m_maxValue;
- m_keyframes = src->m_keyframes;
- m_cycleEnabled = src->m_cycleEnabled;
+ m_grammar = src.m_grammar;
+ m_measureName = src.m_measureName;
+ m_measure = src.m_measure;
+ m_defaultValue = src.m_defaultValue;
+ m_minValue = src.m_minValue;
+ m_maxValue = src.m_maxValue;
+ m_keyframes = src.m_keyframes;
+ m_cycleEnabled = src.m_cycleEnabled;
}
void notify(const TParamChange &change)
@@ -496,14 +496,13 @@ TDoubleParam::TDoubleParam(double v)
TDoubleParam::TDoubleParam(const TDoubleParam &src)
: TParam(src.getName()), m_imp(new TDoubleParam::Imp())
{
- m_imp->copy(src.m_imp);
+ m_imp->copy(*src.m_imp);
}
//---------------------------------------------------------
TDoubleParam::~TDoubleParam()
{
- delete m_imp;
}
//---------------------------------------------------------
@@ -511,7 +510,7 @@ TDoubleParam::~TDoubleParam()
TDoubleParam &TDoubleParam::operator=(const TDoubleParam &dp)
{
setName(dp.getName());
- m_imp->copy(dp.m_imp);
+ m_imp->copy(*dp.m_imp);
return *this;
}
@@ -523,7 +522,7 @@ void TDoubleParam::copy(TParam *src)
if (!p)
throw TException("invalid source for copy");
setName(src->getName());
- m_imp->copy(p->m_imp);
+ m_imp->copy(*p->m_imp);
m_imp->notify(TParamChange(this, 0, 0, true, false, false));
}
diff --git a/toonz/sources/common/tparam/tnotanimatableparam.cpp b/toonz/sources/common/tparam/tnotanimatableparam.cpp
index 414a3029b..86fa65d68 100644
--- a/toonz/sources/common/tparam/tnotanimatableparam.cpp
+++ b/toonz/sources/common/tparam/tnotanimatableparam.cpp
@@ -133,7 +133,7 @@ class TEnumParamImp
{
public:
vector<pair<int, string>> m_items;
- void copy(TEnumParamImp *src)
+ void copy(std::unique_ptr<TEnumParamImp>& src)
{
m_items.clear();
std::back_insert_iterator<std::vector<pair<int, string>>> bii(m_items);
@@ -171,7 +171,6 @@ void TEnumParam::copy(TParam *src)
TEnumParam::~TEnumParam()
{
- delete m_imp;
}
//---------------------------------------------------------
diff --git a/toonz/sources/common/tparam/tparamcontainer.cpp b/toonz/sources/common/tparam/tparamcontainer.cpp
index f489dbc79..d58fa4cd8 100644
--- a/toonz/sources/common/tparam/tparamcontainer.cpp
+++ b/toonz/sources/common/tparam/tparamcontainer.cpp
@@ -37,7 +37,6 @@ TParamContainer::TParamContainer()
TParamContainer::~TParamContainer()
{
- delete m_imp;
}
void TParamContainer::setParamObserver(TParamObserver *observer)
diff --git a/toonz/sources/common/tparam/tparamset.cpp b/toonz/sources/common/tparam/tparamset.cpp
index 49376de47..7d6ef906a 100644
--- a/toonz/sources/common/tparam/tparamset.cpp
+++ b/toonz/sources/common/tparam/tparamset.cpp
@@ -103,23 +103,22 @@ public:
TParamSet::TParamSet(string name)
: TParam(name)
+ , m_imp(new TParamSetImp(this))
{
- m_imp = new TParamSetImp(this);
}
//---------------------------------------------------------
TParamSet::TParamSet(const TParamSet &src)
: TParam(src.getName())
+ , m_imp(new TParamSetImp(this))
{
- m_imp = new TParamSetImp(this);
}
//---------------------------------------------------------
TParamSet::~TParamSet()
{
- delete m_imp;
}
//---------------------------------------------------------
diff --git a/toonz/sources/common/tparam/tspectrumparam.cpp b/toonz/sources/common/tparam/tspectrumparam.cpp
index a55a88b4c..ee65526d4 100644
--- a/toonz/sources/common/tparam/tspectrumparam.cpp
+++ b/toonz/sources/common/tparam/tspectrumparam.cpp
@@ -113,9 +113,8 @@ PERSIST_IDENTIFIER(TSpectrumParam, "spectrumParam")
//---------------------------------------------------------
-TSpectrumParam::TSpectrumParam()
+TSpectrumParam::TSpectrumParam(): m_imp(new TSpectrumParamImp(this)) //brutto...
{
- m_imp = new TSpectrumParamImp(this); //brutto...
ColorKeyParam ck1(TDoubleParamP(0.0), TPixelParamP(TPixel32::Black));
ColorKeyParam ck2(TDoubleParamP(1.0), TPixelParamP(TPixel32::White));
m_imp->addKey(ck1);
@@ -126,8 +125,8 @@ TSpectrumParam::TSpectrumParam()
TSpectrumParam::TSpectrumParam(const TSpectrumParam &src)
: TParam(src.getName())
+ , m_imp(new TSpectrumParamImp(*src.m_imp))
{
- m_imp = new TSpectrumParamImp(*src.m_imp);
}
//---------------------------------------------------------
@@ -147,8 +146,8 @@ void TSpectrumParam::removeObserver(TParamObserver *obs)
//---------------------------------------------------------
TSpectrumParam::TSpectrumParam(int keyCount, TSpectrum::ColorKey keys[])
+ : m_imp(new TSpectrumParamImp(this))
{
- m_imp = new TSpectrumParamImp(this);
for (int i = 0; i < keyCount; i++) {
double v = keys[i].first;
TPixel32 pix = keys[i].second;
@@ -175,7 +174,6 @@ void TSpectrumParam::copy(TParam *src)
TSpectrumParam::~TSpectrumParam()
{
- delete m_imp;
}
//---------------------------------------------------------
diff --git a/toonz/sources/common/trop/trop_borders.cpp b/toonz/sources/common/trop/trop_borders.cpp
index 4332afd76..11baa40f0 100644
--- a/toonz/sources/common/trop/trop_borders.cpp
+++ b/toonz/sources/common/trop/trop_borders.cpp
@@ -201,7 +201,6 @@ ImageMeshesReader::ImageMeshesReader()
ImageMeshesReader::~ImageMeshesReader()
{
- delete m_imp;
}
//--------------------------------------------------------------------------------
diff --git a/toonz/sources/common/tsound/tsound_nt.cpp b/toonz/sources/common/tsound/tsound_nt.cpp
index d1c8e94e3..80a49084e 100644
--- a/toonz/sources/common/tsound/tsound_nt.cpp
+++ b/toonz/sources/common/tsound/tsound_nt.cpp
@@ -647,7 +647,6 @@ TSoundOutputDevice::~TSoundOutputDevice()
close();
WaitForSingleObject(m_imp->m_closeDevice, INFINITE);
CloseHandle(m_imp->m_closeDevice);
- delete m_imp;
}
//------------------------------------------------------------------------------
@@ -1111,14 +1110,14 @@ void WinSoundInputDevice::stop()
class RecordTask : public TThread::Runnable
{
public:
- RecordTask(TSoundInputDeviceImp *dev)
- : Runnable(), m_dev(dev) {}
+ RecordTask(std::shared_ptr<TSoundInputDeviceImp> dev)
+ : Runnable(), m_dev(std::move(dev)) {}
~RecordTask() {}
void run();
- TSoundInputDeviceImp *m_dev;
+ std::shared_ptr<TSoundInputDeviceImp> m_dev;
};
#endif
@@ -1268,7 +1267,6 @@ TSoundInputDevice::TSoundInputDevice() : m_imp(new TSoundInputDeviceImp())
TSoundInputDevice::~TSoundInputDevice()
{
- delete m_imp;
}
//------------------------------------------------------------------------------
diff --git a/toonz/sources/common/tstream/tstream.cpp b/toonz/sources/common/tstream/tstream.cpp
index 8e48833c8..bd4fb8260 100644
--- a/toonz/sources/common/tstream/tstream.cpp
+++ b/toonz/sources/common/tstream/tstream.cpp
@@ -256,8 +256,8 @@ TOStream::TOStream(const TFilePath &fp, bool compressed)
//---------------------------------------------------------------
-TOStream::TOStream(Imp *imp)
- : m_imp(imp)
+TOStream::TOStream(std::shared_ptr<Imp> imp)
+ : m_imp(std::move(imp))
{
assert(!imp->m_tagStack.empty());
ostream &os = *m_imp->m_os;
@@ -314,7 +314,6 @@ TOStream::~TOStream()
}
if (m_imp->m_chanOwner)
delete m_imp->m_os;
- delete m_imp;
}
} catch (...) {
}
@@ -497,12 +496,11 @@ TOStream::operator bool() const
}
//---------------------------------------------------------------
-
TOStream TOStream::child(string tagName)
{
assert(tagName != "");
m_imp->m_tagStack.push_back(tagName);
- return TOStream(m_imp);
+ return m_imp;
}
//---------------------------------------------------------------
@@ -981,7 +979,6 @@ TIStream::~TIStream()
{
if (m_imp->m_chanOwner)
delete m_imp->m_is;
- delete m_imp;
}
//---------------------------------------------------------------
diff --git a/toonz/sources/common/tsystem/tlogger.cpp b/toonz/sources/common/tsystem/tlogger.cpp
index 15411af55..151c3bb32 100644
--- a/toonz/sources/common/tsystem/tlogger.cpp
+++ b/toonz/sources/common/tsystem/tlogger.cpp
@@ -12,49 +12,6 @@
using std::endl;
-/*
-class TLogger::Imp {
-public:
- std::ofstream m_os;
- TThread::Mutex m_mutex;
-
- Imp(const TFilePath &fp)
- : m_os(toString(fp.getWideString()).c_str(), std::ios_base::out | std::ios_base::app)
- , m_mutex()
- {
- TTime t = TSystem::getCurrentTime();
- m_os << "========================" << std::endl;
- m_os << t.getDate() << " " << t.getTime() << endl;
- m_os << "Start logging" << endl << endl;
- }
-};
-
-
-TLogger::TLogger()
-: m_imp(new Imp(TSystem::getTempDir() + "log.txt"))
-{
-}
-
-
-TLogger::~TLogger()
-{
- delete m_imp;
-}
-
-TLogger *TLogger::instance()
-{
- static TLogger _instance;
- return &_instance;
-}
-
-
-void TLogger::print(string module, string msg)
-{
- QMutexLocker sl(m_imp->m_mutex);
- m_imp->m_os << module << " : " << msg << std::endl;
-}
-*/
-
class TLogger::Imp
{
public:
@@ -96,7 +53,6 @@ TLogger::TLogger()
TLogger::~TLogger()
{
- delete m_imp;
}
TLogger *TLogger::instance()
diff --git a/toonz/sources/common/tvectorimage/tl2lautocloser.cpp b/toonz/sources/common/tvectorimage/tl2lautocloser.cpp
index c058e85cd..f91ee2b6b 100644
--- a/toonz/sources/common/tvectorimage/tl2lautocloser.cpp
+++ b/toonz/sources/common/tvectorimage/tl2lautocloser.cpp
@@ -529,8 +529,6 @@ TL2LAutocloser::TL2LAutocloser()
TL2LAutocloser::~TL2LAutocloser()
{
- delete m_imp;
- m_imp = 0;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/common/tvectorimage/tl2lautocloser.h b/toonz/sources/common/tvectorimage/tl2lautocloser.h
index ec319a39e..2a4cbbdb9 100644
--- a/toonz/sources/common/tvectorimage/tl2lautocloser.h
+++ b/toonz/sources/common/tvectorimage/tl2lautocloser.h
@@ -1,8 +1,8 @@
-
-
#ifndef T_L2LAUTOCLOSER_H
#define T_L2LAUTOCLOSER_H
+#include <memory>
+
#include "tgeometry.h"
#undef DVAPI
@@ -28,7 +28,7 @@ class TStroke;
class DVAPI TL2LAutocloser
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
TL2LAutocloser();
diff --git a/toonz/sources/common/tvectorimage/tregion.cpp b/toonz/sources/common/tvectorimage/tregion.cpp
index e1f3946a7..0b27899af 100644
--- a/toonz/sources/common/tvectorimage/tregion.cpp
+++ b/toonz/sources/common/tvectorimage/tregion.cpp
@@ -144,7 +144,6 @@ TRegion::TRegion()
TRegion::~TRegion()
{
- delete m_imp;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/common/tvectorimage/tstroke.cpp b/toonz/sources/common/tvectorimage/tstroke.cpp
index 999749d04..9e306f95e 100644
--- a/toonz/sources/common/tvectorimage/tstroke.cpp
+++ b/toonz/sources/common/tvectorimage/tstroke.cpp
@@ -1276,7 +1276,7 @@ TStroke::TStroke()
p[1] = p[0];
p[2] = p[1];
- m_imp = new TStroke::Imp(p);
+ m_imp.reset(new TStroke::Imp(p));
/*
// da fissare deve trovarsi prima della init
@@ -1289,32 +1289,30 @@ TStroke::TStroke()
// Build a stroke from a set of ThickPoint
TStroke::TStroke(const vector<TThickPoint> &v)
: TSmartObject(m_classCode)
+ , m_imp(new TStroke::Imp(v))
{
- m_imp = new TStroke::Imp(v);
}
//-----------------------------------------------------------------------------
TStroke::TStroke(const vector<TPointD> &v)
: TSmartObject(m_classCode)
+ , m_imp(new TStroke::Imp(v))
{
- m_imp = new TStroke::Imp(v);
}
//-----------------------------------------------------------------------------
TStroke::~TStroke()
{
- delete m_imp;
}
//-----------------------------------------------------------------------------
TStroke::TStroke(const TStroke &other)
: TSmartObject(m_classCode)
+ , m_imp(new TStroke::Imp())
{
- m_imp = new TStroke::Imp();
-
m_imp->m_bBox = other.getBBox();
m_imp->m_isValidLength = other.m_imp->m_isValidLength;
m_imp->m_isOutlineValid = other.m_imp->m_isOutlineValid;
diff --git a/toonz/sources/common/tvectorimage/tvectorimage.cpp b/toonz/sources/common/tvectorimage/tvectorimage.cpp
index f6c3572c6..248f4d071 100644
--- a/toonz/sources/common/tvectorimage/tvectorimage.cpp
+++ b/toonz/sources/common/tvectorimage/tvectorimage.cpp
@@ -104,8 +104,8 @@ TVectorImage::Imp::~Imp()
//=============================================================================
TVectorImage::TVectorImage(bool loaded)
+ : m_imp(new TVectorImage::Imp(this))
{
- m_imp = new TVectorImage::Imp(this);
if (loaded)
m_imp->m_justLoaded = true;
}
@@ -114,7 +114,6 @@ TVectorImage::TVectorImage(bool loaded)
TVectorImage::~TVectorImage()
{
- delete m_imp;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/common/tvrender/tinbetween.cpp b/toonz/sources/common/tvrender/tinbetween.cpp
index 82e6ec0d7..f9d2c399f 100644
--- a/toonz/sources/common/tvrender/tinbetween.cpp
+++ b/toonz/sources/common/tvrender/tinbetween.cpp
@@ -709,7 +709,6 @@ TInbetween::TInbetween(const TVectorImageP firstImage, const TVectorImageP lastI
TInbetween::~TInbetween()
{
- delete m_imp;
}
//-------------------------------------------------------------------
diff --git a/toonz/sources/common/tvrender/tofflinegl.cpp b/toonz/sources/common/tvrender/tofflinegl.cpp
index 5ea920226..6ed5cd56f 100644
--- a/toonz/sources/common/tvrender/tofflinegl.cpp
+++ b/toonz/sources/common/tvrender/tofflinegl.cpp
@@ -83,7 +83,7 @@ public:
//-----------------------------------------------------------------------------
- WIN32Implementation(TDimension rasterSize, const TOfflineGL::Imp *shared = 0)
+ WIN32Implementation(TDimension rasterSize, std::shared_ptr<TOfflineGL::Imp> shared)
: TOfflineGL::Imp(rasterSize.lx, rasterSize.ly)
{
m_offData = 0;
@@ -157,7 +157,7 @@ public:
//-----------------------------------------------------------------------------
- void createContext(TDimension rasterSize, const TOfflineGL::Imp *shared)
+ void createContext(TDimension rasterSize, std::shared_ptr<TOfflineGL::Imp> shared)
{
QMutexLocker locker(&win32ImpMutex);
@@ -221,7 +221,7 @@ public:
if (shared) {
// Share shared's display lists
- const WIN32Implementation *sharedImp = dynamic_cast<const WIN32Implementation *>(shared);
+ const WIN32Implementation *sharedImp = dynamic_cast<const WIN32Implementation *>(shared.get());
assert(sharedImp);
bool ok = wglShareLists(sharedImp->m_hglRC, m_hglRC);
@@ -298,9 +298,9 @@ public:
};
// default imp generator
-TOfflineGL::Imp *defaultOfflineGLGenerator(const TDimension &dim, const TOfflineGL::Imp *shared)
+std::shared_ptr<TOfflineGL::Imp> defaultOfflineGLGenerator(const TDimension &dim, std::shared_ptr<TOfflineGL::Imp> shared)
{
- return new WIN32Implementation(dim, shared);
+ return std::make_shared<WIN32Implementation>(dim, shared);
}
//=============================================================================
@@ -502,16 +502,16 @@ public:
}
};
-TOfflineGL::Imp *defaultOfflineGLGenerator(const TDimension &dim)
+std::shared_ptr<TOfflineGL::Imp> defaultOfflineGLGenerator(const TDimension &dim, std::shared_ptr<TOfflineGL::Imp> shared)
{
- return new XImplementation(dim);
+ return std::make_shared<XImplementation>(dim);
}
#elif MACOSX
-TOfflineGL::Imp *defaultOfflineGLGenerator(const TDimension &dim, const TOfflineGL::Imp *shared)
+std::shared_ptr<TOfflineGL::Imp> defaultOfflineGLGenerator(const TDimension &dim, std::shared_ptr<TOfflineGL::Imp> shared)
{
- return new QtOfflineGL(dim, shared);
+ return std::make_shared<QtOfflineGL>(dim, shared);
}
#endif
@@ -538,11 +538,11 @@ class MessageCreateContext : public TThread::Message
TOfflineGL *m_ogl;
TDimension m_size;
- const TOfflineGL::Imp *m_shared;
+ std::shared_ptr<TOfflineGL::Imp> m_shared;
public:
- MessageCreateContext(TOfflineGL *ogl, const TDimension &size, const TOfflineGL::Imp *shared)
- : m_ogl(ogl), m_size(size), m_shared(shared) {}
+ MessageCreateContext(TOfflineGL *ogl, const TDimension &size, std::shared_ptr<TOfflineGL::Imp> shared)
+ : m_ogl(ogl), m_size(size), m_shared(std::move(shared)) {}
void onDeliver()
{
@@ -560,19 +560,18 @@ public:
//--------------------------------------------------
TOfflineGL::TOfflineGL(TDimension dim, const TOfflineGL *shared)
- : m_imp(0)
{
#if defined(LINUX)
XScopedLock xsl;
#endif
- const TOfflineGL::Imp *sharedImp = shared ? shared->m_imp : 0;
+ std::shared_ptr<Imp> sharedImp = shared ? shared->m_imp : 0;
/*
元のコードは(別スレッドから呼び出すための) offline renderer を作って main thread に dispatch するという訳のわからないことをしていたが Q*GLContext は thread context を超えられないので直接生成してこのコンテキストで閉じる.
別スレッドには dispatch しない.
*/
- m_imp = currentImpGenerator(dim, sharedImp);
+ m_imp = currentImpGenerator(dim, std::move(sharedImp));
initMatrix();
}
@@ -585,8 +584,6 @@ TOfflineGL::TOfflineGL(const TRaster32P &raster, const TOfflineGL *shared)
XScopedLock xsl;
#endif
- //m_imp = new Imp(raster->getSize());
-
m_imp = currentImpGenerator(raster->getSize(), shared->m_imp);
initMatrix();
@@ -601,7 +598,6 @@ TOfflineGL::TOfflineGL(const TRaster32P &raster, const TOfflineGL *shared)
TOfflineGL::~TOfflineGL()
{
- delete m_imp;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/common/tvrender/tstrokedeformations.cpp b/toonz/sources/common/tvrender/tstrokedeformations.cpp
index f5c1591d2..0a36b5abb 100644
--- a/toonz/sources/common/tvrender/tstrokedeformations.cpp
+++ b/toonz/sources/common/tvrender/tstrokedeformations.cpp
@@ -189,8 +189,8 @@ struct TStrokePointDeformation::Imp {
TStrokePointDeformation::TStrokePointDeformation(const TPointD &center,
double radius)
+ : m_imp(new Imp(center, radius))
{
- m_imp = new Imp(center, radius);
}
//-----------------------------------------------------------------------------
@@ -198,15 +198,14 @@ TStrokePointDeformation::TStrokePointDeformation(const TPointD &center,
TStrokePointDeformation::TStrokePointDeformation(const TPointD &vect,
const TPointD &center,
double radius)
+ : m_imp(new Imp(vect, center, radius))
{
- m_imp = new Imp(vect, center, radius);
}
//-----------------------------------------------------------------------------
TStrokePointDeformation::~TStrokePointDeformation()
{
- delete m_imp;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/include/ext/meshtexturizer.h b/toonz/sources/include/ext/meshtexturizer.h
index 5ade95eda..99724e206 100644
--- a/toonz/sources/include/ext/meshtexturizer.h
+++ b/toonz/sources/include/ext/meshtexturizer.h
@@ -1,8 +1,8 @@
-
-
#ifndef MESHTEXTURIZER_H
#define MESHTEXTURIZER_H
+#include <memory>
+
// TnzCore includes
#include "traster.h"
#include "tgl.h" // OpenGL includes
@@ -95,7 +95,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
private:
// Not copyable
diff --git a/toonz/sources/include/ext/plasticdeformer.h b/toonz/sources/include/ext/plasticdeformer.h
index 89ed71308..726571da1 100644
--- a/toonz/sources/include/ext/plasticdeformer.h
+++ b/toonz/sources/include/ext/plasticdeformer.h
@@ -1,8 +1,8 @@
-
-
#ifndef PLASTICDEFORMER_H
#define PLASTICDEFORMER_H
+#include <memory>
+
// TnzCore includes
#include "tgeometry.h"
#include "tmeshimage.h"
@@ -42,7 +42,7 @@
class DVAPI PlasticDeformer
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
PlasticDeformer();
diff --git a/toonz/sources/include/ext/plasticdeformerstorage.h b/toonz/sources/include/ext/plasticdeformerstorage.h
index f5840dfd1..36cab1b6c 100644
--- a/toonz/sources/include/ext/plasticdeformerstorage.h
+++ b/toonz/sources/include/ext/plasticdeformerstorage.h
@@ -1,8 +1,8 @@
-
-
#ifndef PLASTIDEFORMERSTORAGE_H
#define PLASTIDEFORMERSTORAGE_H
+#include <memory>
+
// TnzExt includes
#include "ext/plasticdeformer.h"
@@ -158,7 +158,7 @@ private:
class DVAPI PlasticDeformerStorage
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
enum DataType {
diff --git a/toonz/sources/include/ext/plasticskeleton.h b/toonz/sources/include/ext/plasticskeleton.h
index 64b490292..774ce798f 100644
--- a/toonz/sources/include/ext/plasticskeleton.h
+++ b/toonz/sources/include/ext/plasticskeleton.h
@@ -1,8 +1,8 @@
-
-
#ifndef PLASTICSKELETON_H
#define PLASTICSKELETON_H
+#include <memory>
+
// TnzCore includes
#include "tsmartpointer.h"
#include "tpersist.h"
@@ -102,7 +102,7 @@ class DVAPI PlasticSkeleton : public TSmartObject, public tcg::Mesh<PlasticSkele
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
typedef tcg::Mesh<PlasticSkeletonVertex, tcg::Edge, tcg::FaceN<3>> mesh_type;
diff --git a/toonz/sources/include/ext/plasticskeletondeformation.h b/toonz/sources/include/ext/plasticskeletondeformation.h
index 1301f94e2..17dad65d0 100644
--- a/toonz/sources/include/ext/plasticskeletondeformation.h
+++ b/toonz/sources/include/ext/plasticskeletondeformation.h
@@ -1,8 +1,8 @@
-
-
#ifndef PLASTICSKELETONDEFORMATION_H
#define PLASTICSKELETONDEFORMATION_H
+#include <memory>
+
// TnzCore includes
#include "tsmartpointer.h"
#include "tdoubleparam.h"
@@ -139,7 +139,7 @@ class DVAPI PlasticSkeletonDeformation : public TSmartObject, public TPersist
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
typedef tcg::any_it<int, int, void *>::bidirectional skelId_iterator;
diff --git a/toonz/sources/include/permissionsmanager.h b/toonz/sources/include/permissionsmanager.h
index a31714691..b8c1c1197 100644
--- a/toonz/sources/include/permissionsmanager.h
+++ b/toonz/sources/include/permissionsmanager.h
@@ -1,8 +1,8 @@
-
-
#ifndef PERMISSIONSMANAGER_INCLUDED
#define PERMISSIONSMANAGER_INCLUDED
+#include <memory>
+
// TnzCore includes
#include "tcommon.h"
@@ -31,7 +31,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
private:
PermissionsManager();
diff --git a/toonz/sources/include/stdfx/shadingcontext.h b/toonz/sources/include/stdfx/shadingcontext.h
index de1eaea77..6619395d4 100644
--- a/toonz/sources/include/stdfx/shadingcontext.h
+++ b/toonz/sources/include/stdfx/shadingcontext.h
@@ -1,8 +1,8 @@
-
-
#ifndef SHADINGCONTEXT_H
#define SHADINGCONTEXT_H
+#include <memory>
+
// Glew include
#include <GL/glew.h>
@@ -89,7 +89,7 @@ public:
private:
struct Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
// Not copyable
ShadingContext(const ShadingContext &);
diff --git a/toonz/sources/include/tcli.h b/toonz/sources/include/tcli.h
index 7b3dff87e..5aa2f59f1 100644
--- a/toonz/sources/include/tcli.h
+++ b/toonz/sources/include/tcli.h
@@ -1,8 +1,8 @@
-
-
#ifndef TCLI_INCLUDED
#define TCLI_INCLUDED
+#include <memory>
+
//#include "tcommon.h" contenuto in tconvert.h
#include "tconvert.h"
@@ -342,7 +342,7 @@ class UsageImp;
class DVAPI Usage
{
- UsageImp *m_imp;
+ std::unique_ptr<UsageImp> m_imp;
public:
Usage(string progName);
diff --git a/toonz/sources/include/tdoubleparam.h b/toonz/sources/include/tdoubleparam.h
index 384d14fec..3cc51f642 100644
--- a/toonz/sources/include/tdoubleparam.h
+++ b/toonz/sources/include/tdoubleparam.h
@@ -1,8 +1,8 @@
-
-
#ifndef TDOUBLEPARAM_H
#define TDOUBLEPARAM_H
+#include <memory>
+
// TnzCore includes
#include "tgeometry.h"
#include "tfilepath.h"
@@ -55,7 +55,7 @@ class DVAPI TDoubleParam : public TParam
PERSIST_DECLARATION(TDoubleParam)
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
TDoubleParam(double v = 0.0);
diff --git a/toonz/sources/include/texpression.h b/toonz/sources/include/texpression.h
index 996b8ea3e..c29fb3632 100644
--- a/toonz/sources/include/texpression.h
+++ b/toonz/sources/include/texpression.h
@@ -1,8 +1,8 @@
-
-
#ifndef TEXPRESSION_INCLUDED
#define TEXPRESSION_INCLUDED
+#include <memory>
+
// TnzCore includes
#include "tcommon.h"
@@ -47,7 +47,7 @@ class Calculator;
class DVAPI TExpression
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
TExpression();
diff --git a/toonz/sources/include/tfarmserver.h b/toonz/sources/include/tfarmserver.h
index ef1e6ee94..3470f0448 100644
--- a/toonz/sources/include/tfarmserver.h
+++ b/toonz/sources/include/tfarmserver.h
@@ -1,10 +1,8 @@
-
-
#ifndef TFARMSERVER_H
#define TFARMSERVER_H
-//#include "texception.h"
-//#include "tconvert.h"
+#include <memory>
+
#include "tcommon.h"
#include <QString>
@@ -87,7 +85,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
};
#endif
diff --git a/toonz/sources/include/tfarmtask.h b/toonz/sources/include/tfarmtask.h
index b9d8f515f..55d5c5e69 100644
--- a/toonz/sources/include/tfarmtask.h
+++ b/toonz/sources/include/tfarmtask.h
@@ -1,8 +1,8 @@
-
-
#ifndef TFARMTASK_H
#define TFARMTASK_H
+#include <memory>
+
#include <qdatetime>
#include "tpersist.h"
#include "tfarmplatforms.h"
@@ -196,7 +196,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
};
#endif
diff --git a/toonz/sources/include/tfx.h b/toonz/sources/include/tfx.h
index 2f77a36b8..4be1eaa2a 100644
--- a/toonz/sources/include/tfx.h
+++ b/toonz/sources/include/tfx.h
@@ -1,8 +1,8 @@
-
-
#ifndef TFX_INCLUDED
#define TFX_INCLUDED
+#include <memory>
+
// TnzCore includes
#include "tsmartpointer.h"
#include "tpersist.h"
diff --git a/toonz/sources/include/tfxcachemanager.h b/toonz/sources/include/tfxcachemanager.h
index d8ee3ab8e..e2ae86526 100644
--- a/toonz/sources/include/tfxcachemanager.h
+++ b/toonz/sources/include/tfxcachemanager.h
@@ -1,8 +1,8 @@
-
-
#ifndef TFXCACHEMANAGER_H
#define TFXCACHEMANAGER_H
+#include <memory>
+
#include "trenderresourcemanager.h"
#include "tcacheresource.h"
@@ -182,7 +182,7 @@ private:
std::set<std::string> m_staticCacheIds;
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
TFxCacheManager();
diff --git a/toonz/sources/include/tgrammar.h b/toonz/sources/include/tgrammar.h
index c0909b6b4..bf91dff72 100644
--- a/toonz/sources/include/tgrammar.h
+++ b/toonz/sources/include/tgrammar.h
@@ -1,8 +1,8 @@
-
-
#ifndef TGRAMMAR_INCLUDED
#define TGRAMMAR_INCLUDED
+#include <memory>
+
// TnzCore includes
#include "tcommon.h"
@@ -198,7 +198,7 @@ public:
class DVAPI Grammar
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
Grammar();
diff --git a/toonz/sources/include/timagecache.h b/toonz/sources/include/timagecache.h
index 98c15d2f5..ec44926ef 100644
--- a/toonz/sources/include/timagecache.h
+++ b/toonz/sources/include/timagecache.h
@@ -1,8 +1,8 @@
-
-
#ifndef TIMAGECACHE_H
#define TIMAGECACHE_H
+#include <memory>
+
// TnzCore includes
#include "tcommon.h"
#include "timage.h"
@@ -55,7 +55,7 @@ of system memory. This is especially true on 32-bit OSes.
class DVAPI TImageCache
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
static TImageCache *instance();
diff --git a/toonz/sources/include/tinbetween.h b/toonz/sources/include/tinbetween.h
index 467086fbf..28bebc9f4 100644
--- a/toonz/sources/include/tinbetween.h
+++ b/toonz/sources/include/tinbetween.h
@@ -1,9 +1,7 @@
-
-
#ifndef TINBETWEEN_H
#define TINBETWEEN_H
-//#include "tvectorimage.h"
+#include <memory>
#include "tcommon.h"
class TVectorImageP;
@@ -21,9 +19,8 @@ class TVectorImageP;
class DVAPI TInbetween
{
-
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
TInbetween(const TVectorImageP firstImage, const TVectorImageP lastImage);
diff --git a/toonz/sources/include/tlogger.h b/toonz/sources/include/tlogger.h
index 4c59de953..7932ec1ea 100644
--- a/toonz/sources/include/tlogger.h
+++ b/toonz/sources/include/tlogger.h
@@ -1,8 +1,8 @@
-
-
#ifndef TLOGGER_INCLUDED
#define TLOGGER_INCLUDED
+#include <memory>
+
//
// TLogger
//
@@ -34,7 +34,7 @@ class TFilePath;
class DVAPI TLogger
{ // singleton
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
TLogger();
diff --git a/toonz/sources/include/tmeshimage.h b/toonz/sources/include/tmeshimage.h
index a83d75605..5c84e1215 100644
--- a/toonz/sources/include/tmeshimage.h
+++ b/toonz/sources/include/tmeshimage.h
@@ -1,8 +1,8 @@
-
-
#ifndef TMESHIMAGE_INCLUDED
#define TMESHIMAGE_INCLUDED
+#include <memory>
+
// TnzCore includes
#include "tsmartpointer.h"
#include "tpersist.h"
@@ -172,14 +172,14 @@ struct graph_traits<TTextureMesh>
class DVAPI TMeshImage : public TImage
{
class Imp;
- Imp *m_imp;
+ std::shared_ptr<Imp> m_imp;
public:
typedef std::vector<TTextureMeshP> meshes_container;
public:
TMeshImage();
- TMeshImage(Imp *imp);
+ TMeshImage(std::shared_ptr<Imp> imp);
~TMeshImage();
TMeshImage(const TMeshImage &other);
diff --git a/toonz/sources/include/tnotanimatableparam.h b/toonz/sources/include/tnotanimatableparam.h
index 1f5ad8676..b4cab5726 100644
--- a/toonz/sources/include/tnotanimatableparam.h
+++ b/toonz/sources/include/tnotanimatableparam.h
@@ -1,8 +1,8 @@
-
-
#ifndef TNOTANIMATABLEPARAM_H
#define TNOTANIMATABLEPARAM_H
+#include <memory>
+
#include "tparam.h"
#include "tparamchange.h"
#include "tfilepath.h"
@@ -331,7 +331,7 @@ public:
void saveData(TOStream &os);
private:
- TEnumParamImp *m_imp;
+ std::unique_ptr<TEnumParamImp> m_imp;
};
typedef TEnumParam TIntEnumParam;
diff --git a/toonz/sources/include/tofflinegl.h b/toonz/sources/include/tofflinegl.h
index a7cf984a5..3049b8bb9 100644
--- a/toonz/sources/include/tofflinegl.h
+++ b/toonz/sources/include/tofflinegl.h
@@ -1,10 +1,8 @@
-
-
#ifndef TOFFLINEGL_INCLUDED
#define TOFFLINEGL_INCLUDED
-//#include "trasterimage.h"
-//#include "tvectorimage.h"
+#include <memory>
+
#include "tgl.h"
#undef DVAPI
@@ -47,12 +45,12 @@ public:
virtual ~Imp(){};
virtual void makeCurrent() = 0;
virtual void doneCurrent() = 0; // Da implementare in Imp
- virtual void createContext(TDimension rasterSize, const TOfflineGL::Imp *shared) = 0;
+ virtual void createContext(TDimension rasterSize, std::shared_ptr<Imp> shared) = 0;
virtual void getRaster(TRaster32P) = 0;
virtual int getLx() const { return m_lx; }
virtual int getLy() const { return m_ly; }
};
- typedef Imp *ImpGenerator(const TDimension &dim, const TOfflineGL::Imp *shared);
+ typedef std::shared_ptr<Imp> ImpGenerator(const TDimension &dim, std::shared_ptr<Imp> shared);
static ImpGenerator *defineImpGenerator(ImpGenerator *impGenerator);
TOfflineGL(TDimension dim, const TOfflineGL *shared = 0);
@@ -87,7 +85,7 @@ public:
static TOfflineGL *getStock(TDimension dim);
// si usa cosi': TOfflineGL *ogl = TOfflineGL::getStock(d);
// non bisogna liberare ogl
- Imp *m_imp;
+ std::shared_ptr<Imp> m_imp;
private:
private:
diff --git a/toonz/sources/include/toonz/autoclose.h b/toonz/sources/include/toonz/autoclose.h
index 1d67bdcad..3465d5080 100644
--- a/toonz/sources/include/toonz/autoclose.h
+++ b/toonz/sources/include/toonz/autoclose.h
@@ -1,8 +1,8 @@
-
-
#ifndef _TAUTOCLOSE_H_
#define _TAUTOCLOSE_H_
+#include <memory>
+
#include "tgeometry.h"
#include "traster.h"
@@ -35,7 +35,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
//not implemented
TAutocloser();
diff --git a/toonz/sources/include/toonz/imagemanager.h b/toonz/sources/include/toonz/imagemanager.h
index a8b9e78b4..273c0560a 100644
--- a/toonz/sources/include/toonz/imagemanager.h
+++ b/toonz/sources/include/toonz/imagemanager.h
@@ -1,8 +1,8 @@
-
-
#ifndef IMAGEMANAGER_H
#define IMAGEMANAGER_H
+#include <memory>
+
// TnzCore includes
#include "timage.h"
#include "timageinfo.h"
@@ -170,7 +170,7 @@ public:
private:
struct Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
private:
ImageManager();
diff --git a/toonz/sources/include/toonz/tlog.h b/toonz/sources/include/toonz/tlog.h
index f2a1b3d97..3f3fc161c 100644
--- a/toonz/sources/include/toonz/tlog.h
+++ b/toonz/sources/include/toonz/tlog.h
@@ -1,8 +1,8 @@
-
-
#ifndef TSYSLOG_H
#define TSYSLOG_H
+#include <memory>
+
#include "tcommon.h"
class TFilePath;
@@ -39,7 +39,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
};
#endif
diff --git a/toonz/sources/include/toonz/tstageobjecttree.h b/toonz/sources/include/toonz/tstageobjecttree.h
index 1d852a81d..575e0a236 100644
--- a/toonz/sources/include/toonz/tstageobjecttree.h
+++ b/toonz/sources/include/toonz/tstageobjecttree.h
@@ -1,8 +1,8 @@
-
-
#ifndef T_STAGE_OBJECT_TREE_INCLUDED
#define T_STAGE_OBJECT_TREE_INCLUDED
+#include <memory>
+
#include "toonz/tstageobject.h"
#undef DVAPI
@@ -70,7 +70,7 @@ class DVAPI TStageObjectTree : public TPersist
{
PERSIST_DECLARATION(TStageObjectTree)
struct TStageObjectTreeImp;
- TStageObjectTreeImp *m_imp;
+ std::unique_ptr<TStageObjectTreeImp> m_imp;
// usato solo sotto #ifndef NDEBUG
void checkIntegrity();
diff --git a/toonz/sources/include/toonz/txsheet.h b/toonz/sources/include/toonz/txsheet.h
index 8b5cfb492..ee91d067f 100644
--- a/toonz/sources/include/toonz/txsheet.h
+++ b/toonz/sources/include/toonz/txsheet.h
@@ -1,8 +1,8 @@
-
-
#ifndef XSHEET_INCLUDED
#define XSHEET_INCLUDED
+#include <memory>
+
// TnzCore includes
#include "traster.h"
#include "tpersist.h"
@@ -118,7 +118,7 @@ private:
The TXsheetImp struct provides all objects necessary to define the \b TXsheet class.
*/
struct TXsheetImp;
- TXsheetImp *m_imp;
+ std::unique_ptr<TXsheetImp> m_imp;
TXshNoteSet *m_notes;
SoundProperties *m_soundProperties;
diff --git a/toonz/sources/include/toonzqt/infoviewer.h b/toonz/sources/include/toonzqt/infoviewer.h
index 36638b9ec..a8286dbe9 100644
--- a/toonz/sources/include/toonzqt/infoviewer.h
+++ b/toonz/sources/include/toonzqt/infoviewer.h
@@ -1,8 +1,8 @@
-
-
#ifndef INFOVIEWER_H
#define INFOVIEWER_H
+#include <memory>
+
#include "toonzqt/dvdialog.h"
#undef DVAPI
@@ -23,7 +23,7 @@ class InfoViewerImp;
class DVAPI InfoViewer : public DVGui::Dialog
{
Q_OBJECT
- InfoViewerImp *m_imp;
+ std::unique_ptr<InfoViewerImp> m_imp;
QWidget *m_parent;
public:
diff --git a/toonz/sources/include/tparamcontainer.h b/toonz/sources/include/tparamcontainer.h
index 49deaa047..570ac68bf 100644
--- a/toonz/sources/include/tparamcontainer.h
+++ b/toonz/sources/include/tparamcontainer.h
@@ -1,8 +1,8 @@
-
-
#ifndef TPARAMCONTAINER_INCLUDED
#define TPARAMCONTAINER_INCLUDED
+#include <memory>
+
#include "tparam.h"
//#include "tfx.h"
#include "tcommon.h"
@@ -69,7 +69,7 @@ public:
class DVAPI TParamContainer
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
TParamContainer();
diff --git a/toonz/sources/include/tparser.h b/toonz/sources/include/tparser.h
index 5fb0e2ec9..4b8a093c1 100644
--- a/toonz/sources/include/tparser.h
+++ b/toonz/sources/include/tparser.h
@@ -1,8 +1,8 @@
-
-
#ifndef TPARSER_INCLUDED
#define TPARSER_INCLUDED
+#include <memory>
+
#include "tcommon.h"
#include "tgrammar.h"
@@ -27,7 +27,7 @@ struct DVAPI SyntaxToken {
class DVAPI Parser
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
Parser(const Grammar *grammar);
diff --git a/toonz/sources/include/tpredictivecachemanager.h b/toonz/sources/include/tpredictivecachemanager.h
index b3a8bf2a3..bdf0a7c0d 100644
--- a/toonz/sources/include/tpredictivecachemanager.h
+++ b/toonz/sources/include/tpredictivecachemanager.h
@@ -1,8 +1,8 @@
-
-
#ifndef TPREDICTIVECACHEMANAGER_H
#define TPREDICTIVECACHEMANAGER_H
+#include <memory>
+
#include "tfxcachemanager.h"
#include "tgeometry.h"
@@ -35,7 +35,7 @@ class DVAPI TPredictiveCacheManager
T_RENDER_RESOURCE_MANAGER
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
TPredictiveCacheManager();
diff --git a/toonz/sources/include/tregion.h b/toonz/sources/include/tregion.h
index 56568f32d..2ac3e02a5 100644
--- a/toonz/sources/include/tregion.h
+++ b/toonz/sources/include/tregion.h
@@ -1,11 +1,11 @@
-
-
//-----------------------------------------------------------------------------
// tregion.h: interface for the TRegion class.
//-----------------------------------------------------------------------------
#if !defined(TREGION_H)
#define TREGION_H
+#include <memory>
+
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
@@ -165,7 +165,7 @@ typedef TSmartPointerT<TEdge> TEdgeP;
class DVAPI TRegion
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
TRegion();
diff --git a/toonz/sources/include/trop_borders.h b/toonz/sources/include/trop_borders.h
index ef75e6374..c58359eed 100644
--- a/toonz/sources/include/trop_borders.h
+++ b/toonz/sources/include/trop_borders.h
@@ -1,8 +1,8 @@
-
-
#ifndef TROP_BORDERS_H
#define TROP_BORDERS_H
+#include <memory>
+
// TnzCore includes
#include "tsmartpointer.h"
#include "tgeometry.h"
@@ -159,7 +159,7 @@ typedef TSmartPointerT<ImageMesh> ImageMeshP;
class DVAPI ImageMeshesReader
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
ImageMeshesReader();
diff --git a/toonz/sources/include/tsmartpointer.h b/toonz/sources/include/tsmartpointer.h
index 8133dcdff..346f1c06b 100644
--- a/toonz/sources/include/tsmartpointer.h
+++ b/toonz/sources/include/tsmartpointer.h
@@ -1,8 +1,8 @@
-
-
#ifndef TSMARTPOINTER_INCLUDED
#define TSMARTPOINTER_INCLUDED
+#include <memory>
+
#include "tutil.h"
#include "tatomicvar.h"
@@ -115,7 +115,7 @@ class DVAPI TSmartPointerT
{
protected:
- T *m_pointer;
+ T* m_pointer;
public:
TSmartPointerT() : m_pointer(0) {}
@@ -126,7 +126,7 @@ public:
m_pointer->addRef();
}
- TSmartPointerT(T *pointer) : m_pointer(pointer)
+ TSmartPointerT(T* pointer) : m_pointer(pointer)
{
if (m_pointer)
m_pointer->addRef();
diff --git a/toonz/sources/include/tsound.h b/toonz/sources/include/tsound.h
index 0cd52da6b..8f3b54394 100644
--- a/toonz/sources/include/tsound.h
+++ b/toonz/sources/include/tsound.h
@@ -1,8 +1,8 @@
-
-
#ifndef TSOUND_INCLUDED
#define TSOUND_INCLUDED
+#include <memory>
+
#include "tsmartpointer.h"
#include "texception.h"
#include "tthreadmessage.h"
@@ -285,7 +285,7 @@ class TSoundInputDeviceImp;
*/
class DVAPI TSoundInputDevice
{
- TSoundInputDeviceImp *m_imp;
+ std::shared_ptr<TSoundInputDeviceImp> m_imp;
public:
enum Source {
@@ -360,7 +360,7 @@ class TSoundOutputDeviceImp;
*/
class DVAPI TSoundOutputDevice
{
- TSoundOutputDeviceImp *m_imp;
+ std::unique_ptr<TSoundOutputDeviceImp> m_imp;
public:
TSoundOutputDevice();
diff --git a/toonz/sources/include/tspectrumparam.h b/toonz/sources/include/tspectrumparam.h
index 31be476cf..6ea7433b8 100644
--- a/toonz/sources/include/tspectrumparam.h
+++ b/toonz/sources/include/tspectrumparam.h
@@ -1,8 +1,8 @@
-
-
#ifndef TSPECTRUMPARAM_H
#define TSPECTRUMPARAM_H
+#include <memory>
+
#include "tspectrum.h"
#include "tparamset.h"
@@ -37,7 +37,7 @@ class DVAPI TSpectrumParam : public TParam
{
PERSIST_DECLARATION(TSpectrumParam)
- TSpectrumParamImp *m_imp;
+ std::unique_ptr<TSpectrumParamImp> m_imp;
public:
TSpectrumParam();
diff --git a/toonz/sources/include/tstencilcontrol.h b/toonz/sources/include/tstencilcontrol.h
index f8f45c4c6..4eb63c92a 100644
--- a/toonz/sources/include/tstencilcontrol.h
+++ b/toonz/sources/include/tstencilcontrol.h
@@ -1,8 +1,8 @@
-
-
#ifndef TSTENCILCONTROL_H
#define TSTENCILCONTROL_H
+#include <memory>
+
#include "tcommon.h"
#undef DVAPI
@@ -34,7 +34,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
static TStencilControl *instance();
diff --git a/toonz/sources/include/tstream.h b/toonz/sources/include/tstream.h
index ddb5cbde7..7f85a6454 100644
--- a/toonz/sources/include/tstream.h
+++ b/toonz/sources/include/tstream.h
@@ -1,8 +1,8 @@
-
-
#ifndef TSTREAM_H
#define TSTREAM_H
+#include <memory>
+
// TnzCore includes
#include "tpixel.h"
@@ -44,7 +44,7 @@ typedef std::pair<int, int> VersionNumber; //!< Integer pair storing the major a
class DVAPI TIStream
{
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
/*!
@@ -168,10 +168,10 @@ TIStream &operator>>(TIStream &is, T *&v)
class DVAPI TOStream
{
class Imp;
- Imp *m_imp;
+ std::shared_ptr<Imp> m_imp;
private:
- TOStream(Imp *imp); //!< deprecated
+ TOStream(std::shared_ptr<Imp> imp); //!< deprecated
public:
/*!
@@ -238,8 +238,8 @@ public:
private:
// Not copyable
- TOStream(const TOStream &); //!< Not implemented
- TOStream &operator=(const TOStream &); //!< Not implemented
+ TOStream(const TOStream &) = delete; //!< Not implemented
+ TOStream &operator=(const TOStream &) = delete; //!< Not implemented
};
#endif // TSTREAM_H
diff --git a/toonz/sources/include/tstroke.h b/toonz/sources/include/tstroke.h
index 2a9384884..9d739d546 100644
--- a/toonz/sources/include/tstroke.h
+++ b/toonz/sources/include/tstroke.h
@@ -1,8 +1,8 @@
-
-
#ifndef TSTROKE_H
#define TSTROKE_H
+#include <memory>
+
#include "tsmartpointer.h"
#include "tgeometry.h"
#include "tthreadmessage.h"
@@ -50,7 +50,7 @@ class DVAPI TStroke : public TSmartObject
private:
//! Pimpl of a TStroke
struct Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
struct OutlineOptions;
diff --git a/toonz/sources/include/ttcpip.h b/toonz/sources/include/ttcpip.h
index 693dd15f1..adfcb6af5 100644
--- a/toonz/sources/include/ttcpip.h
+++ b/toonz/sources/include/ttcpip.h
@@ -1,8 +1,8 @@
-
-
#ifndef TTCPIP_H
#define TTCPIP_H
+#include <memory>
+
#include "tcommon.h"
#include <QString>
@@ -48,7 +48,7 @@ public:
int getExitCode() const;
private:
- TTcpIpServerImp *m_imp;
+ std::shared_ptr<TTcpIpServerImp> m_imp;
};
//---------------------------------------------------------------------
diff --git a/toonz/sources/include/ttimer.h b/toonz/sources/include/ttimer.h
index 2de2d268c..4aaa9490b 100644
--- a/toonz/sources/include/ttimer.h
+++ b/toonz/sources/include/ttimer.h
@@ -1,8 +1,8 @@
-
-
#ifndef TTIMER_INCLUDED
#define TTIMER_INCLUDED
+#include <memory>
+
#include "tcommon.h"
#undef DVAPI
@@ -98,7 +98,7 @@ public:
class Imp;
private:
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
TTimer(const TTimer &);
void operator=(const TTimer &);
diff --git a/toonz/sources/include/tundo.h b/toonz/sources/include/tundo.h
index df5801775..d0f57155d 100644
--- a/toonz/sources/include/tundo.h
+++ b/toonz/sources/include/tundo.h
@@ -1,8 +1,8 @@
-
-
#ifndef T_UNDO_INCLUDED
#define T_UNDO_INCLUDED
+#include <memory>
+
// TnzCore includes
#include "tsmartpointer.h"
@@ -103,7 +103,7 @@ public:
private:
struct TUndoManagerImp;
- TUndoManagerImp *m_imp;
+ std::unique_ptr<TUndoManagerImp> m_imp;
private:
// Noncopyable
diff --git a/toonz/sources/include/tvectorimage.h b/toonz/sources/include/tvectorimage.h
index 8fb1234e6..f80f239a6 100644
--- a/toonz/sources/include/tvectorimage.h
+++ b/toonz/sources/include/tvectorimage.h
@@ -1,8 +1,8 @@
-
-
#ifndef TVECTORIMAGE_INCLUDED
#define TVECTORIMAGE_INCLUDED
+#include <memory>
+
#include "timage.h"
// da togliere spostando cose in altri file!!
@@ -60,7 +60,7 @@ class DVAPI TVectorImage : public TImage
int pickGroup(const TPointD &pos, bool onEnteredGroup) const;
public:
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
struct IntersectionBranch {
int m_strokeIndex;
diff --git a/toonz/sources/stdfx/shadingcontext.cpp b/toonz/sources/stdfx/shadingcontext.cpp
index 2a82a5b6a..c26fe3297 100644
--- a/toonz/sources/stdfx/shadingcontext.cpp
+++ b/toonz/sources/stdfx/shadingcontext.cpp
@@ -120,7 +120,6 @@ ShadingContext::ShadingContext()
ShadingContext::~ShadingContext()
{
- delete m_imp;
}
//--------------------------------------------------------
diff --git a/toonz/sources/tnzbase/permissionsmanager.cpp b/toonz/sources/tnzbase/permissionsmanager.cpp
index 9524e0cf3..635d717c5 100644
--- a/toonz/sources/tnzbase/permissionsmanager.cpp
+++ b/toonz/sources/tnzbase/permissionsmanager.cpp
@@ -161,15 +161,14 @@ void PermissionsManager::Imp::loadPermissions()
//=========================================================
PermissionsManager::PermissionsManager()
+ : m_imp(new Imp())
{
- m_imp = new Imp();
}
//---------------------------------------------------------
PermissionsManager::~PermissionsManager()
{
- delete m_imp;
}
//---------------------------------------------------------
diff --git a/toonz/sources/tnzext/meshtexturizer.cpp b/toonz/sources/tnzext/meshtexturizer.cpp
index 2489872f7..16f85577c 100644
--- a/toonz/sources/tnzext/meshtexturizer.cpp
+++ b/toonz/sources/tnzext/meshtexturizer.cpp
@@ -212,7 +212,6 @@ MeshTexturizer::MeshTexturizer()
MeshTexturizer::~MeshTexturizer()
{
- delete m_imp;
}
//---------------------------------------------------------------------------------
diff --git a/toonz/sources/tnzext/plasticdeformer.cpp b/toonz/sources/tnzext/plasticdeformer.cpp
index 6ded943d0..6dfd6c120 100644
--- a/toonz/sources/tnzext/plasticdeformer.cpp
+++ b/toonz/sources/tnzext/plasticdeformer.cpp
@@ -887,7 +887,6 @@ PlasticDeformer::PlasticDeformer()
PlasticDeformer::~PlasticDeformer()
{
- delete m_imp;
}
//---------------------------------------------------------------------------------
diff --git a/toonz/sources/tnzext/plasticdeformerstorage.cpp b/toonz/sources/tnzext/plasticdeformerstorage.cpp
index b0262edd1..572b26690 100644
--- a/toonz/sources/tnzext/plasticdeformerstorage.cpp
+++ b/toonz/sources/tnzext/plasticdeformerstorage.cpp
@@ -445,7 +445,6 @@ PlasticDeformerStorage::PlasticDeformerStorage()
PlasticDeformerStorage::~PlasticDeformerStorage()
{
- delete m_imp;
}
//----------------------------------------------------------------------------------
diff --git a/toonz/sources/tnzext/plasticskeleton.cpp b/toonz/sources/tnzext/plasticskeleton.cpp
index 97c075bd3..1130b29e7 100644
--- a/toonz/sources/tnzext/plasticskeleton.cpp
+++ b/toonz/sources/tnzext/plasticskeleton.cpp
@@ -149,7 +149,6 @@ PlasticSkeleton::PlasticSkeleton()
PlasticSkeleton::~PlasticSkeleton()
{
- delete m_imp;
}
//------------------------------------------------------------------
diff --git a/toonz/sources/tnzext/plasticskeletondeformation.cpp b/toonz/sources/tnzext/plasticskeletondeformation.cpp
index 201d616a1..4a248a3c3 100644
--- a/toonz/sources/tnzext/plasticskeletondeformation.cpp
+++ b/toonz/sources/tnzext/plasticskeletondeformation.cpp
@@ -644,8 +644,6 @@ PlasticSkeletonDeformation::~PlasticSkeletonDeformation()
SkeletonSet::iterator st, sEnd(m_imp->m_skeletons.end());
for (st = m_imp->m_skeletons.begin(); st != sEnd; ++st)
st->get_right()->removeListener(this);
-
- delete m_imp;
}
//------------------------------------------------------------------
diff --git a/toonz/sources/toonz/moviegenerator.cpp b/toonz/sources/toonz/moviegenerator.cpp
index a73b2a922..d3ae184d6 100644
--- a/toonz/sources/toonz/moviegenerator.cpp
+++ b/toonz/sources/toonz/moviegenerator.cpp
@@ -458,12 +458,11 @@ MovieGenerator::MovieGenerator(
const TDimension &resolution,
TOutputProperties &outputProperties,
bool useMarkers)
- : m_imp(0)
{
if (path.getType() == "swf" || path.getType() == "scr")
- m_imp = new FlashMovieGenerator(path, resolution, outputProperties);
+ m_imp.reset(new FlashMovieGenerator(path, resolution, outputProperties));
else
- m_imp = new RasterMovieGenerator(path, resolution, outputProperties);
+ m_imp.reset(new RasterMovieGenerator(path, resolution, outputProperties));
m_imp->m_useMarkers = useMarkers;
}
@@ -471,7 +470,6 @@ MovieGenerator::MovieGenerator(
MovieGenerator::~MovieGenerator()
{
- delete m_imp;
}
//-------------------------------------------------------------------
@@ -508,7 +506,7 @@ bool MovieGenerator::addSoundtrack(const ToonzScene &scene, int frameOffset, int
bool MovieGenerator::addScene(ToonzScene &scene, int r0, int r1)
{
TApp *app = TApp::instance();
- RasterMovieGenerator *imp = dynamic_cast<RasterMovieGenerator *>(m_imp);
+ RasterMovieGenerator *imp = dynamic_cast<RasterMovieGenerator *>(m_imp.get());
if (imp)
imp->m_alphaEnabled = true;
m_imp->m_renderRange = std::make_pair(r0, r1);
diff --git a/toonz/sources/toonz/moviegenerator.h b/toonz/sources/toonz/moviegenerator.h
index a0666d235..84717e1f1 100644
--- a/toonz/sources/toonz/moviegenerator.h
+++ b/toonz/sources/toonz/moviegenerator.h
@@ -1,8 +1,8 @@
-
-
#ifndef MOVIEGENERATOR_INCLUDED
#define MOVIEGENERATOR_INCLUDED
+#include <memory>
+
#include "tfilepath.h"
#include "tpixel.h"
#include "tgeometry.h"
@@ -26,7 +26,7 @@ public:
class Imp;
private:
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
public:
class Listener
diff --git a/toonz/sources/toonz/previewer.cpp b/toonz/sources/toonz/previewer.cpp
index 97fbeca22..79b322034 100644
--- a/toonz/sources/toonz/previewer.cpp
+++ b/toonz/sources/toonz/previewer.cpp
@@ -1018,7 +1018,6 @@ Previewer::Previewer(bool subcamera)
Previewer::~Previewer()
{
- delete m_imp;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonz/previewer.h b/toonz/sources/toonz/previewer.h
index 3324e3470..7b20e800c 100644
--- a/toonz/sources/toonz/previewer.h
+++ b/toonz/sources/toonz/previewer.h
@@ -1,8 +1,8 @@
-
-
#ifndef PREVIEWER_INCLUDED
#define PREVIEWER_INCLUDED
+#include <memory>
+
#include "traster.h"
#include "tfx.h"
@@ -31,7 +31,7 @@ class Previewer : public QObject, public TFxObserver
Q_OBJECT
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
Previewer(bool subcamera);
~Previewer();
diff --git a/toonz/sources/toonzfarm/include/service.h b/toonz/sources/toonzfarm/include/service.h
index 2edc4dc59..5e20d3d2a 100644
--- a/toonz/sources/toonzfarm/include/service.h
+++ b/toonz/sources/toonzfarm/include/service.h
@@ -1,9 +1,7 @@
-
-
#ifndef SERVICE_H
#define SERVICE_H
-//#include "tfilepath.h"
+#include <memory>
class TFilePath;
@@ -86,7 +84,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
static TService *m_instance;
};
diff --git a/toonz/sources/toonzfarm/include/tlog.h b/toonz/sources/toonzfarm/include/tlog.h
index 2d0e3181b..a489eea88 100644
--- a/toonz/sources/toonzfarm/include/tlog.h
+++ b/toonz/sources/toonzfarm/include/tlog.h
@@ -1,8 +1,8 @@
-
-
#ifndef TSYSLOG_H
#define TSYSLOG_H
+#include <memory>
+
#include "tcommon.h"
#include <QString>
@@ -45,7 +45,7 @@ public:
private:
class Imp;
- Imp *m_imp;
+ std::unique_ptr<Imp> m_imp;
};
#endif
diff --git a/toonz/sources/toonzfarm/tfarm/service.cpp b/toonz/sources/toonzfarm/tfarm/service.cpp
index 84403acc5..7fcc4eb94 100644
--- a/toonz/sources/toonzfarm/tfarm/service.cpp
+++ b/toonz/sources/toonzfarm/tfarm/service.cpp
@@ -123,7 +123,6 @@ TService::TService(const string &name, const string &displayName)
TService::~TService()
{
- delete m_imp;
}
//------------------------------------------------------------------------------
diff --git a/toonz/sources/toonzfarm/tfarm/tfarmserverstub.cpp b/toonz/sources/toonzfarm/tfarm/tfarmserverstub.cpp
index b59700251..527f83a11 100644
--- a/toonz/sources/toonzfarm/tfarm/tfarmserverstub.cpp
+++ b/toonz/sources/toonzfarm/tfarm/tfarmserverstub.cpp
@@ -106,7 +106,6 @@ TFarmServerStub::TFarmServerStub(TFarmServer *farmServer, int port)
TFarmServerStub::~TFarmServerStub()
{
- delete m_imp;
}
//------------------------------------------------------------------------------
diff --git a/toonz/sources/toonzfarm/tfarm/tfarmtask.cpp b/toonz/sources/toonzfarm/tfarm/tfarmtask.cpp
index bf79bb861..f91e492a4 100644
--- a/toonz/sources/toonzfarm/tfarm/tfarmtask.cpp
+++ b/toonz/sources/toonzfarm/tfarm/tfarmtask.cpp
@@ -697,7 +697,6 @@ TFarmTaskGroup::TFarmTaskGroup(const TFarmTaskGroup &src)
TFarmTaskGroup::~TFarmTaskGroup()
{
- delete m_imp;
}
//------------------------------------------------------------------------------
diff --git a/toonz/sources/toonzfarm/tfarm/tlog.cpp b/toonz/sources/toonzfarm/tfarm/tlog.cpp
index 23309bdc8..1c7457c2b 100644
--- a/toonz/sources/toonzfarm/tfarm/tlog.cpp
+++ b/toonz/sources/toonzfarm/tfarm/tlog.cpp
@@ -201,7 +201,6 @@ TUserLog::TUserLog(const TFilePath &fp) : m_imp(new Imp(fp))
TUserLog::~TUserLog()
{
- delete m_imp;
}
//------------------------------------------------------------------------------
diff --git a/toonz/sources/toonzfarm/tfarm/ttcpipserver.cpp b/toonz/sources/toonzfarm/tfarm/ttcpipserver.cpp
index b7f7cb76a..8b200ce38 100644
--- a/toonz/sources/toonzfarm/tfarm/ttcpipserver.cpp
+++ b/toonz/sources/toonzfarm/tfarm/ttcpipserver.cpp
@@ -268,7 +268,6 @@ TTcpIpServer::~TTcpIpServer()
std::cout << "closing socket" << std::endl;
close(m_imp->m_s);
#endif
- delete m_imp;
}
//---------------------------------------------------------------------
@@ -290,14 +289,13 @@ static void shutdown_cb(int)
class DataReader : public TThread::Runnable
{
public:
- DataReader(int clientSocket, TTcpIpServer *server, TTcpIpServerImp *serverImp)
- : m_clientSocket(clientSocket), m_server(server), m_serverImp(serverImp) {}
+ DataReader(int clientSocket, std::shared_ptr<TTcpIpServerImp> serverImp)
+ : m_clientSocket(clientSocket), m_serverImp(std::move(serverImp)) {}
void run();
int m_clientSocket;
- TTcpIpServer *m_server;
- TTcpIpServerImp *m_serverImp;
+ std::shared_ptr<TTcpIpServerImp> m_serverImp;
};
void DataReader::run()
@@ -322,15 +320,14 @@ void DataReader::run()
class DataReceiver : public TThread::Runnable
{
public:
- DataReceiver(int clientSocket, const QString &data, TTcpIpServer *server, TTcpIpServerImp *serverImp)
- : m_clientSocket(clientSocket), m_data(data), m_server(server), m_serverImp(serverImp) {}
+ DataReceiver(int clientSocket, const QString &data, std::shared_ptr<TTcpIpServerImp> serverImp)
+ : m_clientSocket(clientSocket), m_data(data), m_serverImp(std::move(serverImp)) {}
void run();
int m_clientSocket;
QString m_data;
- TTcpIpServer *m_server;
- TTcpIpServerImp *m_serverImp;
+ std::shared_ptr<TTcpIpServerImp> m_serverImp;
};
//---------------------------------------------------------------------
@@ -374,7 +371,7 @@ void TTcpIpServer::run()
} else {
// creo un nuovo thread per la gestione dei dati ricevuti
TThread::Executor executor;
- executor.addTask(new DataReceiver(t, data, this, m_imp));
+ executor.addTask(new DataReceiver(t, data, m_imp));
}
} else {
::shutdown(t, 1);
@@ -413,7 +410,7 @@ void TTcpIpServer::run()
}
TThread::Executor executor;
- executor.addTask(new DataReader(t, this, m_imp));
+ executor.addTask(new DataReader(t, m_imp));
}
} else {
m_exitCode = err;
diff --git a/toonz/sources/toonzlib/autoclose.cpp b/toonz/sources/toonzlib/autoclose.cpp
index 1443b632e..a5289fb12 100644
--- a/toonz/sources/toonzlib/autoclose.cpp
+++ b/toonz/sources/toonzlib/autoclose.cpp
@@ -1144,8 +1144,8 @@ return 0;
/*=============================================================================*/
TAutocloser::TAutocloser(const TRasterP &r, int distance, double angle, int index, int opacity)
+ : m_imp(new Imp(r, distance, angle, index, opacity))
{
- m_imp = new Imp(r, distance, angle, index, opacity);
}
//...............................
@@ -1161,7 +1161,6 @@ void TAutocloser::exec()
TAutocloser::~TAutocloser()
{
- delete m_imp;
}
//-------------------------------------------------
diff --git a/toonz/sources/toonzlib/imagemanager.cpp b/toonz/sources/toonzlib/imagemanager.cpp
index 8c31abb45..a5bdbc403 100644
--- a/toonz/sources/toonzlib/imagemanager.cpp
+++ b/toonz/sources/toonzlib/imagemanager.cpp
@@ -181,7 +181,6 @@ ImageManager::ImageManager()
ImageManager::~ImageManager()
{
- delete m_imp;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonzlib/scriptbinding_renderer.cpp b/toonz/sources/toonzlib/scriptbinding_renderer.cpp
index d361a5887..056d2319a 100644
--- a/toonz/sources/toonzlib/scriptbinding_renderer.cpp
+++ b/toonz/sources/toonzlib/scriptbinding_renderer.cpp
@@ -212,8 +212,6 @@ Renderer::Renderer()
Renderer::~Renderer()
{
- delete m_imp;
- m_imp = 0;
}
QScriptValue Renderer::ctor(QScriptContext *context, QScriptEngine *engine)
diff --git a/toonz/sources/toonzlib/tlog.cpp b/toonz/sources/toonzlib/tlog.cpp
index 185653661..47566319e 100644
--- a/toonz/sources/toonzlib/tlog.cpp
+++ b/toonz/sources/toonzlib/tlog.cpp
@@ -210,7 +210,6 @@ TUserLogAppend::TUserLogAppend(const TFilePath &fp) : m_imp(new Imp(fp))
TUserLogAppend::~TUserLogAppend()
{
- //delete m_imp;
}
//------------------------------------------------------------------------------
diff --git a/toonz/sources/toonzlib/tstageobjecttree.cpp b/toonz/sources/toonzlib/tstageobjecttree.cpp
index dc74a87b7..a67bb202e 100644
--- a/toonz/sources/toonzlib/tstageobjecttree.cpp
+++ b/toonz/sources/toonzlib/tstageobjecttree.cpp
@@ -103,8 +103,6 @@ TStageObjectTree::TStageObjectTree() : m_imp(new TStageObjectTreeImp)
TStageObjectTree::~TStageObjectTree()
{
- delete m_imp;
- m_imp = 0;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonzlib/txsheet.cpp b/toonz/sources/toonzlib/txsheet.cpp
index 966f795ac..afb869241 100644
--- a/toonz/sources/toonzlib/txsheet.cpp
+++ b/toonz/sources/toonzlib/txsheet.cpp
@@ -165,7 +165,10 @@ TXsheet::TXsheetImp::~TXsheetImp()
// TXsheet
TXsheet::TXsheet()
- : TSmartObject(m_classCode), m_player(0), m_imp(new TXsheet::TXsheetImp), m_notes(new TXshNoteSet())
+ : TSmartObject(m_classCode)
+ , m_player(0)
+ , m_imp(new TXsheet::TXsheetImp)
+ , m_notes(new TXshNoteSet())
{
//extern TSyntax::Grammar *createXsheetGrammar(TXsheet*);
m_soundProperties = new TXsheet::SoundProperties();
@@ -181,7 +184,6 @@ TXsheet::~TXsheet()
texture_utils::invalidateTextures(this);
assert(m_imp);
- delete m_imp;
if (m_notes)
delete m_notes;
if (m_soundProperties)
diff --git a/toonz/sources/toonzqt/infoviewer.cpp b/toonz/sources/toonzqt/infoviewer.cpp
index 62a4534b1..6eaf52982 100644
--- a/toonz/sources/toonzqt/infoviewer.cpp
+++ b/toonz/sources/toonzqt/infoviewer.cpp
@@ -116,13 +116,13 @@ public slots:
InfoViewer::InfoViewer(QWidget *parent)
: Dialog()
+ , m_imp(new InfoViewerImp())
{
setWindowTitle(tr("File Info"));
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
//setAttribute(Qt::WA_DeleteOnClose);
m_parent = parent;
- m_imp = new InfoViewerImp();
int i;
for (i = 0; i < (int)m_imp->m_labels.size(); i++) {
@@ -143,7 +143,6 @@ InfoViewer::InfoViewer(QWidget *parent)
InfoViewer::~InfoViewer()
{
- delete m_imp;
}
//----------------------------------------------------------------