From 2a7129aa92a1e5158beaf46e8ffa34edb3403465 Mon Sep 17 00:00:00 2001 From: Shinya Kitaoka Date: Jul 20 2016 12:49:32 +0000 Subject: use std::unique_ptr<> instead of std::auto_ptr<> (#601) --- diff --git a/toonz/sources/common/expressions/tgrammar.cpp b/toonz/sources/common/expressions/tgrammar.cpp index da99a20..818e201 100644 --- a/toonz/sources/common/expressions/tgrammar.cpp +++ b/toonz/sources/common/expressions/tgrammar.cpp @@ -125,7 +125,7 @@ public: template class Op1Node final : public CalculatorNode { protected: - std::auto_ptr m_a; + std::unique_ptr m_a; public: Op1Node(Calculator *calc, CalculatorNode *a) : CalculatorNode(calc), m_a(a) {} @@ -143,7 +143,7 @@ public: template class Op2Node final : public CalculatorNode { protected: - std::auto_ptr m_a, m_b; + std::unique_ptr m_a, m_b; public: Op2Node(Calculator *calc, CalculatorNode *a, CalculatorNode *b) @@ -164,7 +164,7 @@ public: template class Op3Node final : public CalculatorNode { protected: - std::auto_ptr m_a, m_b, m_c; + std::unique_ptr m_a, m_b, m_c; public: Op3Node(Calculator *calc, CalculatorNode *a, CalculatorNode *b, @@ -184,7 +184,7 @@ public: //------------------------------------------------------------------- class ChsNode final : public CalculatorNode { - std::auto_ptr m_a; + std::unique_ptr m_a; public: ChsNode(Calculator *calc, CalculatorNode *a) : CalculatorNode(calc), m_a(a) {} @@ -196,7 +196,7 @@ public: //------------------------------------------------------------------- class QuestionNode final : public CalculatorNode { - std::auto_ptr m_a, m_b, m_c; + std::unique_ptr m_a, m_b, m_c; public: QuestionNode(Calculator *calc, CalculatorNode *a, CalculatorNode *b, @@ -215,7 +215,7 @@ public: //------------------------------------------------------------------- class NotNode final : public CalculatorNode { - std::auto_ptr m_a; + std::unique_ptr m_a; public: NotNode(Calculator *calc, CalculatorNode *a) : CalculatorNode(calc), m_a(a) {} @@ -228,7 +228,7 @@ public: //------------------------------------------------------------------- class CycleNode final : public CalculatorNode { - std::auto_ptr m_a; + std::unique_ptr m_a; public: CycleNode(Calculator *calc, CalculatorNode *a) @@ -268,13 +268,15 @@ public: //------------------------------------------------------------------- class RandomNode final : public CalculatorNode { - std::auto_ptr m_seed, m_min, m_max, m_arg; + std::unique_ptr 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); diff --git a/toonz/sources/common/tstream/tpersistset.cpp b/toonz/sources/common/tstream/tpersistset.cpp index 9dd97db..dde3aea 100644 --- a/toonz/sources/common/tstream/tpersistset.cpp +++ b/toonz/sources/common/tstream/tpersistset.cpp @@ -26,7 +26,7 @@ TPersistSet::~TPersistSet() { //------------------------------------------------------------------ -void TPersistSet::insert(std::auto_ptr object) { +void TPersistSet::insert(std::unique_ptr object) { struct locals { inline static bool sameType(TPersist *a, TPersist *b) { return (typeid(*a) == typeid(*b)); diff --git a/toonz/sources/common/tstream/tstream.cpp b/toonz/sources/common/tstream/tstream.cpp index 7b4ab80..7540dad 100644 --- a/toonz/sources/common/tstream/tstream.cpp +++ b/toonz/sources/common/tstream/tstream.cpp @@ -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 os(new Tofstream(fp)); + std::unique_ptr os(new Tofstream(fp)); m_imp->m_os = os->isOpen() ? os.release() : 0; m_imp->m_chanOwner = true; } @@ -818,7 +818,7 @@ TIStream::TIStream(const TFilePath &fp) : m_imp(new Imp) { { bool swapForEndianess = false; - auto_ptr is(m_imp->m_is); + unique_ptr is(m_imp->m_is); m_imp->m_is = 0; char magicBuffer[4]; diff --git a/toonz/sources/common/tvectorimage/tvectorimage.cpp b/toonz/sources/common/tvectorimage/tvectorimage.cpp index aec0074..bc14fa1 100644 --- a/toonz/sources/common/tvectorimage/tvectorimage.cpp +++ b/toonz/sources/common/tvectorimage/tvectorimage.cpp @@ -629,7 +629,7 @@ TRaster32P TVectorImage::render(bool onlyStrokes) { TRect bBox = convert(getBBox()); if (bBox.isEmpty()) return (TRaster32P)0; - std::auto_ptr offlineGlContext(new TOfflineGL(bBox.getSize())); + std::unique_ptr offlineGlContext(new TOfflineGL(bBox.getSize())); offlineGlContext->clear(TPixel32(0, 0, 0, 0)); offlineGlContext->makeCurrent(); TVectorRenderData rd(TTranslation(-convert(bBox.getP00())), diff --git a/toonz/sources/common/tvrender/tpalette.cpp b/toonz/sources/common/tvrender/tpalette.cpp index 16a6a70..e301908 100644 --- a/toonz/sources/common/tvrender/tpalette.cpp +++ b/toonz/sources/common/tvrender/tpalette.cpp @@ -261,7 +261,7 @@ int TPalette::addStyle(const TPixel32 &color) { //------------------------------------------------------------------- void TPalette::setStyle(int styleId, TColorStyle *style) { - std::auto_ptr styleOwner(style); + std::unique_ptr styleOwner(style); int styleCount = getStyleCount(); diff --git a/toonz/sources/common/twain/twain.h b/toonz/sources/common/twain/twain.h index 4ffd804..b2c712c 100644 --- a/toonz/sources/common/twain/twain.h +++ b/toonz/sources/common/twain/twain.h @@ -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 */ /**************************************************************************** diff --git a/toonz/sources/image/mesh/tiio_mesh.h b/toonz/sources/image/mesh/tiio_mesh.h index f49cae0..f515232 100644 --- a/toonz/sources/image/mesh/tiio_mesh.h +++ b/toonz/sources/image/mesh/tiio_mesh.h @@ -49,4 +49,4 @@ private: TLevelReaderMesh &operator=(const TLevelReaderMesh &); }; -#endif /* TIIO_MESH_H */ +#endif /* TIIO_MESH_H */ diff --git a/toonz/sources/image/png/tiio_png.cpp b/toonz/sources/image/png/tiio_png.cpp index 674b489..f330f8c 100644 --- a/toonz/sources/image/png/tiio_png.cpp +++ b/toonz/sources/image/png/tiio_png.cpp @@ -37,22 +37,18 @@ 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 @@ -60,10 +56,9 @@ static png_byte png_get_current_pass_number(const png_structp png_ptr) #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) @@ -141,8 +136,8 @@ public: #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); diff --git a/toonz/sources/include/tpersistset.h b/toonz/sources/include/tpersistset.h index b787905..e72ad0c 100644 --- a/toonz/sources/include/tpersistset.h +++ b/toonz/sources/include/tpersistset.h @@ -37,7 +37,7 @@ public: return m_objects; } //!< Returns the stored objects list - void insert(std::auto_ptr + void insert(std::unique_ptr object); //!< Overwrites an object type instance with //! the supplied one. public: diff --git a/toonz/sources/stdfx/shadingcontext.cpp b/toonz/sources/stdfx/shadingcontext.cpp index fa00ba1..75a68bd 100644 --- a/toonz/sources/stdfx/shadingcontext.cpp +++ b/toonz/sources/stdfx/shadingcontext.cpp @@ -27,9 +27,9 @@ namespace { -typedef std::auto_ptr QGLPixelBufferP; -typedef std::auto_ptr QGLFramebufferObjectP; -typedef std::auto_ptr QGLShaderProgramP; +typedef std::unique_ptr QGLPixelBufferP; +typedef std::unique_ptr QGLFramebufferObjectP; +typedef std::unique_ptr QGLShaderProgramP; struct CompiledShader { QGLShaderProgramP m_program; @@ -53,7 +53,7 @@ struct ShadingContext::Imp { std::map m_shaderPrograms; //!< Shader Programs stored in the context. - //! \warning Values have \p auto_ptr members. + //! \warning Values have \p unique_ptr members. public: Imp(); diff --git a/toonz/sources/tcomposer/tcomposer.cpp b/toonz/sources/tcomposer/tcomposer.cpp index 5d777ba..a3d06df 100644 --- a/toonz/sources/tcomposer/tcomposer.cpp +++ b/toonz/sources/tcomposer/tcomposer.cpp @@ -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 mainScope(new QObject(&app)); + std::unique_ptr mainScope(new QObject(&app)); mainScope->setObjectName("mainScope"); #ifdef _WIN32 diff --git a/toonz/sources/tnztools/imagegrouping.cpp b/toonz/sources/tnztools/imagegrouping.cpp index 0aa69ef..9176a2c 100644 --- a/toonz/sources/tnztools/imagegrouping.cpp +++ b/toonz/sources/tnztools/imagegrouping.cpp @@ -76,7 +76,7 @@ void ungroupWithoutUndo(TVectorImage *vimg, StrokeSelection *selection) { //----------------------------------------------------------------------------- class GroupUndo final : public ToolUtils::TToolUndo { - std::auto_ptr m_selection; + std::unique_ptr m_selection; public: GroupUndo(TXshSimpleLevel *level, const TFrameId &frameId, @@ -103,7 +103,7 @@ public: //----------------------------------------------------------------------------- class UngroupUndo final : public ToolUtils::TToolUndo { - std::auto_ptr m_selection; + std::unique_ptr m_selection; public: UngroupUndo(TXshSimpleLevel *level, const TFrameId &frameId, diff --git a/toonz/sources/tnztools/plastictool.h b/toonz/sources/tnztools/plastictool.h index 721db5e..0b5b807 100644 --- a/toonz/sources/tnztools/plastictool.h +++ b/toonz/sources/tnztools/plastictool.h @@ -160,8 +160,8 @@ private: // Editing-related vars - std::auto_ptr m_rigidityPainter; //!< Delegate class to - //! deal with (undoable) + std::unique_ptr m_rigidityPainter; //!< Delegate class to + //! deal with (undoable) //! rigidity painting bool m_showSkeletonOS; //!< Whether onion-skinned skeletons must be shown @@ -352,7 +352,7 @@ private: void setGlobalRestKey(); // Rigidity methods - static std::auto_ptr createRigidityPainter(); + static std::unique_ptr createRigidityPainter(); // Drawing methods diff --git a/toonz/sources/tnztools/plastictool_meshedit.cpp b/toonz/sources/tnztools/plastictool_meshedit.cpp index 2cd70e4..f523131 100644 --- a/toonz/sources/tnztools/plastictool_meshedit.cpp +++ b/toonz/sources/tnztools/plastictool_meshedit.cpp @@ -1188,7 +1188,7 @@ void PlasticTool::swapEdge_mesh_undo() { } // Perform operation - std::auto_ptr undo(new SwapEdgeUndo(m_meSel.objects().front())); + std::unique_ptr undo(new SwapEdgeUndo(m_meSel.objects().front())); undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -1208,7 +1208,7 @@ void PlasticTool::collapseEdge_mesh_undo() { } // Perform operation - std::auto_ptr undo(new CollapseEdgeUndo(m_meSel.objects().front())); + std::unique_ptr undo(new CollapseEdgeUndo(m_meSel.objects().front())); undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -1219,7 +1219,7 @@ void PlasticTool::collapseEdge_mesh_undo() { void PlasticTool::splitEdge_mesh_undo() { if (!(m_mi && m_meSel.hasSingleObject())) return; - std::auto_ptr undo(new SplitEdgeUndo(m_meSel.objects().front())); + std::unique_ptr undo(new SplitEdgeUndo(m_meSel.objects().front())); undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -1230,7 +1230,7 @@ void PlasticTool::splitEdge_mesh_undo() { void PlasticTool::cutEdges_mesh_undo() { if (!m_mi) return; - std::auto_ptr undo(new CutEdgesUndo(m_meSel.objects())); + std::unique_ptr undo(new CutEdgesUndo(m_meSel.objects())); if (undo->do_()) TUndoManager::manager()->add(undo.release()); } diff --git a/toonz/sources/tnztools/plastictool_rigidity.cpp b/toonz/sources/tnztools/plastictool_rigidity.cpp index dd584e8..06c83f4 100644 --- a/toonz/sources/tnztools/plastictool_rigidity.cpp +++ b/toonz/sources/tnztools/plastictool_rigidity.cpp @@ -186,8 +186,8 @@ void RigidityPainter::commit() { // PlasticTool functions //**************************************************************************************** -std::auto_ptr PlasticTool::createRigidityPainter() { - return std::auto_ptr(new RigidityPainter); +std::unique_ptr PlasticTool::createRigidityPainter() { + return std::unique_ptr(new RigidityPainter); } //------------------------------------------------------------------------ diff --git a/toonz/sources/tnztools/strokeselection.cpp b/toonz/sources/tnztools/strokeselection.cpp index c4efaef..020519d 100644 --- a/toonz/sources/tnztools/strokeselection.cpp +++ b/toonz/sources/tnztools/strokeselection.cpp @@ -118,7 +118,7 @@ bool pasteStrokesWithoutUndo(TVectorImageP image, std::set &outIndexes, scene->getProperties()->getVectorizerParameters(); assert(vParams); - std::auto_ptr config( + std::unique_ptr config( vParams->getCurrentConfiguration(0.0)); vectorizeToonzImageData(image, tiData, indexes, image->getPalette(), *config); diff --git a/toonz/sources/tnztools/toolutils.cpp b/toonz/sources/tnztools/toolutils.cpp index 666da37..3717d96 100644 --- a/toonz/sources/tnztools/toolutils.cpp +++ b/toonz/sources/tnztools/toolutils.cpp @@ -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(selection); - if (strokeSelection) - strokeSelection->selectNone(); + if (strokeSelection) strokeSelection->selectNone(); UINT size = m_fillInformation->size(); TRegion *reg; diff --git a/toonz/sources/toonz/adjustthicknesspopup.cpp b/toonz/sources/toonz/adjustthicknesspopup.cpp index c1b3fdb..46e5554 100644 --- a/toonz/sources/toonz/adjustthicknesspopup.cpp +++ b/toonz/sources/toonz/adjustthicknesspopup.cpp @@ -1092,7 +1092,7 @@ void AdjustThicknessPopup::apply() { double fromTransform[2], toTransform[2]; getTransformParameters(fromTransform, toTransform); - std::auto_ptr undo( + std::unique_ptr undo( new AdjustThicknessUndo(m_selectionData, fromTransform, toTransform)); undo->redo(); diff --git a/toonz/sources/toonz/cellselectioncommand.cpp b/toonz/sources/toonz/cellselectioncommand.cpp index af0274b..a670e73 100644 --- a/toonz/sources/toonz/cellselectioncommand.cpp +++ b/toonz/sources/toonz/cellselectioncommand.cpp @@ -226,7 +226,7 @@ void TCellSelection::incrementCells() { TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); - std::auto_ptr undo(new IncrementUndo( + std::unique_ptr undo(new IncrementUndo( m_range.m_r0, m_range.m_c0, m_range.m_r1, m_range.m_c1)); if (undo->redo(), !undo->m_ok) { @@ -1312,7 +1312,7 @@ TXshSimpleLevel *CloneLevelUndo::cloneLevel( //----------------------------------------------------------------------------- bool CloneLevelUndo::chooseLevelName(TFilePath &fp) const { - std::auto_ptr levelNamePopup( + std::unique_ptr levelNamePopup( new LevelNamePopup(fp.getWideName())); if (levelNamePopup->exec() == QDialog::Accepted) { const QString &levelName = levelNamePopup->getName(); @@ -1385,7 +1385,7 @@ void CloneLevelUndo::cloneLevels() const { bool askCloneName = (levels.size() == 1); // Now, try to clone every found level in the associated range - std::auto_ptr dialog; + std::unique_ptr dialog; ExistsFunc exists(scene); LevelsMap::iterator lt, lEnd(levels.end()); @@ -1533,7 +1533,7 @@ void CloneLevelUndo::undo() const { //----------------------------------------------------------------------------- void TCellSelection::cloneLevel() { - std::auto_ptr undo(new CloneLevelUndo(m_range)); + std::unique_ptr undo(new CloneLevelUndo(m_range)); if (undo->redo(), undo->m_ok) TUndoManager::manager()->add(undo.release()); } diff --git a/toonz/sources/toonz/columncommand.cpp b/toonz/sources/toonz/columncommand.cpp index 07f5d48..0aa1e17 100644 --- a/toonz/sources/toonz/columncommand.cpp +++ b/toonz/sources/toonz/columncommand.cpp @@ -539,7 +539,7 @@ class DeleteColumnsUndo final : public TUndo { QMap> m_columnObjChildren; QMap m_columnObjParents; - mutable std::auto_ptr m_data; + mutable std::unique_ptr m_data; public: DeleteColumnsUndo(const std::set &indices) @@ -736,7 +736,7 @@ void ColumnCmd::insertEmptyColumns(const std::set &indices) { std::vector positiveIndices(indices.lower_bound(0), indices.end()); if (positiveIndices.empty()) return; - std::auto_ptr undo( + std::unique_ptr undo( new InsertEmptyColumnsUndo(positiveIndices)); if (undo->isConsistent()) { undo->redo(); diff --git a/toonz/sources/toonz/drawingdata.cpp b/toonz/sources/toonz/drawingdata.cpp index 4eb2bdc..370f22f 100644 --- a/toonz/sources/toonz/drawingdata.cpp +++ b/toonz/sources/toonz/drawingdata.cpp @@ -385,7 +385,7 @@ TImageP DrawingData::getImage(QString imageId, TXshSimpleLevel *sl, ToonzScene *scene = sl->getScene(); assert(scene); - std::auto_ptr config( + std::unique_ptr config( scene->getProperties() ->getVectorizerParameters() ->getCurrentConfiguration(0.0)); diff --git a/toonz/sources/toonz/exportlevelcommand.cpp b/toonz/sources/toonz/exportlevelcommand.cpp index 10e62f7..e0b7c90 100644 --- a/toonz/sources/toonz/exportlevelcommand.cpp +++ b/toonz/sources/toonz/exportlevelcommand.cpp @@ -217,7 +217,7 @@ class ImageExporter { ExportLevelOptions m_opts; TRasterP m_rout; - std::auto_ptr m_glContext; + std::unique_ptr m_glContext; public: ImageExporter(const TXshSimpleLevel &sl, const ExportLevelOptions &opts) @@ -536,9 +536,9 @@ bool IoCmd::exportLevel(const TFilePath &path, TXshSimpleLevel *sl, assert(opts.m_camera.getRes().lx > 0 && opts.m_camera.getRes().ly > 0); // Callbacks - std::auto_ptr overwriteDefault( + std::unique_ptr overwriteDefault( overwriteCB ? 0 : (overwriteCB = new ExportOverwriteCB())); - std::auto_ptr progressDefault( + std::unique_ptr progressDefault( progressCB ? 0 : (progressCB = new ExportProgressCB())); // Initialize variables diff --git a/toonz/sources/toonz/frameheadgadget.cpp b/toonz/sources/toonz/frameheadgadget.cpp index dc318d3..e6ab484 100644 --- a/toonz/sources/toonz/frameheadgadget.cpp +++ b/toonz/sources/toonz/frameheadgadget.cpp @@ -659,4 +659,3 @@ public: enableOnionSkin(checked); } } onionSkinToggle; - diff --git a/toonz/sources/toonz/insertfxpopup.cpp b/toonz/sources/toonz/insertfxpopup.cpp index 8206c15..ed7ed17 100644 --- a/toonz/sources/toonz/insertfxpopup.cpp +++ b/toonz/sources/toonz/insertfxpopup.cpp @@ -249,7 +249,7 @@ void InsertFxPopup::loadFolder(QTreeWidgetItem *parent) { // Found a sub-folder QString folderName = QString::fromStdString(tagName); - std::auto_ptr folder( + std::unique_ptr folder( new QTreeWidgetItem((QTreeWidget *)0, QStringList(folderName))); folder->setIcon(0, m_folderIcon); diff --git a/toonz/sources/toonz/levelcreatepopup.cpp b/toonz/sources/toonz/levelcreatepopup.cpp index 8442974..2a7ed3d 100644 --- a/toonz/sources/toonz/levelcreatepopup.cpp +++ b/toonz/sources/toonz/levelcreatepopup.cpp @@ -302,7 +302,7 @@ void LevelCreatePopup::updatePath() { //----------------------------------------------------------------------------- void LevelCreatePopup::nextName() { - const std::auto_ptr nameBuilder(NameBuilder::getBuilder(L"")); + const std::unique_ptr nameBuilder(NameBuilder::getBuilder(L"")); TLevelSet *levelSet = TApp::instance()->getCurrentScene()->getScene()->getLevelSet(); diff --git a/toonz/sources/toonz/loadfoldercommand.cpp b/toonz/sources/toonz/loadfoldercommand.cpp index 7808c1a..950d518 100644 --- a/toonz/sources/toonz/loadfoldercommand.cpp +++ b/toonz/sources/toonz/loadfoldercommand.cpp @@ -366,7 +366,7 @@ TFilePath dstPath(const TFilePath &dstDir, const Resource::Component &comp) { struct import_Locals { const ToonzScene &m_scene; - std::auto_ptr m_overwriteDialog; + std::unique_ptr m_overwriteDialog; void switchToDst(Resource::Path &path) { path.m_rootFp = m_scene.decodeFilePath( @@ -423,7 +423,7 @@ struct import_Locals { void import(const ToonzScene &scene, std::vector &resources, IoCmd::LoadResourceArguments::ScopedBlock &sb) { - import_Locals locals = {scene, std::auto_ptr()}; + import_Locals locals = {scene, std::unique_ptr()}; // Setup import GUI int r, rCount = resources.size(); diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp index 00dd059..90e2de7 100644 --- a/toonz/sources/toonz/main.cpp +++ b/toonz/sources/toonz/main.cpp @@ -319,7 +319,7 @@ int main(int argc, char *argv[]) { // order ONLY within the same library. On MAC, it made the app crash on exit // o_o. So, nope. - std::auto_ptr mainScope(new QObject( + std::unique_ptr mainScope(new QObject( &a)); // A QObject destroyed before the qApp is therefore explicitly mainScope->setObjectName("mainScope"); // provided. It can be accessed by // looking in the qApp's children. diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index 2cedecf..a6ef674 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -1908,7 +1908,7 @@ void MainWindow::defineActions() { createToggle(MI_OnionSkin, tr("Onion Skin Toggle"), "//", false, RightClickMenuCommandType); - createToggle(MI_ZeroThick, tr("Zero Thick Lines"), "Shift+/", false, + createToggle(MI_ZeroThick, tr("Zero Thick Lines"), "Shift+/", false, RightClickMenuCommandType); // createRightClickMenuAction(MI_LoadSubSceneFile, tr("Load As diff --git a/toonz/sources/toonz/meshifypopup.cpp b/toonz/sources/toonz/meshifypopup.cpp index bf51ea7..4138011 100644 --- a/toonz/sources/toonz/meshifypopup.cpp +++ b/toonz/sources/toonz/meshifypopup.cpp @@ -121,7 +121,7 @@ TRaster32P render(const TVectorImageP &vi, double &rasDpi, int margin, rasDpi = scale * Stage::inch; // Initialize a corresponding OpenGL context - std::auto_ptr offlineGlContext(new TOfflineGL(bbox.getSize())); + std::unique_ptr offlineGlContext(new TOfflineGL(bbox.getSize())); offlineGlContext->makeCurrent(); // Draw the image @@ -936,8 +936,9 @@ void createMeshifiedLevels(std::map &meshLevels, } // Prepare a progress dialog - std::auto_ptr progressDialog(new DVGui::ProgressDialog( - MeshifyPopup::tr("Mesh Creation in progress..."), QString(), 0, 0)); + std::unique_ptr progressDialog( + new DVGui::ProgressDialog( + MeshifyPopup::tr("Mesh Creation in progress..."), QString(), 0, 0)); { progressDialog->setWindowTitle("Create Mesh"); progressDialog->setModal(true); diff --git a/toonz/sources/toonz/sceneviewercontextmenu.cpp b/toonz/sources/toonz/sceneviewercontextmenu.cpp index f9c6cff..ed8c2e5 100644 --- a/toonz/sources/toonz/sceneviewercontextmenu.cpp +++ b/toonz/sources/toonz/sceneviewercontextmenu.cpp @@ -178,8 +178,8 @@ SceneViewerContextMenu::SceneViewerContextMenu(SceneViewer *parent) OnioniSkinMaskGUI::addOnionSkinCommand(this); // Zero Thick - if (!parent->isPreviewEnabled()) - ZeroThickToggleGui::addZeroThickCommand(this); + if (!parent->isPreviewEnabled()) + ZeroThickToggleGui::addZeroThickCommand(this); // preview if (parent->isPreviewEnabled()) { @@ -393,44 +393,41 @@ void SceneViewerContextMenu::savePreviewedFrames() { ->saveRenderedFrames(); } - - class ZeroThickToggle : public MenuItemHandler { public: - ZeroThickToggle() : MenuItemHandler(MI_ZeroThick) {} - void execute() { - QAction *action = CommandManager::instance()->getAction(MI_ZeroThick); - if (!action) - return; - bool checked = action->isChecked(); - enableZeroThick(checked); - } - - static void enableZeroThick(bool enable = true) { - Preferences::instance()->setShow0ThickLines(enable); - TApp::instance()->getCurrentScene()->notifySceneChanged(); - } -} ZeroThickToggle; + ZeroThickToggle() : MenuItemHandler(MI_ZeroThick) {} + void execute() { + QAction *action = CommandManager::instance()->getAction(MI_ZeroThick); + if (!action) return; + bool checked = action->isChecked(); + enableZeroThick(checked); + } + static void enableZeroThick(bool enable = true) { + Preferences::instance()->setShow0ThickLines(enable); + TApp::instance()->getCurrentScene()->notifySceneChanged(); + } +} ZeroThickToggle; void ZeroThickToggleGui::addZeroThickCommand(QMenu *menu) { - static ZeroThickToggleHandler switcher; - if (Preferences::instance()->getShow0ThickLines()) { - QAction *hideZeroThick = menu->addAction(QString(QObject::tr("Hide Zero Thickness Lines"))); - menu->connect(hideZeroThick, SIGNAL(triggered()), - &switcher, SLOT(deactivate())); - } - else { - QAction *showZeroThick = menu->addAction(QString(QObject::tr("Show Zero Thickness Lines"))); - menu->connect(showZeroThick, SIGNAL(triggered()), - &switcher, SLOT(activate())); - } + static ZeroThickToggleHandler switcher; + if (Preferences::instance()->getShow0ThickLines()) { + QAction *hideZeroThick = + menu->addAction(QString(QObject::tr("Hide Zero Thickness Lines"))); + menu->connect(hideZeroThick, SIGNAL(triggered()), &switcher, + SLOT(deactivate())); + } else { + QAction *showZeroThick = + menu->addAction(QString(QObject::tr("Show Zero Thickness Lines"))); + menu->connect(showZeroThick, SIGNAL(triggered()), &switcher, + SLOT(activate())); + } } void ZeroThickToggleGui::ZeroThickToggleHandler::activate() { - ZeroThickToggle::enableZeroThick(true); + ZeroThickToggle::enableZeroThick(true); } void ZeroThickToggleGui::ZeroThickToggleHandler::deactivate() { - ZeroThickToggle::enableZeroThick(false); + ZeroThickToggle::enableZeroThick(false); } \ No newline at end of file diff --git a/toonz/sources/toonz/sceneviewercontextmenu.h b/toonz/sources/toonz/sceneviewercontextmenu.h index e9ada49..09de03f 100644 --- a/toonz/sources/toonz/sceneviewercontextmenu.h +++ b/toonz/sources/toonz/sceneviewercontextmenu.h @@ -37,17 +37,16 @@ public slots: }; namespace ZeroThickToggleGui { - void addZeroThickCommand(QMenu* menu); +void addZeroThickCommand(QMenu *menu); - class ZeroThickToggleHandler : public QObject { - Q_OBJECT - - public slots: - void activate(); - void deactivate(); - }; +class ZeroThickToggleHandler : public QObject { + Q_OBJECT +public slots: + void activate(); + void deactivate(); +}; -} //Namespace ZeroThickToggleGui +} // Namespace ZeroThickToggleGui #endif diff --git a/toonz/sources/toonz/shortcutpopup.cpp b/toonz/sources/toonz/shortcutpopup.cpp index ef169ea..04d0c19 100644 --- a/toonz/sources/toonz/shortcutpopup.cpp +++ b/toonz/sources/toonz/shortcutpopup.cpp @@ -49,7 +49,7 @@ public: text.remove("&"); setText(0, text); QString shortcut = m_action->shortcut().toString(); - setText(1, shortcut); + setText(1, shortcut); } QAction *getAction() const { return m_action; } }; @@ -196,7 +196,7 @@ ShortcutTree::ShortcutTree(QWidget *parent) : QTreeWidget(parent) { addFolder(tr("File"), MenuFileCommandType, menuCommandFolder); addFolder(tr("Edit"), MenuEditCommandType, menuCommandFolder); addFolder(tr("Scan & Cleanup"), MenuScanCleanupCommandType, - menuCommandFolder); + menuCommandFolder); addFolder(tr("Level"), MenuLevelCommandType, menuCommandFolder); addFolder(tr("Xsheet"), MenuXsheetCommandType, menuCommandFolder); addFolder(tr("Cells"), MenuCellsCommandType, menuCommandFolder); @@ -225,14 +225,13 @@ ShortcutTree::~ShortcutTree() {} //----------------------------------------------------------------------------- -void ShortcutTree::addFolder(const QString &title, int commandType, - QTreeWidgetItem *parentFolder) { +void ShortcutTree::addFolder(const QString &title, int commandType, + QTreeWidgetItem *parentFolder) { QTreeWidgetItem *folder; - if (!parentFolder){ + if (!parentFolder) { folder = new QTreeWidgetItem(this); m_folders.push_back(folder); - } - else{ + } else { folder = new QTreeWidgetItem(parentFolder); m_subFolders.push_back(folder); } @@ -249,44 +248,44 @@ void ShortcutTree::addFolder(const QString &title, int commandType, //----------------------------------------------------------------------------- -void ShortcutTree::searchItems(const QString& searchWord) { - +void ShortcutTree::searchItems(const QString &searchWord) { if (searchWord.isEmpty()) { for (int i = 0; i < (int)m_items.size(); i++) m_items[i]->setHidden(false); - for (int f = 0; f < m_subFolders.size(); f++){ + for (int f = 0; f < m_subFolders.size(); f++) { m_subFolders[f]->setHidden(false); m_subFolders[f]->setExpanded(false); } - for (int f = 0; f < m_folders.size(); f++){ + for (int f = 0; f < m_folders.size(); f++) { m_folders[f]->setHidden(false); - m_folders[f]->setExpanded(f==0); + m_folders[f]->setExpanded(f == 0); } show(); emit searched(true); update(); return; } - - QList foundItems = findItems(searchWord, Qt::MatchContains | Qt::MatchRecursive, 0); - if (foundItems.isEmpty()){ + + QList foundItems = + findItems(searchWord, Qt::MatchContains | Qt::MatchRecursive, 0); + if (foundItems.isEmpty()) { hide(); emit searched(false); update(); return; } - + // show all matched items, hide all unmatched items for (int i = 0; i < (int)m_items.size(); i++) m_items[i]->setHidden(!foundItems.contains(m_items[i])); - + // hide folders which does not contain matched items // show and expand folders containing matched items bool found; - for (int f = 0; f < m_subFolders.size(); f++){ - QTreeWidgetItem* sf = m_subFolders.at(f); - found = false; - for (int i = 0; i < sf->childCount(); i++){ - if (!sf->child(i)->isHidden()){ + for (int f = 0; f < m_subFolders.size(); f++) { + QTreeWidgetItem *sf = m_subFolders.at(f); + found = false; + for (int i = 0; i < sf->childCount(); i++) { + if (!sf->child(i)->isHidden()) { found = true; break; } @@ -294,11 +293,11 @@ void ShortcutTree::searchItems(const QString& searchWord) { sf->setHidden(!found); sf->setExpanded(found); } - for (int f = 0; f < m_folders.size(); f++){ - QTreeWidgetItem* fol = m_folders.at(f); - found = false; - for (int i = 0; i < fol->childCount(); i++){ - if (!fol->child(i)->isHidden()){ + for (int f = 0; f < m_folders.size(); f++) { + QTreeWidgetItem *fol = m_folders.at(f); + found = false; + for (int i = 0; i < fol->childCount(); i++) { + if (!fol->child(i)->isHidden()) { found = true; break; } @@ -314,8 +313,7 @@ void ShortcutTree::searchItems(const QString& searchWord) { //----------------------------------------------------------------------------- -void ShortcutTree::resizeEvent(QResizeEvent *event) -{ +void ShortcutTree::resizeEvent(QResizeEvent *event) { header()->resizeSection(0, width() - 120); header()->resizeSection(1, 120); QTreeView::resizeEvent(event); @@ -351,31 +349,33 @@ ShortcutPopup::ShortcutPopup() m_sViewer = new ShortcutViewer(this); m_removeBtn = new QPushButton(tr("Remove"), this); - QLabel* noSearchResultLabel = new QLabel(tr("Couldn't find any matching command."), this); + QLabel *noSearchResultLabel = + new QLabel(tr("Couldn't find any matching command."), this); noSearchResultLabel->setHidden(true); - QLineEdit* searchEdit = new QLineEdit(this); + QLineEdit *searchEdit = new QLineEdit(this); m_topLayout->setMargin(5); m_topLayout->setSpacing(8); { - QHBoxLayout* searchLay = new QHBoxLayout(); + QHBoxLayout *searchLay = new QHBoxLayout(); searchLay->setMargin(0); searchLay->setSpacing(5); { - searchLay->addWidget(new QLabel("Search:",this),0); + searchLay->addWidget(new QLabel("Search:", this), 0); searchLay->addWidget(searchEdit); } m_topLayout->addLayout(searchLay, 0); - QVBoxLayout* listLay = new QVBoxLayout(); + QVBoxLayout *listLay = new QVBoxLayout(); listLay->setMargin(0); listLay->setSpacing(0); { - listLay->addWidget(noSearchResultLabel, 0, Qt::AlignTop|Qt::AlignHCenter); + listLay->addWidget(noSearchResultLabel, 0, + Qt::AlignTop | Qt::AlignHCenter); listLay->addWidget(m_list, 1); } - m_topLayout->addLayout(listLay,1); + m_topLayout->addLayout(listLay, 1); QHBoxLayout *bottomLayout = new QHBoxLayout(); bottomLayout->setMargin(0); @@ -395,8 +395,10 @@ ShortcutPopup::ShortcutPopup() connect(m_sViewer, SIGNAL(shortcutChanged()), m_list, SLOT(onShortcutChanged())); - connect(m_list, SIGNAL(searched(bool)), noSearchResultLabel, SLOT(setHidden(bool))); - connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onSearchTextChanged(const QString &))); + connect(m_list, SIGNAL(searched(bool)), noSearchResultLabel, + SLOT(setHidden(bool))); + connect(searchEdit, SIGNAL(textChanged(const QString &)), this, + SLOT(onSearchTextChanged(const QString &))); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/shortcutpopup.h b/toonz/sources/toonz/shortcutpopup.h index 84e8602..2044ac6 100644 --- a/toonz/sources/toonz/shortcutpopup.h +++ b/toonz/sources/toonz/shortcutpopup.h @@ -61,13 +61,14 @@ public: ShortcutTree(QWidget *parent = 0); ~ShortcutTree(); - void searchItems(const QString& searchWord = QString()); + void searchItems(const QString &searchWord = QString()); + protected: // aggiunge un blocco di QAction. commandType e' un // CommandType::MenubarCommandType - void addFolder(const QString &title, int commandType, + void addFolder(const QString &title, int commandType, QTreeWidgetItem *folder = 0); - + void resizeEvent(QResizeEvent *event); public slots: @@ -91,14 +92,13 @@ class ShortcutPopup final : public DVGui::Dialog { QPushButton *m_removeBtn; ShortcutViewer *m_sViewer; ShortcutTree *m_list; - + public: ShortcutPopup(); ~ShortcutPopup(); protected slots: void onSearchTextChanged(const QString &text); - }; #endif // SHORTCUTPOPUP_H diff --git a/toonz/sources/toonz/vectorizerpopup.cpp b/toonz/sources/toonz/vectorizerpopup.cpp index 511d1e1..3aa13db 100644 --- a/toonz/sources/toonz/vectorizerpopup.cpp +++ b/toonz/sources/toonz/vectorizerpopup.cpp @@ -243,7 +243,8 @@ void Vectorizer::setLevel(const TXshSimpleLevelP &level) { // Build the new level name std::wstring levelName = sl->getName() + L"v"; { - std::auto_ptr nameBuilder(NameBuilder::getBuilder(levelName)); + std::unique_ptr nameBuilder( + NameBuilder::getBuilder(levelName)); for (;;) { levelName = nameBuilder->getNext(); @@ -1411,8 +1412,8 @@ void VectorizerPopup::saveParameters() { // Replace data to be saved VectorizerParameters *params = getCurrentVectorizerParameters(); - std::auto_ptr paramsClone(new VectorizerParameters(*params)); - levelSettings.insert(paramsClone); + levelSettings.insert( + std::unique_ptr(new VectorizerParameters(*params))); // Save the new settings TOStream os(fp); diff --git a/toonz/sources/toonz/vectorizerswatch.cpp b/toonz/sources/toonz/vectorizerswatch.cpp index bf65f8a..2cfc4dd 100644 --- a/toonz/sources/toonz/vectorizerswatch.cpp +++ b/toonz/sources/toonz/vectorizerswatch.cpp @@ -59,9 +59,9 @@ inline TImageP getXsheetImage(int row, int col) { //----------------------------------------------------------------------------- -std::auto_ptr getCurrentVectorizerConfiguration( +std::unique_ptr getCurrentVectorizerConfiguration( int row, int col) { - typedef std::auto_ptr result_type; + typedef std::unique_ptr result_type; TApp *app = TApp::instance(); TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); diff --git a/toonz/sources/toonz/vectorizerswatch.h b/toonz/sources/toonz/vectorizerswatch.h index 576c8d5..6827d9d 100644 --- a/toonz/sources/toonz/vectorizerswatch.h +++ b/toonz/sources/toonz/vectorizerswatch.h @@ -93,7 +93,7 @@ class VectorizationSwatchTask final : public TThread::Runnable { int m_row, m_col; TImageP m_image; - std::auto_ptr m_config; + std::unique_ptr m_config; public: VectorizationSwatchTask(int row, int col); diff --git a/toonz/sources/toonz/xsheetcmd.cpp b/toonz/sources/toonz/xsheetcmd.cpp index f378f60..32673fc 100644 --- a/toonz/sources/toonz/xsheetcmd.cpp +++ b/toonz/sources/toonz/xsheetcmd.cpp @@ -1299,7 +1299,8 @@ public: pegbar->getKeyframeSpan(row, r0, ease0, r1, ease1); - std::auto_ptr undo(new KeyFrameHandleCommandUndo(objectId, r0, r1)); + std::unique_ptr undo( + new KeyFrameHandleCommandUndo(objectId, r0, r1)); TStageObject::Keyframe keyframe0 = pegbar->getKeyframe(r0); TStageObject::Keyframe keyframe1 = pegbar->getKeyframe(r1); @@ -1346,7 +1347,8 @@ public: pegbar->getKeyframeSpan(row, r0, ease0, r1, ease1); - std::auto_ptr undo(new KeyFrameHandleCommandUndo(objectId, r0, r1)); + std::unique_ptr undo( + new KeyFrameHandleCommandUndo(objectId, r0, r1)); TStageObject::Keyframe keyframe0 = pegbar->getKeyframe(r0); TStageObject::Keyframe keyframe1 = pegbar->getKeyframe(r1); diff --git a/toonz/sources/toonzlib/fxcommand.cpp b/toonz/sources/toonzlib/fxcommand.cpp index 33c677c..90bbac0 100644 --- a/toonz/sources/toonzlib/fxcommand.cpp +++ b/toonz/sources/toonzlib/fxcommand.cpp @@ -921,7 +921,7 @@ void TFxCommand::insertFx(TFx *newFx, const QList &fxs, int row) { if (!newFx) return; - std::auto_ptr undo( + std::unique_ptr undo( new InsertFxUndo(newFx, row, col, fxs, links, app)); if (undo->isConsistent()) { undo->redo(); @@ -937,7 +937,7 @@ void TFxCommand::addFx(TFx *newFx, const QList &fxs, TApplication *app, int col, int row) { if (!newFx) return; - std::auto_ptr undo( + std::unique_ptr undo( new InsertFxUndo(newFx, row, col, fxs, QList(), app, false)); if (!undo->isConsistent()) return; @@ -1068,7 +1068,7 @@ QString DuplicateFxUndo::getHistoryString() { void TFxCommand::duplicateFx(TFx *src, TXsheetHandle *xshHandle, TFxHandle *fxHandle) { - std::auto_ptr undo( + std::unique_ptr undo( new DuplicateFxUndo(src, xshHandle, fxHandle)); if (undo->isConsistent()) { undo->redo(); @@ -1297,7 +1297,7 @@ void TFxCommand::replaceFx(TFx *newFx, const QList &fxs, for (f = 0; f != fCount; ++f) { if (!clonedFx) clonedFx = cloneFx(); - std::auto_ptr undo( + std::unique_ptr undo( new ReplaceFxUndo(clonedFx, fxs[f], xshHandle, fxHandle)); if (undo->isConsistent()) { undo->redo(); @@ -1350,7 +1350,7 @@ void TFxCommand::unlinkFx(TFx *fx, TFxHandle *fxHandle, TXsheetHandle *xshHandle) { if (!fx) return; - std::auto_ptr undo(new UnlinkFxUndo(fx, xshHandle)); + std::unique_ptr undo(new UnlinkFxUndo(fx, xshHandle)); if (undo->isConsistent()) { undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -1498,7 +1498,7 @@ void MakeMacroUndo::undo() const { void TFxCommand::makeMacroFx(const std::vector &fxs, TApplication *app) { if (fxs.empty()) return; - std::auto_ptr undo(new MakeMacroUndo(fxs, app)); + std::unique_ptr undo(new MakeMacroUndo(fxs, app)); if (undo->isConsistent()) { undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -1542,7 +1542,7 @@ void ExplodeMacroUndo::initialize() { void TFxCommand::explodeMacroFx(TMacroFx *macroFx, TApplication *app) { if (!macroFx) return; - std::auto_ptr undo(new ExplodeMacroUndo(macroFx, app)); + std::unique_ptr undo(new ExplodeMacroUndo(macroFx, app)); if (undo->isConsistent()) { undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -1711,7 +1711,7 @@ void ConnectNodesToXsheetUndo::initialize() { void TFxCommand::connectNodesToXsheet(const std::list &fxs, TXsheetHandle *xshHandle) { - std::auto_ptr undo( + std::unique_ptr undo( new ConnectNodesToXsheetUndo(fxs, xshHandle)); if (undo->isConsistent()) { undo->redo(); @@ -1766,7 +1766,7 @@ void DisconnectNodesFromXsheetUndo::initialize() { void TFxCommand::disconnectNodesFromXsheet(const std::list &fxs, TXsheetHandle *xshHandle) { - std::auto_ptr undo( + std::unique_ptr undo( new DisconnectNodesFromXsheetUndo(fxs, xshHandle)); if (undo->isConsistent()) { undo->redo(); @@ -2037,8 +2037,8 @@ QString DeleteLinksUndo::getHistoryString() { //============================================================= static void deleteLinks(const std::list &links, - TXsheetHandle *xshHandle) { - std::auto_ptr undo(new DeleteLinksUndo(links, xshHandle)); + TXsheetHandle *xshHandle) { + std::unique_ptr undo(new DeleteLinksUndo(links, xshHandle)); if (undo->isConsistent()) { undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -2058,7 +2058,7 @@ protected: TFxP m_linkedFx; std::vector m_nonTerminalInputs; - mutable std::auto_ptr m_columnData; + mutable std::unique_ptr m_columnData; TXsheetHandle *m_xshHandle; TFxHandle *m_fxHandle; @@ -2299,7 +2299,7 @@ QString DeleteFxOrColumnUndo::getHistoryString() { //============================================================= static void deleteFxs(const std::list &fxs, TXsheetHandle *xshHandle, - TFxHandle *fxHandle) { + TFxHandle *fxHandle) { TUndoManager *undoManager = TUndoManager::manager(); TXsheet *xsh = xshHandle->getXsheet(); @@ -2313,7 +2313,7 @@ static void deleteFxs(const std::list &fxs, TXsheetHandle *xshHandle, // or ABOVE, if any. if (dynamic_cast(ft->getPointer())) continue; - std::auto_ptr undo( + std::unique_ptr undo( new DeleteFxOrColumnUndo(*ft, xshHandle, fxHandle)); if (undo->isConsistent()) { undo->redo(); @@ -2333,7 +2333,7 @@ void TFxCommand::removeOutputFx(TFx *fx, TXsheetHandle *xshHandle, TOutputFx *outputFx = dynamic_cast(fx); if (!outputFx) return; - std::auto_ptr undo( + std::unique_ptr undo( new DeleteFxOrColumnUndo(fx, xshHandle, fxHandle)); if (undo->isConsistent()) { undo->redo(); @@ -2346,7 +2346,7 @@ void TFxCommand::removeOutputFx(TFx *fx, TXsheetHandle *xshHandle, //********************************************************************** static void deleteColumns(const std::list &columns, TXsheetHandle *xshHandle, - TFxHandle *fxHandle) { + TFxHandle *fxHandle) { TUndoManager *undoManager = TUndoManager::manager(); undoManager->beginBlock(); @@ -2365,7 +2365,7 @@ static void deleteColumns(const std::list &columns, TXsheetHandle *xshHandl size_t c, cCount = cols.size(); for (c = 0; c != cCount; ++c) { - std::auto_ptr undo( + std::unique_ptr undo( new DeleteFxOrColumnUndo(cols[c]->getIndex(), xshHandle, fxHandle)); if (undo->isConsistent()) { undo->redo(); @@ -2726,7 +2726,7 @@ void TFxCommand::pasteFxs(const std::list &fxs, const std::list &columns, const TPointD &pos, TXsheetHandle *xshHandle, TFxHandle *fxHandle) { - std::auto_ptr undo(new UndoPasteFxs( + std::unique_ptr undo(new UndoPasteFxs( fxs, zeraryFxColumnSize, columns, pos, xshHandle, fxHandle)); if (undo->isConsistent()) { undo->redo(); @@ -2815,7 +2815,7 @@ void TFxCommand::addPasteFxs(TFx *inFx, const std::list &fxs, const std::map &zeraryFxColumnSize, const std::list &columns, TXsheetHandle *xshHandle, TFxHandle *fxHandle) { - std::auto_ptr undo(new UndoAddPasteFxs( + std::unique_ptr undo(new UndoAddPasteFxs( inFx, fxs, zeraryFxColumnSize, columns, xshHandle, fxHandle)); if (undo->isConsistent()) { // NOTE: (inFx == 0) is considered consistent, as long as @@ -2907,7 +2907,7 @@ void TFxCommand::insertPasteFxs(const Link &link, const std::list &fxs, const std::map &zeraryFxColumnSize, const std::list &columns, TXsheetHandle *xshHandle, TFxHandle *fxHandle) { - std::auto_ptr undo(new UndoInsertPasteFxs( + std::unique_ptr undo(new UndoInsertPasteFxs( link, fxs, zeraryFxColumnSize, columns, xshHandle, fxHandle)); if (undo->isConsistent()) { undo->redo(); @@ -2920,7 +2920,7 @@ void TFxCommand::insertPasteFxs(const Link &link, const std::list &fxs, //********************************************************************** class UndoReplacePasteFxs final : public UndoAddPasteFxs { - std::auto_ptr m_deleteFxUndo; + std::unique_ptr m_deleteFxUndo; TFx *m_fx, *m_rightmostFx; @@ -3033,7 +3033,7 @@ void TFxCommand::replacePasteFxs(TFx *inFx, const std::list &fxs, const std::list &columns, TXsheetHandle *xshHandle, TFxHandle *fxHandle) { - std::auto_ptr undo(new UndoReplacePasteFxs( + std::unique_ptr undo(new UndoReplacePasteFxs( inFx, fxs, zeraryFxColumnSize, columns, xshHandle, fxHandle)); if (undo->isConsistent()) { undo->redo(); @@ -3199,7 +3199,7 @@ void UndoDisconnectFxs::undo() const { void TFxCommand::disconnectFxs(const std::list &fxs, TXsheetHandle *xshHandle, const QList> &fxPos) { - std::auto_ptr undo( + std::unique_ptr undo( new UndoDisconnectFxs(fxs, fxPos, xshHandle)); if (undo->isConsistent()) { undo->redo(); @@ -3343,7 +3343,7 @@ QString UndoConnectFxs::getHistoryString() { void TFxCommand::connectFxs(const Link &link, const std::list &fxs, TXsheetHandle *xshHandle, const QList> &fxPos) { - std::auto_ptr undo( + std::unique_ptr undo( new UndoConnectFxs(link, fxs, fxPos, xshHandle)); if (undo->isConsistent()) { undo->redo(); @@ -3463,14 +3463,14 @@ void SetParentUndo::undo() const { void TFxCommand::setParent(TFx *fx, TFx *parentFx, int parentFxPort, TXsheetHandle *xshHandle) { if (dynamic_cast(parentFx) || parentFxPort < 0) { - std::auto_ptr undo( + std::unique_ptr undo( new ConnectNodesToXsheetUndo(std::list(1, fx), xshHandle)); if (undo->isConsistent()) { undo->redo_(); TUndoManager::manager()->add(undo.release()); } } else { - std::auto_ptr undo( + std::unique_ptr undo( new SetParentUndo(fx, parentFx, parentFxPort, xshHandle)); if (undo->isConsistent()) { undo->redo_(); @@ -3527,7 +3527,7 @@ void TFxCommand::renameFx(TFx *fx, const std::wstring &newName, TXsheetHandle *xshHandle) { if (!fx) return; - std::auto_ptr undo(new UndoRenameFx(fx, newName, xshHandle)); + std::unique_ptr undo(new UndoRenameFx(fx, newName, xshHandle)); if (undo->isConsistent()) { undo->redo_(); TUndoManager::manager()->add(undo.release()); @@ -3650,7 +3650,7 @@ void UndoGroupFxs::undo() const { void TFxCommand::groupFxs(const std::list &fxs, TXsheetHandle *xshHandle) { - std::auto_ptr undo(new UndoGroupFxs(fxs, xshHandle)); + std::unique_ptr undo(new UndoGroupFxs(fxs, xshHandle)); if (undo->isConsistent()) { undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -3737,7 +3737,7 @@ void UndoUngroupFxs::initialize() { //====================================================== void TFxCommand::ungroupFxs(int groupId, TXsheetHandle *xshHandle) { - std::auto_ptr undo(new UndoUngroupFxs(groupId, xshHandle)); + std::unique_ptr undo(new UndoUngroupFxs(groupId, xshHandle)); if (undo->isConsistent()) { undo->redo(); TUndoManager::manager()->add(undo.release()); @@ -3849,7 +3849,7 @@ void UndoRenameGroup::undo() const { void TFxCommand::renameGroup(const std::list &fxs, const std::wstring &name, bool fromEditor, TXsheetHandle *xshHandle) { - std::auto_ptr undo( + std::unique_ptr undo( new UndoRenameGroup(fxs, name, fromEditor, xshHandle)); if (undo->isConsistent()) { undo->redo_(); // Same schematic nodes problem as above... :( diff --git a/toonz/sources/toonzlib/movierenderer.cpp b/toonz/sources/toonzlib/movierenderer.cpp index 35c6e30..924ce5b 100644 --- a/toonz/sources/toonzlib/movierenderer.cpp +++ b/toonz/sources/toonzlib/movierenderer.cpp @@ -107,7 +107,7 @@ public: double m_xDpi, m_yDpi; std::set m_listeners; - std::auto_ptr m_levelUpdaterA, m_levelUpdaterB; + std::unique_ptr m_levelUpdaterA, m_levelUpdaterB; TSoundTrackP m_st; std::map> m_toBeSaved; diff --git a/toonz/sources/toonzlib/palettecmd.cpp b/toonz/sources/toonzlib/palettecmd.cpp index 30a0390..5e16930 100644 --- a/toonz/sources/toonzlib/palettecmd.cpp +++ b/toonz/sources/toonzlib/palettecmd.cpp @@ -603,7 +603,7 @@ void PaletteCmd::eraseStyles(const std::set &levels, if (levels.empty() || styleIds.empty()) return; - std::auto_ptr undo(new Undo(levels, styleIds)); + std::unique_ptr undo(new Undo(levels, styleIds)); if (static_cast(*undo).isValid()) { undo->redo(); TUndoManager::manager()->add(undo.release()); diff --git a/toonz/sources/toonzlib/palettecontroller.cpp b/toonz/sources/toonzlib/palettecontroller.cpp index 8129f98..9a7632a 100644 --- a/toonz/sources/toonzlib/palettecontroller.cpp +++ b/toonz/sources/toonzlib/palettecontroller.cpp @@ -12,7 +12,8 @@ #include "toonz/palettecontroller.h" -TEnv::IntVar PaletteControllerAutoApplyState("PaletteControllerAutoApplyState", 1); +TEnv::IntVar PaletteControllerAutoApplyState("PaletteControllerAutoApplyState", + 1); PaletteController::PaletteController() : QObject() @@ -20,7 +21,7 @@ PaletteController::PaletteController() , m_currentCleanupPalette(0) , m_originalCurrentPalette(0) , m_currentPalette(0) - , m_colorAutoApplyEnabled( PaletteControllerAutoApplyState != 0 ) + , m_colorAutoApplyEnabled(PaletteControllerAutoApplyState != 0) , m_colorSample() { m_currentLevelPalette = new TPaletteHandle; m_currentCleanupPalette = new TPaletteHandle; @@ -93,7 +94,7 @@ void PaletteController::editCleanupPalette() { void PaletteController::enableColorAutoApply(bool enabled) { if (m_colorAutoApplyEnabled != enabled) { - m_colorAutoApplyEnabled = enabled; + m_colorAutoApplyEnabled = enabled; PaletteControllerAutoApplyState = (enabled) ? 1 : 0; emit colorAutoApplyEnabled(m_colorAutoApplyEnabled); } diff --git a/toonz/sources/toonzlib/plasticdeformerfx.cpp b/toonz/sources/toonzlib/plasticdeformerfx.cpp index e9870c3..bda75e2 100644 --- a/toonz/sources/toonzlib/plasticdeformerfx.cpp +++ b/toonz/sources/toonzlib/plasticdeformerfx.cpp @@ -317,7 +317,7 @@ void PlasticDeformerFx::doCompute(TTile &tile, double frame, TScale worldMeshToMeshAff(meshDpi.x / Stage::inch, meshDpi.y / Stage::inch); - std::auto_ptr dataGroup( + std::unique_ptr dataGroup( PlasticDeformerStorage::instance()->processOnce( sdFrame, mi.getPointer(), sd.getPointer(), sd->skeletonId(sdFrame), worldMeshToMeshAff)); @@ -356,7 +356,7 @@ void PlasticDeformerFx::doCompute(TTile &tile, double frame, const std::string &texId = "render_tex " + std::to_string(++var); // Prepare an OpenGL context - std::auto_ptr context( + std::unique_ptr context( new TOfflineGL(tile.getRaster()->getSize())); context->makeCurrent(); diff --git a/toonz/sources/toonzlib/screensavermaker.cpp b/toonz/sources/toonzlib/screensavermaker.cpp index 8b6066b..4cbd8cf 100644 --- a/toonz/sources/toonzlib/screensavermaker.cpp +++ b/toonz/sources/toonzlib/screensavermaker.cpp @@ -1,10 +1,10 @@ - - #include "toonz/screensavermaker.h" -#include "texception.h" +#include "texception.h" #include "tsystem.h" +#include + #ifdef _WIN32 #pragma warning(disable : 4996) @@ -24,7 +24,7 @@ void makeScreenSaver(TFilePath scrFn, TFilePath swfFn, throw TException(L"Can't stat file " + swfFn.getWideString()); int swfSize = results.st_size; - std::auto_ptr swf(new char[swfSize]); + std::unique_ptr swf(new char[swfSize]); FILE *chan = _wfopen(swfFn.getWideString().c_str(), L"rb"); if (!chan) throw TException(L"fopen failed on " + swfFn.getWideString()); fread(swf.get(), swfSize, 1, chan); diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cpp index e4125ad..a73c1b3 100644 --- a/toonz/sources/toonzlib/toonzscene.cpp +++ b/toonz/sources/toonzlib/toonzscene.cpp @@ -824,7 +824,7 @@ TXshLevel *ToonzScene::createNewLevel(int type, std::wstring levelName, // Select a different unique level name in case it already exists (either in // scene or on disk) { - const std::auto_ptr nameBuilder( + const std::unique_ptr nameBuilder( NameBuilder::getBuilder(levelName)); for (;;) { diff --git a/toonz/sources/toonzlib/txsheetexpr.cpp b/toonz/sources/toonzlib/txsheetexpr.cpp index fe7d917..0968c3a 100644 --- a/toonz/sources/toonzlib/txsheetexpr.cpp +++ b/toonz/sources/toonzlib/txsheetexpr.cpp @@ -66,12 +66,12 @@ class ParamCalculatorNode final : public CalculatorNode, public TParamObserver, public boost::noncopyable { TDoubleParamP m_param; - std::auto_ptr m_frame; + std::unique_ptr m_frame; public: ParamCalculatorNode(Calculator *calculator, const TDoubleParamP ¶m, - std::auto_ptr frame) - : CalculatorNode(calculator), m_param(param), m_frame(frame) { + std::unique_ptr frame) + : CalculatorNode(calculator), m_param(param), m_frame(std::move(frame)) { param->addObserver(this); } @@ -122,15 +122,15 @@ class XsheetDrawingCalculatorNode final : public CalculatorNode, TXsheet *m_xsh; int m_columnIndex; - std::auto_ptr m_frame; + std::unique_ptr m_frame; public: XsheetDrawingCalculatorNode(Calculator *calc, TXsheet *xsh, int columnIndex, - std::auto_ptr frame) + std::unique_ptr frame) : CalculatorNode(calc) , m_xsh(xsh) , m_columnIndex(columnIndex) - , m_frame(frame) {} + , m_frame(std::move(frame)) {} double compute(double vars[3]) const override { double f = m_frame->compute(vars); @@ -265,7 +265,7 @@ public: const std::vector &tokens) const override { assert(tokens.size() >= 3); - std::auto_ptr frameNode( + std::unique_ptr frameNode( (tokens.size() == 6) ? popNode(stack) : new VariableNode(calc, CalculatorNode::FRAME)); @@ -274,14 +274,15 @@ public: std::string field = toLower(tokens[2].getText()); if (field == "cell" || field == "cel" || field == "cels") { int columnIndex = objectId.getIndex(); - stack.push_back( - new XsheetDrawingCalculatorNode(calc, m_xsh, columnIndex, frameNode)); + stack.push_back(new XsheetDrawingCalculatorNode(calc, m_xsh, columnIndex, + std::move(frameNode))); } else { TStageObject *object = m_xsh->getStageObject(objectId); TStageObject::Channel channelName = matchChannelName(tokens[2]); TDoubleParam *channel = object->getParam(channelName); if (channel) - stack.push_back(new ParamCalculatorNode(calc, channel, frameNode)); + stack.push_back( + new ParamCalculatorNode(calc, channel, std::move(frameNode))); } } }; @@ -388,7 +389,7 @@ public: const std::vector &tokens) const override { int tokenSize = tokens.size(); - std::auto_ptr frameNode( + std::unique_ptr frameNode( (tokenSize > 0 && tokens.back().getText() == ")") ? popNode(stack) : new VariableNode(calc, CalculatorNode::FRAME)); @@ -409,7 +410,8 @@ public: channel = param; if (channel.getPointer()) - stack.push_back(new ParamCalculatorNode(calc, channel, frameNode)); + stack.push_back( + new ParamCalculatorNode(calc, channel, std::move(frameNode))); } }; @@ -526,7 +528,7 @@ public: const std::vector &tokens) const override { assert(tokens.size() > COMPONENT); - std::auto_ptr frameNode( + std::unique_ptr frameNode( (tokens.size() == POSITIONS_COUNT) ? popNode(stack) : new VariableNode(calc, CalculatorNode::FRAME)); @@ -550,7 +552,8 @@ public: if (component != componentsEnd) { const TDoubleParamP ¶m = skvd->m_params[component->m_paramId].getPointer(); - stack.push_back(new ParamCalculatorNode(calc, param, frameNode)); + stack.push_back( + new ParamCalculatorNode(calc, param, std::move(frameNode))); } } } diff --git a/toonz/sources/toonzqt/addfxcontextmenu.cpp b/toonz/sources/toonzqt/addfxcontextmenu.cpp index b6bf3c2..908455e 100644 --- a/toonz/sources/toonzqt/addfxcontextmenu.cpp +++ b/toonz/sources/toonzqt/addfxcontextmenu.cpp @@ -245,9 +245,9 @@ void AddFxContextMenu::loadFxs() { void AddFxContextMenu::loadFxPluginGroup() { QString groupName = QString::fromStdString("Plugins"); - std::auto_ptr insertFxGroup(new QMenu(groupName, m_insertMenu)); - std::auto_ptr addFxGroup(new QMenu(groupName, m_addMenu)); - std::auto_ptr replaceFxGroup(new QMenu(groupName, m_replaceMenu)); + std::unique_ptr insertFxGroup(new QMenu(groupName, m_insertMenu)); + std::unique_ptr addFxGroup(new QMenu(groupName, m_addMenu)); + std::unique_ptr replaceFxGroup(new QMenu(groupName, m_replaceMenu)); loadFxPlugins(insertFxGroup.get(), addFxGroup.get(), replaceFxGroup.get()); @@ -263,9 +263,10 @@ void AddFxContextMenu::loadFxGroup(TIStream *is) { if (is->matchTag(tagName)) { QString groupName = QString::fromStdString(tagName); - std::auto_ptr insertFxGroup(new QMenu(groupName, m_insertMenu)); - std::auto_ptr addFxGroup(new QMenu(groupName, m_addMenu)); - std::auto_ptr replaceFxGroup(new QMenu(groupName, m_replaceMenu)); + std::unique_ptr insertFxGroup(new QMenu(groupName, m_insertMenu)); + std::unique_ptr addFxGroup(new QMenu(groupName, m_addMenu)); + std::unique_ptr replaceFxGroup( + new QMenu(groupName, m_replaceMenu)); loadFx(is, insertFxGroup.get(), addFxGroup.get(), replaceFxGroup.get()); diff --git a/toonz/sources/toonzqt/keyframenavigator.cpp b/toonz/sources/toonzqt/keyframenavigator.cpp index 8bc430b..b8d1431 100644 --- a/toonz/sources/toonzqt/keyframenavigator.cpp +++ b/toonz/sources/toonzqt/keyframenavigator.cpp @@ -353,7 +353,7 @@ void PaletteKeyframeNavigator::toggle() { int styleId = getStyleIndex(), frame = getCurrentFrame(); - std::auto_ptr undo( + std::unique_ptr undo( new UndoPaletteSetKeyFrame(styleId, frame, m_paletteHandle)); undo->redo(); diff --git a/toonz/sources/toonzqt/paletteviewergui.cpp b/toonz/sources/toonzqt/paletteviewergui.cpp index a20bb85..fcd489b 100644 --- a/toonz/sources/toonzqt/paletteviewergui.cpp +++ b/toonz/sources/toonzqt/paletteviewergui.cpp @@ -949,7 +949,6 @@ void PageViewer::mouseDoubleClickEvent(QMouseEvent *e) { } CommandManager::instance()->execute("MI_OpenStyleControl"); - } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonzqt/rasterimagedata.cpp b/toonz/sources/toonzqt/rasterimagedata.cpp index f0cce67..def5ac4 100644 --- a/toonz/sources/toonzqt/rasterimagedata.cpp +++ b/toonz/sources/toonzqt/rasterimagedata.cpp @@ -294,7 +294,7 @@ StrokesData *FullColorImageData::toStrokesData(ToonzScene *scene) const { scene->getProperties()->getVectorizerParameters(); assert(vParams); - std::auto_ptr config( + std::unique_ptr config( vParams->getCurrentConfiguration(0.0)); TVectorImageP vi = vectorize(image, rect, *config, m_transformation); diff --git a/toonz/sources/toonzqt/styleselection.cpp b/toonz/sources/toonzqt/styleselection.cpp index 81e823b..024ace0 100644 --- a/toonz/sources/toonzqt/styleselection.cpp +++ b/toonz/sources/toonzqt/styleselection.cpp @@ -605,7 +605,7 @@ void TStyleSelection::cutStyles() { styleIds.push_back(page->getStyleId(*it)); } - std::auto_ptr undo(new CutStylesUndo(this, data, oldData)); + std::unique_ptr undo(new CutStylesUndo(this, data, oldData)); if (m_xsheetHandle) { if (eraseStylesInDemand(palette, styleIds, m_xsheetHandle) == 0) return; @@ -683,7 +683,7 @@ void TStyleSelection::deleteStyles() { return; } - std::auto_ptr undo(new DeleteStylesUndo(this, data)); + std::unique_ptr undo(new DeleteStylesUndo(this, data)); deleteStylesWithoutUndo(m_paletteHandle->getPalette(), m_paletteHandle, m_pageIndex, &m_styleIndicesInPage);