Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unique_ptr instead of auto_ptr #601

Merged
merged 1 commit into from Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 13 additions & 11 deletions toonz/sources/common/expressions/tgrammar.cpp
Expand Up @@ -125,7 +125,7 @@ class Op0Node final : public CalculatorNode {
template <class Op>
class Op1Node final : public CalculatorNode {
protected:
std::auto_ptr<CalculatorNode> m_a;
std::unique_ptr<CalculatorNode> m_a;

public:
Op1Node(Calculator *calc, CalculatorNode *a) : CalculatorNode(calc), m_a(a) {}
Expand All @@ -143,7 +143,7 @@ class Op1Node final : public CalculatorNode {
template <class Op>
class Op2Node final : public CalculatorNode {
protected:
std::auto_ptr<CalculatorNode> m_a, m_b;
std::unique_ptr<CalculatorNode> m_a, m_b;

public:
Op2Node(Calculator *calc, CalculatorNode *a, CalculatorNode *b)
Expand All @@ -164,7 +164,7 @@ class Op2Node final : public CalculatorNode {
template <class Op>
class Op3Node final : public CalculatorNode {
protected:
std::auto_ptr<CalculatorNode> m_a, m_b, m_c;
std::unique_ptr<CalculatorNode> m_a, m_b, m_c;

public:
Op3Node(Calculator *calc, CalculatorNode *a, CalculatorNode *b,
Expand All @@ -184,7 +184,7 @@ class Op3Node final : public CalculatorNode {
//-------------------------------------------------------------------

class ChsNode final : public CalculatorNode {
std::auto_ptr<CalculatorNode> m_a;
std::unique_ptr<CalculatorNode> m_a;

public:
ChsNode(Calculator *calc, CalculatorNode *a) : CalculatorNode(calc), m_a(a) {}
Expand All @@ -196,7 +196,7 @@ class ChsNode final : public CalculatorNode {
//-------------------------------------------------------------------

class QuestionNode final : public CalculatorNode {
std::auto_ptr<CalculatorNode> m_a, m_b, m_c;
std::unique_ptr<CalculatorNode> m_a, m_b, m_c;

public:
QuestionNode(Calculator *calc, CalculatorNode *a, CalculatorNode *b,
Expand All @@ -215,7 +215,7 @@ class QuestionNode final : public CalculatorNode {
//-------------------------------------------------------------------

class NotNode final : public CalculatorNode {
std::auto_ptr<CalculatorNode> m_a;
std::unique_ptr<CalculatorNode> m_a;

public:
NotNode(Calculator *calc, CalculatorNode *a) : CalculatorNode(calc), m_a(a) {}
Expand All @@ -228,7 +228,7 @@ class NotNode final : public CalculatorNode {
//-------------------------------------------------------------------

class CycleNode final : public CalculatorNode {
std::auto_ptr<CalculatorNode> m_a;
std::unique_ptr<CalculatorNode> m_a;

public:
CycleNode(Calculator *calc, CalculatorNode *a)
Expand Down Expand Up @@ -268,13 +268,15 @@ class CycleNode final : public CalculatorNode {
//-------------------------------------------------------------------

class RandomNode final : public CalculatorNode {
std::auto_ptr<CalculatorNode> m_seed, m_min, m_max, m_arg;
std::unique_ptr<CalculatorNode> m_seed, m_min, m_max, m_arg;

public:
RandomNode(Calculator *calc)
: CalculatorNode(calc), m_seed(0), m_min(0), m_max(0) {
m_arg.reset(new VariableNode(calc, CalculatorNode::FRAME));
}
: CalculatorNode(calc)
, m_seed()
, m_min()
, m_max()
, m_arg(new VariableNode(calc, CalculatorNode::FRAME)) {}

void setSeed(CalculatorNode *arg) {
assert(m_seed.get() == 0);
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/common/tstream/tpersistset.cpp
Expand Up @@ -26,7 +26,7 @@ TPersistSet::~TPersistSet() {

//------------------------------------------------------------------

void TPersistSet::insert(std::auto_ptr<TPersist> object) {
void TPersistSet::insert(std::unique_ptr<TPersist> object) {
struct locals {
inline static bool sameType(TPersist *a, TPersist *b) {
return (typeid(*a) == typeid(*b));
Expand Down
4 changes: 2 additions & 2 deletions toonz/sources/common/tstream/tstream.cpp
Expand Up @@ -225,7 +225,7 @@ TOStream::TOStream(const TFilePath &fp, bool compressed) : m_imp(new Imp) {
m_imp->m_compressed = true;
m_imp->m_chanOwner = false;
} else {
std::auto_ptr<Tofstream> os(new Tofstream(fp));
std::unique_ptr<Tofstream> os(new Tofstream(fp));
m_imp->m_os = os->isOpen() ? os.release() : 0;
m_imp->m_chanOwner = true;
}
Expand Down Expand Up @@ -818,7 +818,7 @@ TIStream::TIStream(const TFilePath &fp) : m_imp(new Imp) {
{
bool swapForEndianess = false;

auto_ptr<std::istream> is(m_imp->m_is);
unique_ptr<std::istream> is(m_imp->m_is);
m_imp->m_is = 0;

char magicBuffer[4];
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/common/tvectorimage/tvectorimage.cpp
Expand Up @@ -629,7 +629,7 @@ TRaster32P TVectorImage::render(bool onlyStrokes) {
TRect bBox = convert(getBBox());
if (bBox.isEmpty()) return (TRaster32P)0;

std::auto_ptr<TOfflineGL> offlineGlContext(new TOfflineGL(bBox.getSize()));
std::unique_ptr<TOfflineGL> offlineGlContext(new TOfflineGL(bBox.getSize()));
offlineGlContext->clear(TPixel32(0, 0, 0, 0));
offlineGlContext->makeCurrent();
TVectorRenderData rd(TTranslation(-convert(bBox.getP00())),
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/common/tvrender/tpalette.cpp
Expand Up @@ -261,7 +261,7 @@ int TPalette::addStyle(const TPixel32 &color) {
//-------------------------------------------------------------------

void TPalette::setStyle(int styleId, TColorStyle *style) {
std::auto_ptr<TColorStyle> styleOwner(style);
std::unique_ptr<TColorStyle> styleOwner(style);

int styleCount = getStyleCount();

Expand Down
4 changes: 3 additions & 1 deletion toonz/sources/common/twain/twain.h
Expand Up @@ -1484,16 +1484,18 @@ typedef struct {

/* misplaced */
#define DAT_ICCPROFILE \
0x0401 /* TW_MEMORY Added 1.91 This Data Argument is misplaced but \ \ \
0x0401 /* TW_MEMORY Added 1.91 This Data Argument is misplaced but \ \ \ \
belongs to the DG_IMAGE Data Group */
#define DAT_IMAGEMEMFILEXFER \
0x0402 /* TW_IMAGEMEMXFER Added 1.91 This Data Argument is misplaced but \
\ \
\ \ \
\ \ \ \
belongs to the DG_IMAGE Data Group */
#define DAT_ENTRYPOINT \
0x0403 /* TW_ENTRYPOINT Added 2.0 This Data Argument is misplaced but \ \
\ \
\ \ \
belongs to the DG_CONTROL Data Group */

/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/image/mesh/tiio_mesh.h
Expand Up @@ -49,4 +49,4 @@ class TLevelReaderMesh final : public TLevelReader {
TLevelReaderMesh &operator=(const TLevelReaderMesh &);
};

#endif /* TIIO_MESH_H */
#endif /* TIIO_MESH_H */
31 changes: 13 additions & 18 deletions toonz/sources/image/png/tiio_png.cpp
Expand Up @@ -37,33 +37,28 @@ void tnz_error_fun(png_structp pngPtr, png_const_charp error_message) {
#if defined(PNG_LIBPNG_VER)
#if (PNG_LIBPNG_VER < 10527)
extern "C" {
static png_uint_32 png_get_current_row_number(const png_structp png_ptr)
{
/* See the comments in png.h - this is the sub-image row when reading and
* interlaced image.
*/
if (png_ptr != NULL)
return png_ptr->row_number;
static png_uint_32 png_get_current_row_number(const png_structp png_ptr) {
/* See the comments in png.h - this is the sub-image row when reading and
* interlaced image.
*/
if (png_ptr != NULL) return png_ptr->row_number;

return PNG_UINT_32_MAX; /* help the app not to fail silently */
return PNG_UINT_32_MAX; /* help the app not to fail silently */
}

static png_byte png_get_current_pass_number(const png_structp png_ptr)
{
if (png_ptr != NULL)
return png_ptr->pass;
return 8; /* invalid */
static png_byte png_get_current_pass_number(const png_structp png_ptr) {
if (png_ptr != NULL) return png_ptr->pass;
return 8; /* invalid */
}
}
#endif
#else
#error "PNG_LIBPNG_VER undefined, libpng too old?"
#endif

//=========================================================
//=========================================================

inline USHORT
mySwap(USHORT val) {
inline USHORT mySwap(USHORT val) {
#if TNZ_LITTLE_ENDIAN
return ((val) |
((val & 0xff) << 8)); //((val>>8)|((val&0xff)<<8)); (vecchio codice)
Expand Down Expand Up @@ -141,8 +136,8 @@ class PngReader final : public Tiio::Reader {
#if (PNG_LIBPNG_VER >= 10527)
png_set_longjmp_fn(m_png_ptr, tnz_abort,
sizeof(jmp_buf)); /* ignore all fatal errors */
#endif // (PNG_LIBPNG_VER >= 10527)
#endif // defined(PNG_LIBPNG_VER)
#endif // (PNG_LIBPNG_VER >= 10527)
#endif // defined(PNG_LIBPNG_VER)

m_canDelete = 1;
m_info_ptr = png_create_info_struct(m_png_ptr);
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/include/tpersistset.h
Expand Up @@ -37,7 +37,7 @@ class DVAPI TPersistSet final : public TPersist {
return m_objects;
} //!< Returns the stored objects list

void insert(std::auto_ptr<TPersist>
void insert(std::unique_ptr<TPersist>
object); //!< Overwrites an object type instance with
//! the supplied one.
public:
Expand Down
8 changes: 4 additions & 4 deletions toonz/sources/stdfx/shadingcontext.cpp
Expand Up @@ -27,9 +27,9 @@

namespace {

typedef std::auto_ptr<QGLPixelBuffer> QGLPixelBufferP;
typedef std::auto_ptr<QGLFramebufferObject> QGLFramebufferObjectP;
typedef std::auto_ptr<QGLShaderProgram> QGLShaderProgramP;
typedef std::unique_ptr<QGLPixelBuffer> QGLPixelBufferP;
typedef std::unique_ptr<QGLFramebufferObject> QGLFramebufferObjectP;
typedef std::unique_ptr<QGLShaderProgram> QGLShaderProgramP;

struct CompiledShader {
QGLShaderProgramP m_program;
Expand All @@ -53,7 +53,7 @@ struct ShadingContext::Imp {
std::map<QString,
CompiledShader>
m_shaderPrograms; //!< Shader Programs stored in the context.
//! \warning Values have \p auto_ptr members.
//! \warning Values have \p unique_ptr members.
public:
Imp();

Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/tcomposer/tcomposer.cpp
Expand Up @@ -565,7 +565,7 @@ int main(int argc, char *argv[]) {

// Create a QObject destroyed just before app - see Tnz6's main.cpp for
// rationale
std::auto_ptr<QObject> mainScope(new QObject(&app));
std::unique_ptr<QObject> mainScope(new QObject(&app));
mainScope->setObjectName("mainScope");

#ifdef _WIN32
Expand Down
4 changes: 2 additions & 2 deletions toonz/sources/tnztools/imagegrouping.cpp
Expand Up @@ -76,7 +76,7 @@ void ungroupWithoutUndo(TVectorImage *vimg, StrokeSelection *selection) {
//-----------------------------------------------------------------------------

class GroupUndo final : public ToolUtils::TToolUndo {
std::auto_ptr<StrokeSelection> m_selection;
std::unique_ptr<StrokeSelection> m_selection;

public:
GroupUndo(TXshSimpleLevel *level, const TFrameId &frameId,
Expand All @@ -103,7 +103,7 @@ class GroupUndo final : public ToolUtils::TToolUndo {
//-----------------------------------------------------------------------------

class UngroupUndo final : public ToolUtils::TToolUndo {
std::auto_ptr<StrokeSelection> m_selection;
std::unique_ptr<StrokeSelection> m_selection;

public:
UngroupUndo(TXshSimpleLevel *level, const TFrameId &frameId,
Expand Down
6 changes: 3 additions & 3 deletions toonz/sources/tnztools/plastictool.h
Expand Up @@ -160,8 +160,8 @@ class PlasticTool final : public QObject,

// Editing-related vars

std::auto_ptr<tcg::polymorphic> m_rigidityPainter; //!< Delegate class to
//! deal with (undoable)
std::unique_ptr<tcg::polymorphic> m_rigidityPainter; //!< Delegate class to
//! deal with (undoable)
//! rigidity painting
bool m_showSkeletonOS; //!< Whether onion-skinned skeletons must be shown

Expand Down Expand Up @@ -352,7 +352,7 @@ public slots:
void setGlobalRestKey();

// Rigidity methods
static std::auto_ptr<tcg::polymorphic> createRigidityPainter();
static std::unique_ptr<tcg::polymorphic> createRigidityPainter();

// Drawing methods

Expand Down
8 changes: 4 additions & 4 deletions toonz/sources/tnztools/plastictool_meshedit.cpp
Expand Up @@ -1188,7 +1188,7 @@ void PlasticTool::swapEdge_mesh_undo() {
}

// Perform operation
std::auto_ptr<TUndo> undo(new SwapEdgeUndo(m_meSel.objects().front()));
std::unique_ptr<TUndo> undo(new SwapEdgeUndo(m_meSel.objects().front()));
undo->redo();

TUndoManager::manager()->add(undo.release());
Expand All @@ -1208,7 +1208,7 @@ void PlasticTool::collapseEdge_mesh_undo() {
}

// Perform operation
std::auto_ptr<TUndo> undo(new CollapseEdgeUndo(m_meSel.objects().front()));
std::unique_ptr<TUndo> undo(new CollapseEdgeUndo(m_meSel.objects().front()));
undo->redo();

TUndoManager::manager()->add(undo.release());
Expand All @@ -1219,7 +1219,7 @@ void PlasticTool::collapseEdge_mesh_undo() {
void PlasticTool::splitEdge_mesh_undo() {
if (!(m_mi && m_meSel.hasSingleObject())) return;

std::auto_ptr<TUndo> undo(new SplitEdgeUndo(m_meSel.objects().front()));
std::unique_ptr<TUndo> undo(new SplitEdgeUndo(m_meSel.objects().front()));
undo->redo();

TUndoManager::manager()->add(undo.release());
Expand All @@ -1230,7 +1230,7 @@ void PlasticTool::splitEdge_mesh_undo() {
void PlasticTool::cutEdges_mesh_undo() {
if (!m_mi) return;

std::auto_ptr<CutEdgesUndo> undo(new CutEdgesUndo(m_meSel.objects()));
std::unique_ptr<CutEdgesUndo> undo(new CutEdgesUndo(m_meSel.objects()));

if (undo->do_()) TUndoManager::manager()->add(undo.release());
}
Expand Down
4 changes: 2 additions & 2 deletions toonz/sources/tnztools/plastictool_rigidity.cpp
Expand Up @@ -186,8 +186,8 @@ void RigidityPainter::commit() {
// PlasticTool functions
//****************************************************************************************

std::auto_ptr<tcg::polymorphic> PlasticTool::createRigidityPainter() {
return std::auto_ptr<tcg::polymorphic>(new RigidityPainter);
std::unique_ptr<tcg::polymorphic> PlasticTool::createRigidityPainter() {
return std::unique_ptr<tcg::polymorphic>(new RigidityPainter);
}

//------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/tnztools/strokeselection.cpp
Expand Up @@ -118,7 +118,7 @@ bool pasteStrokesWithoutUndo(TVectorImageP image, std::set<int> &outIndexes,
scene->getProperties()->getVectorizerParameters();
assert(vParams);

std::auto_ptr<VectorizerConfiguration> config(
std::unique_ptr<VectorizerConfiguration> config(
vParams->getCurrentConfiguration(0.0));
vectorizeToonzImageData(image, tiData, indexes, image->getPalette(),
*config);
Expand Down
5 changes: 2 additions & 3 deletions toonz/sources/tnztools/toolutils.cpp
Expand Up @@ -1066,10 +1066,9 @@ void ToolUtils::UndoPencil::undo() const {
VIStroke *stroke = image->getStrokeById(m_strokeId);
if (!stroke) return;
image->deleteStroke(stroke);
TSelection *selection = app->getCurrentSelection()->getSelection();
TSelection *selection = app->getCurrentSelection()->getSelection();
StrokeSelection *strokeSelection = dynamic_cast<StrokeSelection *>(selection);
if (strokeSelection)
strokeSelection->selectNone();
if (strokeSelection) strokeSelection->selectNone();

UINT size = m_fillInformation->size();
TRegion *reg;
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/toonz/adjustthicknesspopup.cpp
Expand Up @@ -1092,7 +1092,7 @@ void AdjustThicknessPopup::apply() {
double fromTransform[2], toTransform[2];
getTransformParameters(fromTransform, toTransform);

std::auto_ptr<TUndo> undo(
std::unique_ptr<TUndo> undo(
new AdjustThicknessUndo(m_selectionData, fromTransform, toTransform));

undo->redo();
Expand Down