diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt index 2291edc..a6a373d 100644 --- a/toonz/sources/CMakeLists.txt +++ b/toonz/sources/CMakeLists.txt @@ -21,6 +21,7 @@ if (WIN32) endif() set(QT_LIB_PATH ${QT_PATH}) set(CMAKE_PREFIX_PATH "${QT_PATH}/lib/cmake/") + add_definitions(-DNOMINMAX) elseif (APPLE) message("Apple System") if (NOT PLATFORM) diff --git a/toonz/sources/colorfx/colorfxutils.h b/toonz/sources/colorfx/colorfxutils.h index eeff9b0..14790d5 100644 --- a/toonz/sources/colorfx/colorfxutils.h +++ b/toonz/sources/colorfx/colorfxutils.h @@ -8,15 +8,14 @@ #include "trandom.h" #include "tregionoutline.h" #include "tcurves.h" -using namespace std; class TRegion; class TFlash; class RubberDeform { - vector *m_pPolyOri; - vector m_polyLoc; + std::vector *m_pPolyOri; + std::vector m_polyLoc; void deformStep(); double avgLength(); @@ -25,7 +24,7 @@ class RubberDeform public: RubberDeform(); - RubberDeform(vector *pPolyOri, const double rf = -1.0); + RubberDeform(std::vector *pPolyOri, const double rf = -1.0); void copyLoc2Ori() { *m_pPolyOri = m_polyLoc; }; void copyOri2Loc() { m_polyLoc = *m_pPolyOri; }; @@ -36,12 +35,12 @@ public: class SFlashUtils { void computeOutline(const TRegion *region, TRegionOutline::PointVector &polyline) const; - void PointVector2QuadsArray(const vector &pv, - vector &quadArray, - vector &toBeDeleted, + void PointVector2QuadsArray(const std::vector &pv, + std::vector &quadArray, + std::vector &toBeDeleted, const bool isRounded) const; - int nbDiffVerts(const vector &pv) const; - void Triangle2Quad(vector &p) const; + int nbDiffVerts(const std::vector &pv) const; + void Triangle2Quad(std::vector &p) const; public: const TRegion *m_r; @@ -54,11 +53,11 @@ public: void computeRegionOutline(); void drawRegionOutline(TFlash &flash, const bool isRounded = true) const; void drawGradedPolyline(TFlash &flash, - vector &pv, + std::vector &pv, const TPixel32 &c1, const TPixel32 &c2) const; void drawGradedRegion(TFlash &flash, - vector &pv, + std::vector &pv, const TPixel32 &c1, const TPixel32 &c2, const TRegion &r) const; diff --git a/toonz/sources/common/psdlib/psd.h b/toonz/sources/common/psdlib/psd.h index e243116..1538cbe 100644 --- a/toonz/sources/common/psdlib/psd.h +++ b/toonz/sources/common/psdlib/psd.h @@ -7,7 +7,6 @@ #include "timage_io.h" #define REF_LAYER_BY_NAME -using namespace std; class TRasterImageP; diff --git a/toonz/sources/common/tapptools/tcli.cpp b/toonz/sources/common/tapptools/tcli.cpp index baac4c5..a632e9e 100644 --- a/toonz/sources/common/tapptools/tcli.cpp +++ b/toonz/sources/common/tapptools/tcli.cpp @@ -205,7 +205,7 @@ void MultiArgument::fetch(int index, int &argc, char *argv[]) //--------------------------------------------------------- UsageLine::UsageLine() - : m_elements(0), m_count(0) + : m_count(0) { } @@ -213,9 +213,6 @@ UsageLine::UsageLine() UsageLine::~UsageLine() { - if (m_elements) { - delete[] m_elements; - } } //--------------------------------------------------------- @@ -223,8 +220,8 @@ UsageLine::~UsageLine() UsageLine::UsageLine(const UsageLine &src) { m_count = src.m_count; - m_elements = new UsageElementPtr[m_count]; - ::memcpy(m_elements, src.m_elements, m_count * sizeof(m_elements[0])); + m_elements.reset(new UsageElementPtr[m_count]); + ::memcpy(m_elements.get(), src.m_elements.get(), m_count * sizeof(m_elements[0])); } //--------------------------------------------------------- @@ -232,9 +229,8 @@ UsageLine::UsageLine(const UsageLine &src) UsageLine &UsageLine::operator=(const UsageLine &src) { if (src.m_elements != m_elements) { - delete[] m_elements; - m_elements = new UsageElementPtr[src.m_count]; - ::memcpy(m_elements, src.m_elements, src.m_count * sizeof(m_elements[0])); + m_elements.reset(new UsageElementPtr[src.m_count]); + ::memcpy(m_elements.get(), src.m_elements.get(), src.m_count * sizeof(m_elements[0])); } m_count = src.m_count; return *this; @@ -245,8 +241,8 @@ UsageLine &UsageLine::operator=(const UsageLine &src) UsageLine::UsageLine(const UsageLine &src, UsageElement &elem) { m_count = src.m_count; - m_elements = new UsageElementPtr[m_count + 1]; - ::memcpy(m_elements, src.m_elements, m_count * sizeof(m_elements[0])); + m_elements.reset(new UsageElementPtr[m_count + 1]); + ::memcpy(m_elements.get(), src.m_elements.get(), m_count * sizeof(m_elements[0])); m_elements[m_count++] = &elem; } @@ -255,8 +251,8 @@ UsageLine::UsageLine(const UsageLine &src, UsageElement &elem) UsageLine::UsageLine(int count) { m_count = count; - m_elements = new UsageElementPtr[m_count]; - ::memset(m_elements, 0, m_count * sizeof(m_elements[0])); + m_elements.reset(new UsageElementPtr[m_count]); + ::memset(m_elements.get(), 0, m_count * sizeof(m_elements[0])); } //--------------------------------------------------------- @@ -264,7 +260,7 @@ UsageLine::UsageLine(int count) UsageLine::UsageLine(UsageElement &elem) { m_count = 1; - m_elements = new UsageElementPtr[m_count]; + m_elements.reset(new UsageElementPtr[m_count]); m_elements[0] = &elem; } @@ -273,7 +269,7 @@ UsageLine::UsageLine(UsageElement &elem) UsageLine::UsageLine(UsageElement &a, UsageElement &b) { m_count = 2; - m_elements = new UsageElementPtr[m_count]; + m_elements.reset(new UsageElementPtr[m_count]); m_elements[0] = &a; m_elements[1] = &b; } diff --git a/toonz/sources/common/tapptools/tcolorutils.cpp b/toonz/sources/common/tapptools/tcolorutils.cpp index e2075b3..b83d8fd 100644 --- a/toonz/sources/common/tapptools/tcolorutils.cpp +++ b/toonz/sources/common/tapptools/tcolorutils.cpp @@ -10,7 +10,7 @@ typedef float KEYER_FLOAT; //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 #define ISNAN _isnan #else extern "C" int isnan(double); diff --git a/toonz/sources/common/tapptools/tenv.cpp b/toonz/sources/common/tapptools/tenv.cpp index 6441e23..c380469 100644 --- a/toonz/sources/common/tapptools/tenv.cpp +++ b/toonz/sources/common/tapptools/tenv.cpp @@ -69,7 +69,7 @@ public: TFilePath getSystemVarPath(string varName) { -#ifdef WIN32 +#ifdef _WIN32 return m_registryRoot + varName; #else QString settingsPath = QString::fromStdString(getApplicationName()) + QString("_") + @@ -90,7 +90,7 @@ public: string getSystemVarValue(string varName) { -#ifdef WIN32 +#ifdef _WIN32 return TSystem::getSystemValue(getSystemVarPath(varName)).toStdString(); #else TFilePath systemVarPath = getSystemVarPath(varName); @@ -146,7 +146,7 @@ public: m_applicationFullName = m_applicationName + " " + m_applicationVersion; m_moduleName = m_applicationName; m_rootVarName = toUpper(m_applicationName) + "ROOT"; -#ifdef WIN32 +#ifdef _WIN32 m_registryRoot = TFilePath("SOFTWARE\\OpenToonz\\") + m_applicationName + m_applicationVersion; #endif m_systemVarPrefix = m_applicationName; diff --git a/toonz/sources/common/tapptools/ttimer.cpp b/toonz/sources/common/tapptools/ttimer.cpp index 0e631ee..7482052 100644 --- a/toonz/sources/common/tapptools/ttimer.cpp +++ b/toonz/sources/common/tapptools/ttimer.cpp @@ -3,7 +3,7 @@ #include "ttimer.h" #include "texception.h" -#ifdef WIN32 +#ifdef _WIN32 #include diff --git a/toonz/sources/common/tcache/timagecache.cpp b/toonz/sources/common/tcache/timagecache.cpp index 7b139ef..2ff378f 100644 --- a/toonz/sources/common/tcache/timagecache.cpp +++ b/toonz/sources/common/tcache/timagecache.cpp @@ -41,7 +41,7 @@ #include #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #endif @@ -121,7 +121,7 @@ public: bool m_modified; }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif typedef TSmartPointerT CacheItemP; @@ -368,7 +368,7 @@ public: TImageP m_image; }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -417,7 +417,7 @@ public: TRasterP m_compressedRas; }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -518,7 +518,7 @@ public: TFilePath m_fp; }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -587,7 +587,7 @@ public: TFilePath m_fp; }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -854,7 +854,7 @@ void TImageCache::Imp::doCompress() } string id = it->first; -#ifdef WIN32 +#ifdef _WIN32 assert(itu->first == it->second->m_historyCount); itu = m_itemHistory.erase(itu); m_itemsByImagePointer.erase(getPointer(item->getImage())); @@ -939,7 +939,7 @@ void TImageCache::Imp::doCompress(string id) return; // id not found: return // delete itu from m_itemHistory -#ifdef WIN32 +#ifdef _WIN32 assert(itu->first == it->second->m_historyCount); itu = m_itemHistory.erase(itu); m_itemsByImagePointer.erase(getPointer(item->getImage())); @@ -1044,7 +1044,7 @@ UCHAR *TImageCache::Imp::compressAndMalloc(TUINT32 size) m_compressedItems[it->first] = newItem; } -#ifdef WIN32 +#ifdef _WIN32 assert(itu->first == it->second->m_historyCount); itu = m_itemHistory.erase(itu); m_itemsByImagePointer.erase(getPointer(item->getImage())); diff --git a/toonz/sources/common/tcontenthistory.cpp b/toonz/sources/common/tcontenthistory.cpp index 6ae89fc..b4ad776 100644 --- a/toonz/sources/common/tcontenthistory.cpp +++ b/toonz/sources/common/tcontenthistory.cpp @@ -6,7 +6,7 @@ #include #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #endif #include diff --git a/toonz/sources/common/tcore/tstopwatch.cpp b/toonz/sources/common/tcore/tstopwatch.cpp index dd0cb16..6b49ee3 100644 --- a/toonz/sources/common/tcore/tstopwatch.cpp +++ b/toonz/sources/common/tcore/tstopwatch.cpp @@ -17,7 +17,7 @@ #include #ifndef STW_TICKS_PER_SECOND -#ifndef WIN32 +#ifndef _WIN32 extern "C" long sysconf(int); #define STW_TICKS_PER_SECOND sysconf(_SC_CLK_TCK) #else @@ -36,7 +36,7 @@ enum TimerType { TTUUnknown, TTUTickCount }; static void determineTimer(); -#ifdef WIN32 +#ifdef _WIN32 static TimerType timerToUse = TTUUnknown; @@ -150,7 +150,7 @@ static void checkTime(START start, START_USER startUser, START_SYSTEM startSyste { assert(timerToUse == TTUTickCount); -#ifdef WIN32 +#ifdef _WIN32 DWORD tm_stop; FILETIME creationTime, exitTime, stopSystem, stopUser; @@ -166,7 +166,7 @@ static void checkTime(START start, START_USER startUser, START_SYSTEM startSyste tmUser += FileTimeToInt64(&stopUser) - FileTimeToInt64(&startUser); //user elapsed time tmSystem += FileTimeToInt64(&stopSystem) - FileTimeToInt64(&startSystem); //system elapsed time -#else //WIN32 +#else // _WIN32 struct tms clk; clock_t tm_stop; @@ -176,12 +176,12 @@ static void checkTime(START start, START_USER startUser, START_SYSTEM startSyste tmUser += clk.tms_utime - startUser; tmSystem += clk.tms_stime - startSystem; -#endif //WIN32 +#endif // _WIN32 } //----------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 // // come checkTime, ma usa i timer ad alta risoluzione @@ -255,7 +255,7 @@ void hrCheckTime(LARGE_INTEGER start, START_USER startUser, START_SYSTEM startSy } //namespace -#endif //WIN32 +#endif // _WIN32 //----------------------------------------------------------- @@ -264,7 +264,7 @@ void TStopWatch::stop() if (!m_isRunning) return; m_isRunning = false; -#ifdef WIN32 +#ifdef _WIN32 if (timerToUse == TTUTickCount) checkTime(m_start, m_startUser, m_startSystem, m_tm, m_tmUser, m_tmSystem); else @@ -283,7 +283,7 @@ void TStopWatch::getElapsedTime(TM_TOTAL &tm, TM_USER &user, TM_SYSTEM &system) TM_USER cur_tmUser = 0; TM_SYSTEM cur_tmSystem = 0; -#ifdef WIN32 +#ifdef _WIN32 if (timerToUse == TTUTickCount) checkTime(m_start, m_startUser, m_startSystem, cur_tm, cur_tmUser, cur_tmSystem); else @@ -390,7 +390,7 @@ void TStopWatch::printGlobals() } //----------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 void dummyFunction() { diff --git a/toonz/sources/common/tcore/tstring.cpp b/toonz/sources/common/tcore/tstring.cpp index 05a8d14..b2f1c93 100644 --- a/toonz/sources/common/tcore/tstring.cpp +++ b/toonz/sources/common/tcore/tstring.cpp @@ -8,7 +8,7 @@ #include #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include "windows.h" #endif @@ -206,7 +206,7 @@ wstring toWideString(double v, int p) string toUpper(string a) { -#ifdef WIN32 +#ifdef _WIN32 return _strupr(const_cast(a.c_str())); #else string ret = a; @@ -218,7 +218,7 @@ string toUpper(string a) string toLower(string a) { -#ifdef WIN32 +#ifdef _WIN32 return _strlwr(const_cast(a.c_str())); #else string ret = a; @@ -230,7 +230,7 @@ string toLower(string a) wstring toUpper(wstring a) { -#ifdef WIN32 +#ifdef _WIN32 return _wcsupr(const_cast(a.c_str())); #else wstring ret; @@ -244,7 +244,7 @@ wstring toUpper(wstring a) wstring toLower(wstring a) { -#ifdef WIN32 +#ifdef _WIN32 return _wcslwr(const_cast(a.c_str())); #else wstring ret; diff --git a/toonz/sources/common/tfx/trenderer.cpp b/toonz/sources/common/tfx/trenderer.cpp index e61c5fc..eb3ad71 100644 --- a/toonz/sources/common/tfx/trenderer.cpp +++ b/toonz/sources/common/tfx/trenderer.cpp @@ -369,7 +369,7 @@ public: void quitWaitingLoops(); }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/common/tfx/ttzpimagefx.cpp b/toonz/sources/common/tfx/ttzpimagefx.cpp index 9779846..5a1bf92 100644 --- a/toonz/sources/common/tfx/ttzpimagefx.cpp +++ b/toonz/sources/common/tfx/ttzpimagefx.cpp @@ -11,7 +11,7 @@ void parseIndexes(string indexes, vector &items) { -#ifdef WIN32 +#ifdef _WIN32 char seps[] = " ,;"; char *token; if (indexes == "all" || indexes == "All" || indexes == "ALL") @@ -39,7 +39,7 @@ void parseIndexes(string indexes, vector &items) void insertIndexes(vector items, PaletteFilterFxRenderData *t) { -#ifdef WIN32 +#ifdef _WIN32 for (int i = 0; i < (int)items.size(); i++) { char *starttoken, *endtoken; char subseps[] = "-"; diff --git a/toonz/sources/common/tgl/tgl.cpp b/toonz/sources/common/tgl/tgl.cpp index 687fe0a..9b04bb7 100644 --- a/toonz/sources/common/tgl/tgl.cpp +++ b/toonz/sources/common/tgl/tgl.cpp @@ -9,7 +9,7 @@ #include "tcurves.h" #ifndef __sgi -#ifdef WIN32 +#ifdef _WIN32 #include #elif defined(LINUX) #include @@ -435,8 +435,7 @@ void tglDraw(const TCubic &cubic, int precision, GLenum pointOrLine) { CHECK_ERRORS_BY_GL; assert(pointOrLine == GL_POINT || pointOrLine == GL_LINE); - float(*ctrlPts)[3]; - ctrlPts = new float[4][3]; + float ctrlPts[4][3]; ctrlPts[0][0] = cubic.getP0().x; ctrlPts[0][1] = cubic.getP0().y; @@ -463,8 +462,6 @@ void tglDraw(const TCubic &cubic, int precision, GLenum pointOrLine) CHECK_ERRORS_BY_GL; glEvalMesh1(pointOrLine, 0, precision); CHECK_ERRORS_BY_GL; - - delete[] ctrlPts; } //----------------------------------------------------------------------------- @@ -669,7 +666,7 @@ void tglBuildMipmaps(std::vector &rasters, //----------------------------------------------------------------------------- //Forse si potrebbe togliere l'ifdef ed usare QT -#if defined(WIN32) +#if defined(_WIN32) TGlContext tglGetCurrentContext() { diff --git a/toonz/sources/common/tiio/bmp/filebmp.c b/toonz/sources/common/tiio/bmp/filebmp.c index c084a6b..363bf84 100644 --- a/toonz/sources/common/tiio/bmp/filebmp.c +++ b/toonz/sources/common/tiio/bmp/filebmp.c @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif diff --git a/toonz/sources/common/tiio/bmp/filebmp.h b/toonz/sources/common/tiio/bmp/filebmp.h index 56562e0..436cba2 100644 --- a/toonz/sources/common/tiio/bmp/filebmp.h +++ b/toonz/sources/common/tiio/bmp/filebmp.h @@ -7,7 +7,7 @@ extern "C" { #endif /* -#if defined(WIN32) +#if defined(_WIN32) typedef struct {unsigned char b,g,r,m;} LPIXEL; #elif defined(__sgi) typedef struct { unsigned char m,b,g,r; } LPIXEL; diff --git a/toonz/sources/common/tiio/compatibility/tfile_io.c b/toonz/sources/common/tiio/compatibility/tfile_io.c index 1995573..11c0cb5 100644 --- a/toonz/sources/common/tiio/compatibility/tfile_io.c +++ b/toonz/sources/common/tiio/compatibility/tfile_io.c @@ -2,7 +2,7 @@ #include "tfile_io.h" -#ifdef WIN32 +#ifdef _WIN32 #include #include diff --git a/toonz/sources/common/tiio/movsettings.cpp b/toonz/sources/common/tiio/movsettings.cpp index 5a52730..fb3a83f 100644 --- a/toonz/sources/common/tiio/movsettings.cpp +++ b/toonz/sources/common/tiio/movsettings.cpp @@ -13,8 +13,8 @@ // 32-bit version //******************************************************************************* -#ifdef WIN32 -#ifdef WIN32 +#ifdef _WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif @@ -299,7 +299,7 @@ static Boolean QTCmpr_FilterProc void openMovSettingsPopup(TPropertyGroup *props, bool macBringToFront) { -#ifdef WIN32 +#ifdef _WIN32 if (InitializeQTML(0) != noErr) return; #endif diff --git a/toonz/sources/common/tiio/tiio.cpp b/toonz/sources/common/tiio/tiio.cpp index f60c8b2..4c3fe02 100644 --- a/toonz/sources/common/tiio/tiio.cpp +++ b/toonz/sources/common/tiio/tiio.cpp @@ -13,7 +13,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4786) #include #endif @@ -205,7 +205,7 @@ void Tiio::defineWriterProperties(const char *ext, TPropertyGroup *prop) } /* -#ifdef WIN32 +#ifdef _WIN32 int Tiio::openForReading(char *fn) { int fd = _open(fn, _O_BINARY|_O_RDONLY); diff --git a/toonz/sources/common/tiio/tiio_bmp.cpp b/toonz/sources/common/tiio/tiio_bmp.cpp index 160de2b..3ceb903 100644 --- a/toonz/sources/common/tiio/tiio_bmp.cpp +++ b/toonz/sources/common/tiio/tiio_bmp.cpp @@ -1,9 +1,9 @@ - - -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif +#include + #include "tiio_bmp.h" // #include "bmp/filebmp.h" #include "tpixel.h" @@ -109,7 +109,7 @@ class BmpReader : public Tiio::Reader BMP_HEADER m_header; char *m_line; int m_lineSize; - TPixel *m_cmap; + std::unique_ptr m_cmap; bool m_corrupted; typedef int (BmpReader::*ReadLineMethod)(char *buffer, int x0, int x1, int shrink); ReadLineMethod m_readLineMethod; @@ -155,7 +155,9 @@ private: //--------------------------------------------------------- BmpReader::BmpReader() - : m_chan(0), m_cmap(0), m_corrupted(false), m_readLineMethod(&BmpReader::readNoLine) + : m_chan(0) + , m_corrupted(false) + , m_readLineMethod(&BmpReader::readNoLine) { memset(&m_header, 0, sizeof m_header); } @@ -164,7 +166,6 @@ BmpReader::BmpReader() BmpReader::~BmpReader() { - delete[] m_cmap; } //--------------------------------------------------------- @@ -261,8 +262,8 @@ void BmpReader::readHeader() ? m_header.biClrUsed : 1 << m_header.biBitCount; assert(cmaplen <= 256); - m_cmap = new TPixel[256]; - TPixel32 *pix = m_cmap; + m_cmap.reset(new TPixel[256]); + TPixel32 *pix = m_cmap.get(); for (int i = 0; i < cmaplen; i++) { pix->b = getc(m_chan); pix->g = getc(m_chan); diff --git a/toonz/sources/common/tiio/tiio_jpg.cpp b/toonz/sources/common/tiio/tiio_jpg.cpp index 56759a6..c8e0ee2 100644 --- a/toonz/sources/common/tiio/tiio_jpg.cpp +++ b/toonz/sources/common/tiio/tiio_jpg.cpp @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif //#include "texception.h" diff --git a/toonz/sources/common/tiio/tiio_jpg_util.cpp b/toonz/sources/common/tiio/tiio_jpg_util.cpp index f782486..5d3af09 100644 --- a/toonz/sources/common/tiio/tiio_jpg_util.cpp +++ b/toonz/sources/common/tiio/tiio_jpg_util.cpp @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif diff --git a/toonz/sources/common/timage_io/timage_io.cpp b/toonz/sources/common/timage_io/timage_io.cpp index 1ed32f2..3fd2e6b 100644 --- a/toonz/sources/common/timage_io/timage_io.cpp +++ b/toonz/sources/common/timage_io/timage_io.cpp @@ -16,7 +16,7 @@ #include // OS-specific includes -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include #endif diff --git a/toonz/sources/common/tipc/tipc.cpp b/toonz/sources/common/tipc/tipc.cpp index 3fca4bf..2eb0264 100644 --- a/toonz/sources/common/tipc/tipc.cpp +++ b/toonz/sources/common/tipc/tipc.cpp @@ -13,7 +13,7 @@ #include //System-specific includes -#ifdef WIN32 +#ifdef _WIN32 #include #elif MACOSX #include @@ -270,7 +270,7 @@ QString tipc::applicationSpecificServerName(QString srvName) bool tipc::startBackgroundProcess(QString cmdline) { -#ifdef WIN32 +#ifdef _WIN32 QProcess *proc = new QProcess; proc->start(cmdline); if (proc->state() == QProcess::NotRunning) { @@ -317,7 +317,7 @@ bool tipc::startSlaveServer(QString srvName, QString cmdline) //Wait up to msecs until the socket is connecting. Wait a small amount of time //until the server is up and listening to connection (there is no other way to tell). while (dummySock->state() == QLocalSocket::UnconnectedState) { -#ifdef WIN32 +#ifdef _WIN32 Sleep(10); #else usleep(10 << 10); //10.24 msecs diff --git a/toonz/sources/common/tmsgcore.cpp b/toonz/sources/common/tmsgcore.cpp index 888d01a..d70213c 100644 --- a/toonz/sources/common/tmsgcore.cpp +++ b/toonz/sources/common/tmsgcore.cpp @@ -140,11 +140,11 @@ void TMsgCore::readFromSocket(QTcpSocket *socket) //server side QString str = messages.at(i).simplified(); str.chop(4); //rimuovo i "#END" alla fine if (str.startsWith("ERROR")) - DVGui::MsgBox(CRITICAL, str.right(str.size() - 5)); + DVGui::error(str.right(str.size() - 5)); else if (str.startsWith("WARNING")) - DVGui::MsgBox(WARNING, str.right(str.size() - 7)); + DVGui::warning(str.right(str.size() - 7)); else if (str.startsWith("INFO")) - DVGui::MsgBox(INFORMATION, str.right(str.size() - 4)); + DVGui::info(str.right(str.size() - 4)); else assert(false); } @@ -166,13 +166,13 @@ TMsgCore::~TMsgCore() //---------------------------------- -bool TMsgCore::send(MsgType type, const QString &message) //client side +bool TMsgCore::send(DVGui::MsgType type, const QString &message) //client side { if (receivers(SIGNAL(sendMessage(int, const QString &))) == 0) { if (m_clientSocket == 0 || m_clientSocket->state() != QTcpSocket::ConnectedState) return false; - QString socketMessage = (type == CRITICAL ? "#TMSG ERROR " : (type == WARNING ? "#TMSG WARNING " : "#TMSG INFO ")) + message + " #END\n"; + QString socketMessage = (type == DVGui::CRITICAL ? "#TMSG ERROR " : (type == DVGui::WARNING ? "#TMSG WARNING " : "#TMSG INFO ")) + message + " #END\n"; #if QT_VERSION >= 0x050000 m_clientSocket->write(socketMessage.toLatin1()); @@ -213,19 +213,19 @@ void DVGui::MsgBox(MsgType type, const QString &text) void DVGui::error(const QString &msg) { - MsgBox(DVGui::CRITICAL, msg); + DVGui::MsgBox(DVGui::CRITICAL, msg); } //----------------------------------------------------------------------------- void DVGui::warning(const QString &msg) { - MsgBox(DVGui::WARNING, msg); + DVGui::MsgBox(DVGui::WARNING, msg); } //----------------------------------------------------------------------------- void DVGui::info(const QString &msg) { - MsgBox(DVGui::INFORMATION, msg); + DVGui::MsgBox(DVGui::INFORMATION, msg); } diff --git a/toonz/sources/common/traster/traster.cpp b/toonz/sources/common/traster/traster.cpp index e7f5b48..9e978a0 100644 --- a/toonz/sources/common/traster/traster.cpp +++ b/toonz/sources/common/traster/traster.cpp @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #ifndef UNICODE #define UNICODE #endif @@ -35,7 +35,7 @@ TRaster::TRaster(int lx, int ly, int pixelSize) //m_buffer = new UCHAR[lx*ly*pixelSize]; if (!m_buffer) { -#ifdef WIN32 +#ifdef _WIN32 static bool firstTime = true; if (firstTime) { firstTime = false; @@ -57,7 +57,7 @@ TRaster::TRaster(int lx, int ly, int pixelSize) m_buffer = BigMemoryManager.getMemoryChunk(lx*ly*pixelSize, this); //m_buffer = new UCHAR[lx*ly*pixelSize]; m_totalMemory += ((lx*ly*pixelSize)>>10); - #ifdef WIN32 + #ifdef _WIN32 MessageBox( NULL, "Run out of contiguos phisical memory: please save all and restart toonz!", "Warning", MB_OK); #endif }*/ @@ -296,19 +296,18 @@ void TRaster::yMirror() { const int rowSize = m_lx * m_pixelSize; const int wrapSize = m_wrap * m_pixelSize; - UCHAR *auxBuf = new UCHAR[rowSize]; + std::unique_ptr auxBuf(new UCHAR[rowSize]); lock(); UCHAR *buff1 = getRawData(); UCHAR *buff2 = getRawData(0, (m_ly - 1)); while (buff1 < buff2) { - ::memcpy(auxBuf, buff1, rowSize); + ::memcpy(auxBuf.get(), buff1, rowSize); ::memcpy(buff1, buff2, rowSize); - ::memcpy(buff2, auxBuf, rowSize); + ::memcpy(buff2, auxBuf.get(), rowSize); buff1 += wrapSize; buff2 -= wrapSize; } unlock(); - delete[] auxBuf; } //------------------------------------------------------------ @@ -317,22 +316,21 @@ void TRaster::xMirror() { const int wrapSize = m_wrap * m_pixelSize; const int lastPixelOffset = (m_lx - 1) * m_pixelSize; - UCHAR *auxBuf = new UCHAR[m_pixelSize]; + std::unique_ptr auxBuf(new UCHAR[m_pixelSize]); lock(); UCHAR *row = getRawData(); for (int i = 0; i < m_ly; i++) { UCHAR *a = row, *b = row + lastPixelOffset; while (a < b) { - ::memcpy(auxBuf, a, m_pixelSize); + ::memcpy(auxBuf.get(), a, m_pixelSize); ::memcpy(a, b, m_pixelSize); - ::memcpy(b, auxBuf, m_pixelSize); + ::memcpy(b, auxBuf.get(), m_pixelSize); a += m_pixelSize; b -= m_pixelSize; } row += wrapSize; } unlock(); - delete[] auxBuf; } //------------------------------------------------------------ @@ -341,15 +339,15 @@ void TRaster::rotate180() { //const int rowSize = m_lx * m_pixelSize; const int wrapSize = m_wrap * m_pixelSize; - UCHAR *auxBuf = new UCHAR[m_pixelSize]; + std::unique_ptr auxBuf(new UCHAR[m_pixelSize]); lock(); UCHAR *buff1 = getRawData(); UCHAR *buff2 = buff1 + wrapSize * (m_ly - 1) + m_pixelSize * (m_lx - 1); if (m_wrap == m_lx) { while (buff1 < buff2) { - ::memcpy(auxBuf, buff1, m_pixelSize); + ::memcpy(auxBuf.get(), buff1, m_pixelSize); ::memcpy(buff1, buff2, m_pixelSize); - ::memcpy(buff2, auxBuf, m_pixelSize); + ::memcpy(buff2, auxBuf.get(), m_pixelSize); buff1 += m_pixelSize; buff2 -= m_pixelSize; } @@ -357,9 +355,9 @@ void TRaster::rotate180() for (int y = 0; y < m_ly / 2; y++) { UCHAR *a = buff1, *b = buff2; for (int x = 0; x < m_lx; x++) { - ::memcpy(auxBuf, a, m_pixelSize); + ::memcpy(auxBuf.get(), a, m_pixelSize); ::memcpy(a, b, m_pixelSize); - ::memcpy(b, auxBuf, m_pixelSize); + ::memcpy(b, auxBuf.get(), m_pixelSize); a += m_pixelSize; b -= m_pixelSize; } @@ -368,7 +366,6 @@ void TRaster::rotate180() } } unlock(); - delete[] auxBuf; } //------------------------------------------------------------ diff --git a/toonz/sources/common/trop/brush.cpp b/toonz/sources/common/trop/brush.cpp index eb335db..f716657 100644 --- a/toonz/sources/common/trop/brush.cpp +++ b/toonz/sources/common/trop/brush.cpp @@ -1,3 +1,4 @@ +#include #include #include "trop.h" @@ -6,16 +7,16 @@ class HalfCord { - int *m_array; + std::unique_ptr m_array; int m_radius; public: HalfCord(int radius) + : m_radius(radius) + , m_array(new int[radius + 1]) { assert(radius >= 0); - m_radius = radius; - m_array = new int[m_radius + 1]; - memset(m_array, 0, (m_radius + 1) * sizeof(int)); + memset(m_array.get(), 0, (m_radius + 1) * sizeof(int)); float dCircle = 1.25f - m_radius; // inizializza decision variable int y = m_radius; // inizializzazione indice scanline @@ -34,10 +35,6 @@ public: } while (y >= x); } - ~HalfCord() - { - delete[] m_array; - } inline int getCord(int x) { assert(0 <= x && x <= m_radius); diff --git a/toonz/sources/common/trop/quickput.cpp b/toonz/sources/common/trop/quickput.cpp index 041e6d2..af70c07 100644 --- a/toonz/sources/common/trop/quickput.cpp +++ b/toonz/sources/common/trop/quickput.cpp @@ -3941,9 +3941,9 @@ void doQuickResampleFilter_optimized( UINT32 gColUpTmp; UINT32 bColUpTmp; - register unsigned char rCol; - register unsigned char gCol; - register unsigned char bCol; + unsigned char rCol; + unsigned char gCol; + unsigned char bCol; int xI; int yI; @@ -4209,9 +4209,9 @@ void doQuickResampleFilter_optimized( int xWeight1; int xWeight0; - register unsigned char rCol; - register unsigned char gCol; - register unsigned char bCol; + unsigned char rCol; + unsigned char gCol; + unsigned char bCol; int xL; int yI; diff --git a/toonz/sources/common/trop/runsmap.h b/toonz/sources/common/trop/runsmap.h index 04e057a..5d33dd4 100644 --- a/toonz/sources/common/trop/runsmap.h +++ b/toonz/sources/common/trop/runsmap.h @@ -52,7 +52,7 @@ public: //--------------------------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif diff --git a/toonz/sources/common/trop/tblur.cpp b/toonz/sources/common/trop/tblur.cpp index 1fb3544..e256d76 100644 --- a/toonz/sources/common/trop/tblur.cpp +++ b/toonz/sources/common/trop/tblur.cpp @@ -3,7 +3,7 @@ #include "traster.h" #include "trop.h" #include "tpixelgr.h" -#ifdef WIN32 +#ifdef _WIN32 #include #include #endif @@ -11,7 +11,7 @@ namespace { -#ifdef WIN32 +#ifdef _WIN32 template struct BlurPixel { T b; @@ -231,7 +231,7 @@ inline void blur_code( //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 //------------------------------------------------------------------- template @@ -484,7 +484,7 @@ inline void blur_code_SSE2( } } -#endif // WIN32 +#endif // _WIN32 //------------------------------------------------------------------- @@ -574,7 +574,7 @@ template void do_filtering_chan(BlurPixel

*row1, T *row2, int length, float coeff, float coeffq, int brad, float diff, bool useSSE) { -#ifdef WIN32 +#ifdef _WIN32 if (useSSE && T::maxChannelValue == 255) blur_code_SSE2(row1, row2, length, coeff, coeffq, brad, diff, 0.5); else @@ -769,7 +769,7 @@ void do_filtering_floatRgb(T *row1, BlurPixel

*row2, int length, BLUR_CODE(0, unsigned char) */ -#ifdef WIN32 +#ifdef _WIN32 if (useSSE) blur_code_SSE2(row1, row2, length, coeff, coeffq, brad, diff, 0); else @@ -805,7 +805,7 @@ void doBlurRgb(TRasterPT &dstRas, TRasterPT &srcRas, double blur, int dx, BlurPixel

*row2, *col1, *fbuffer; TRasterGR8P r1; -#ifdef WIN32 +#ifdef _WIN32 if (useSSE) { fbuffer = (BlurPixel

*)_aligned_malloc(llx * ly * sizeof(BlurPixel

), 16); row1 = (T *)_aligned_malloc((llx + 2 * brad) * sizeof(T), 16); @@ -853,7 +853,7 @@ void doBlurRgb(TRasterPT &dstRas, TRasterPT &srcRas, double blur, int dx, dstRas->clear(); } -#ifdef WIN32 +#ifdef _WIN32 if (useSSE) { _aligned_free(col2); _aligned_free(col1); @@ -866,7 +866,6 @@ void doBlurRgb(TRasterPT &dstRas, TRasterPT &srcRas, double blur, int dx, delete[] col1; delete[] row1; r1->unlock(); - //delete[]fbuffer; } } diff --git a/toonz/sources/common/trop/tconvolve.cpp b/toonz/sources/common/trop/tconvolve.cpp index 909e2d3..4758b53 100644 --- a/toonz/sources/common/trop/tconvolve.cpp +++ b/toonz/sources/common/trop/tconvolve.cpp @@ -304,8 +304,8 @@ void doConvolve_i(TRasterPT rout, PIXOUT *pixout; int radiusSquare = sq(radius); - PIXIN **pixarr = new PIXIN *[radiusSquare]; - long *w = new long[radiusSquare]; + std::unique_ptr pixarr(new PIXIN *[radiusSquare]); + std::unique_ptr w(new long[radiusSquare]); int pixn; int wrapin, wrapout; int x, y, n; @@ -356,7 +356,7 @@ void doConvolve_i(TRasterPT rout, pixn++; } - doConvolve_row_i(pixout, n, pixarr, w, pixn); + doConvolve_row_i(pixout, n, pixarr.get(), w.get(), pixn); x += n; pixin += n; @@ -366,9 +366,6 @@ void doConvolve_i(TRasterPT rout, rin->unlock(); rout->unlock(); - - delete[] w; - delete[] pixarr; } //------------------------------------------------------------------------------ @@ -465,8 +462,8 @@ void doConvolve_cm32_i(TRasterPT rout, TPixelCM32 *pixin; PIXOUT *pixout; int radiusSquare = sq(radius); - TPixelCM32 **pixarr = new TPixelCM32 *[radiusSquare]; - long *w = new long[radiusSquare]; + std::unique_ptr pixarr(new TPixelCM32*[radiusSquare]); + std::unique_ptr w(new long[radiusSquare]); int pixn; int wrapin, wrapout; int x, y, n; @@ -526,7 +523,7 @@ void doConvolve_cm32_i(TRasterPT rout, pixn++; } - doConvolve_cm32_row_i(pixout, n, pixarr, w, pixn, paints, inks); + doConvolve_cm32_row_i(pixout, n, pixarr.get(), w.get(), pixn, paints, inks); x += n; pixin += n; @@ -536,9 +533,6 @@ void doConvolve_cm32_i(TRasterPT rout, rin->unlock(); rout->unlock(); - - delete[] pixarr; - delete[] w; } } // anonymous namespace diff --git a/toonz/sources/common/trop/toperators.cpp b/toonz/sources/common/trop/toperators.cpp index 4ef1fc8..384843c 100644 --- a/toonz/sources/common/trop/toperators.cpp +++ b/toonz/sources/common/trop/toperators.cpp @@ -4,7 +4,7 @@ #include "tpixel.h" #include "tpixelutils.h" -#ifdef WIN32 +#ifdef _WIN32 #include // per SSE2 #endif diff --git a/toonz/sources/common/trop/tover.cpp b/toonz/sources/common/trop/tover.cpp index 7346382..41dfb12 100644 --- a/toonz/sources/common/trop/tover.cpp +++ b/toonz/sources/common/trop/tover.cpp @@ -7,7 +7,7 @@ #include "tropcm.h" #include "tpalette.h" -#ifdef WIN32 +#ifdef _WIN32 #include // per SSE2 #endif @@ -171,7 +171,7 @@ void do_overT2(TRasterPT rout, const TRasterPT &rup) //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 void do_over_SSE2(TRaster32P rout, const TRaster32P &rup) { @@ -345,7 +345,7 @@ void TRop::over(const TRasterP &rout, const TRasterP &rup, const TPoint &pos) // TRaster64P rout64 = rout, rin64 = rin; if (rout32 && rup32) { -#ifdef WIN32 +#ifdef _WIN32 if (TSystem::getCPUExtensions() & TSystem::CpuSupportsSse2) do_over_SSE2(rout32, rup32); else diff --git a/toonz/sources/common/trop/tresample.cpp b/toonz/sources/common/trop/tresample.cpp index 3051bab..4cf9735 100644 --- a/toonz/sources/common/trop/tresample.cpp +++ b/toonz/sources/common/trop/tresample.cpp @@ -18,7 +18,7 @@ using namespace TConsts; -#ifdef WIN32 +#ifdef _WIN32 #include // per SSE2 #endif @@ -841,7 +841,7 @@ inline void calcValueNoCalc(UINT &calc_value){ //#define PIXVAL_EQ PIXVAL_EQ_EQUAL template -#ifdef WIN32 +#ifdef _WIN32 __forceinline #endif void @@ -861,7 +861,7 @@ wrap_in = wrap UINT calc_value; UCHAR *calc_byte = 0; int goodcols; - int *col_height = new int[lu]; + std::unique_ptr col_height(new int[lu]); int ref_u, ref_v; int filter_diam_u = max_pix_ref_u - min_pix_ref_u + 1; int filter_diam_v = max_pix_ref_v - min_pix_ref_v + 1; @@ -873,7 +873,7 @@ wrap_in = wrap assert(col_height); CALC_VALUE_INIT - ch = col_height; + ch = col_height.get(); ch_end = ch + lu; while (ch < ch_end) { @@ -985,9 +985,6 @@ wrap_in = wrap } } assert(!calc_byte || calc_byte == calc + calc_bytesize); - - if (col_height) - delete[] col_height; } /*---------------------------------------------------------------------------*/ @@ -1511,7 +1508,7 @@ void resample_main_rgbm(TRasterPT rout, const TRasterPT &rin, //--------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 namespace { @@ -1808,7 +1805,7 @@ void inline blendBySSE2(__m128 &pix_out_packed, } // namespace -#endif // WIN32 +#endif // _WIN32 //--------------------------------------------------------------------------- static void get_prow_gr8(const TRasterGR8P &rin, @@ -2434,26 +2431,26 @@ void rop_resample_rgbm(TRasterPT rout, const TRasterPT &rin, #ifdef USE_STATIC_VARS static TRop::ResampleFilterType current_flt_type = TRop::None; - static short *filter_array = 0; + static std::unique_ptr filter_array; static short *filter = 0; static int min_filter_fg, max_filter_fg; static int filter_array_size = 0; static int n_pix = 0; - static int *pix_ref_u = 0; - static int *pix_ref_v = 0; - static int *pix_ref_f = 0; - static int *pix_ref_g = 0; + static std::unique_ptr pix_ref_u; + static std::unique_ptr pix_ref_v; + static std::unique_ptr pix_ref_f; + static std::unique_ptr pix_ref_g; static int current_max_n_pix = 0; #else - short *filter_array = 0; + std::unique_ptr filter_array; short *filter = 0; int min_filter_fg, max_filter_fg; int filter_array_size = 0; int n_pix = 0; - int *pix_ref_u = 0; - int *pix_ref_v = 0; - int *pix_ref_f = 0; - int *pix_ref_g = 0; + std::unique_ptr pix_ref_u; + std::unique_ptr pix_ref_v; + std::unique_ptr pix_ref_f; + std::unique_ptr pix_ref_g; int current_max_n_pix = 0; #endif int filter_st_radius; @@ -2581,18 +2578,10 @@ void rop_resample_rgbm(TRasterPT rout, const TRasterPT &rin, if (max_n_pix > current_max_n_pix) { current_max_n_pix = max_n_pix; - if (pix_ref_u) - delete[] pix_ref_u; - pix_ref_u = new int[current_max_n_pix]; - if (pix_ref_v) - delete[] pix_ref_v; - pix_ref_v = new int[current_max_n_pix]; - if (pix_ref_f) - delete[] pix_ref_f; //These will provide the images of the formers - pix_ref_f = new int[current_max_n_pix]; - if (pix_ref_g) - delete[] pix_ref_g; - pix_ref_g = new int[current_max_n_pix]; + pix_ref_u.reset(new int[current_max_n_pix]); + pix_ref_v.reset(new int[current_max_n_pix]); + pix_ref_f.reset(new int[current_max_n_pix]); + pix_ref_g.reset(new int[current_max_n_pix]); assert(pix_ref_u && pix_ref_v && pix_ref_f && pix_ref_g); } @@ -2620,16 +2609,6 @@ void rop_resample_rgbm(TRasterPT rout, const TRasterPT &rin, n_pix = 0; if (!pix_ref_u || !pix_ref_v || !pix_ref_f || !pix_ref_g) { -#ifndef USE_STATIC_VARS - if (pix_ref_u) - delete[] pix_ref_u; - if (pix_ref_v) - delete[] pix_ref_v; - if (pix_ref_f) - delete[] pix_ref_f; - if (pix_ref_g) - delete[] pix_ref_g; -#endif throw TRopException("tresample.cpp line2640 function rop_resample_rgbm() : alloc pix_ref failed"); } @@ -2687,13 +2666,11 @@ void rop_resample_rgbm(TRasterPT rout, const TRasterPT &rin, filter_size = max_filter_fg - min_filter_fg + 1; if (filter_size > filter_array_size) //For the static vars case... { - if (filter_array) - delete[] filter_array; - filter_array = new short[filter_size]; + filter_array.reset(new short[filter_size]); assert(filter_array); filter_array_size = filter_size; } - filter = filter_array - min_filter_fg; //Take the position corresponding to fg's (0,0) in the array + filter = filter_array.get() - min_filter_fg; //Take the position corresponding to fg's (0,0) in the array filter[0] = MAX_FILTER_VAL; for (f = 1, s_ = 1.0 / FILTER_RESOLUTION; f < filter_fg_radius; @@ -2722,14 +2699,12 @@ void rop_resample_rgbm(TRasterPT rout, const TRasterPT &rin, if (filter_size > filter_array_size) { //controllare!! //TREALLOC (filter_array, filter_size) - if (filter_array) - delete[] filter_array; - filter_array = new short[filter_size]; + filter_array.reset(new short[filter_size]); assert(filter_array); filter_array_size = filter_size; } - filter = filter_array - min_filter_fg; + filter = filter_array.get() - min_filter_fg; if (min_pix_out_fg < min_filter_fg) { int delta = min_filter_fg - min_pix_out_fg; @@ -2747,14 +2722,14 @@ void rop_resample_rgbm(TRasterPT rout, const TRasterPT &rin, } } -#ifdef WIN32 +#ifdef _WIN32 if ((TSystem::getCPUExtensions() & TSystem::CpuSupportsSse2) && T::maxChannelValue == 255) resample_main_rgbm_SSE2(rout, rin, aff_xy2uv, aff0_uv2fg, min_pix_ref_u, min_pix_ref_v, max_pix_ref_u, max_pix_ref_v, n_pix, - pix_ref_u, pix_ref_v, - pix_ref_f, pix_ref_g, + pix_ref_u.get(), pix_ref_v.get(), + pix_ref_f.get(), pix_ref_g.get(), filter); else #endif @@ -2764,8 +2739,8 @@ void rop_resample_rgbm(TRasterPT rout, const TRasterPT &rin, min_pix_ref_u, min_pix_ref_v, max_pix_ref_u, max_pix_ref_v, n_pix, - pix_ref_u, pix_ref_v, - pix_ref_f, pix_ref_g, + pix_ref_u.get(), pix_ref_v.get(), + pix_ref_f.get(), pix_ref_g.get(), filter); else resample_main_rgbm( @@ -2773,23 +2748,10 @@ void rop_resample_rgbm(TRasterPT rout, const TRasterPT &rin, min_pix_ref_u, min_pix_ref_v, max_pix_ref_u, max_pix_ref_v, n_pix, - pix_ref_u, pix_ref_v, - pix_ref_f, pix_ref_g, + pix_ref_u.get(), pix_ref_v.get(), + pix_ref_f.get(), pix_ref_g.get(), filter); -#ifndef USE_STATIC_VARS - if (filter_array) - delete[] filter_array; - if (pix_ref_u) - delete[] pix_ref_u; - if (pix_ref_v) - delete[] pix_ref_v; - if (pix_ref_f) - delete[] pix_ref_f; - if (pix_ref_g) - delete[] pix_ref_g; -#endif - ///////////////////////////////////////////////////////// // INIZIO GESTIONE ALTRI TIPI RASTER DA IMPLEMENTARE ///////////////////////////////////////////////////////// @@ -3651,7 +3613,7 @@ void do_resample(TRasterCM32P rout, const TRasterCM32P &rin, const TAffine &aff) //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template void resample_main_cm32_rgbm_SSE2(TRasterPT rout, const TRasterCM32P &rin, const TAffine &aff_xy2uv, @@ -4832,26 +4794,26 @@ void rop_resample_rgbm_2(TRasterPT rout, const TRasterCM32P &rin, #ifdef USE_STATIC_VARS static TRop::ResampleFilterType current_flt_type = TRop::None; - static short *filter_array = 0; + static std::unique_ptr filter_array; static short *filter = 0; static int min_filter_fg, max_filter_fg; static int filter_array_size = 0; static int n_pix = 0; - static int *pix_ref_u = 0; - static int *pix_ref_v = 0; - static int *pix_ref_f = 0; - static int *pix_ref_g = 0; + static std::unique_ptr pix_ref_u; + static std::unique_ptr pix_ref_v; + static std::unique_ptr pix_ref_f; + static std::unique_ptr pix_ref_g; static int current_max_n_pix = 0; #else - short *filter_array = 0; + std::unique_ptr filter_array; short *filter = 0; int min_filter_fg, max_filter_fg; int filter_array_size = 0; int n_pix = 0; - int *pix_ref_u = 0; - int *pix_ref_v = 0; - int *pix_ref_f = 0; - int *pix_ref_g = 0; + std::unique_ptr pix_ref_u; + std::unique_ptr pix_ref_v; + std::unique_ptr pix_ref_f; + std::unique_ptr pix_ref_g; int current_max_n_pix = 0; #endif @@ -4958,18 +4920,10 @@ void rop_resample_rgbm_2(TRasterPT rout, const TRasterCM32P &rin, if (max_n_pix > current_max_n_pix) { current_max_n_pix = max_n_pix; - if (pix_ref_u) - delete[] pix_ref_u; - pix_ref_u = new int[current_max_n_pix]; - if (pix_ref_v) - delete[] pix_ref_v; - pix_ref_v = new int[current_max_n_pix]; - if (pix_ref_f) - delete[] pix_ref_f; - pix_ref_f = new int[current_max_n_pix]; - if (pix_ref_g) - delete[] pix_ref_g; - pix_ref_g = new int[current_max_n_pix]; + pix_ref_u.reset(new int[current_max_n_pix]); + pix_ref_v.reset(new int[current_max_n_pix]); + pix_ref_f.reset(new int[current_max_n_pix]); + pix_ref_g.reset(new int[current_max_n_pix]); assert(pix_ref_u && pix_ref_v && pix_ref_f && pix_ref_g); } @@ -5025,13 +4979,11 @@ void rop_resample_rgbm_2(TRasterPT rout, const TRasterCM32P &rin, max_filter_fg = filter_fg_radius + FILTER_RESOLUTION * 3 / 2; filter_size = max_filter_fg - min_filter_fg + 1; if (filter_size > filter_array_size) { - if (filter_array) - delete[] filter_array; - filter_array = new short[filter_size]; + filter_array.reset(new short[filter_size]); assert(filter_array); filter_array_size = filter_size; } - filter = filter_array - min_filter_fg; + filter = filter_array.get() - min_filter_fg; filter[0] = MAX_FILTER_VAL; for (f = 1, s_ = 1.0 / FILTER_RESOLUTION; f < filter_fg_radius; @@ -5057,14 +5009,12 @@ void rop_resample_rgbm_2(TRasterPT rout, const TRasterCM32P &rin, if (filter_size > filter_array_size) { //controllare!! //TREALLOC (filter_array, filter_size) - if (filter_array) - delete[] filter_array; - filter_array = new short[filter_size]; + filter_array.reset(new short[filter_size]); assert(filter_array); filter_array_size = filter_size; } - filter = filter_array - min_filter_fg; + filter = filter_array.get() - min_filter_fg; if (min_pix_out_fg < min_filter_fg) { int delta = min_filter_fg - min_pix_out_fg; @@ -5082,15 +5032,15 @@ void rop_resample_rgbm_2(TRasterPT rout, const TRasterCM32P &rin, } } -#ifdef WIN32 +#ifdef _WIN32 TRaster32P rout32 = rout; if ((TSystem::getCPUExtensions() & TSystem::CpuSupportsSse2) && rout32) resample_main_cm32_rgbm_SSE2(rout32, rin, aff_xy2uv, aff0_uv2fg, min_pix_ref_u, min_pix_ref_v, max_pix_ref_u, max_pix_ref_v, n_pix, - pix_ref_u, pix_ref_v, - pix_ref_f, pix_ref_g, + pix_ref_u.get(), pix_ref_v.get(), + pix_ref_f.get(), pix_ref_g.get(), filter, palette); else #endif @@ -5098,23 +5048,10 @@ void rop_resample_rgbm_2(TRasterPT rout, const TRasterCM32P &rin, min_pix_ref_u, min_pix_ref_v, max_pix_ref_u, max_pix_ref_v, n_pix, - pix_ref_u, pix_ref_v, - pix_ref_f, pix_ref_g, + pix_ref_u.get(), pix_ref_v.get(), + pix_ref_f.get(), pix_ref_g.get(), filter, palette); -#ifndef USE_STATIC_VARS - if (filter_array) - delete[] filter_array; - if (pix_ref_u) - delete[] pix_ref_u; - if (pix_ref_v) - delete[] pix_ref_v; - if (pix_ref_f) - delete[] pix_ref_f; - if (pix_ref_g) - delete[] pix_ref_g; -#endif - ///////////////////////////////////////////////////////// // INIZIO GESTIONE ALTRI TIPI RASTER DA IMPLEMENTARE ///////////////////////////////////////////////////////// diff --git a/toonz/sources/common/trop/tropcm.cpp b/toonz/sources/common/trop/tropcm.cpp index 8cfc930..f7c6911 100644 --- a/toonz/sources/common/trop/tropcm.cpp +++ b/toonz/sources/common/trop/tropcm.cpp @@ -22,7 +22,7 @@ extern "C" { #include "toonz4.6/raster.h" } -#ifdef WIN32 +#ifdef _WIN32 #define USE_SSE2 #endif @@ -78,7 +78,7 @@ void TRop::convert(const TRaster32P &rasOut, rasOut->lock(); rasIn->lock(); -#ifdef WIN32 +#ifdef _WIN32 if (TSystem::getCPUExtensions() & TSystem::CpuSupportsSse2) { __m128i zeros = _mm_setzero_si128(); TPixelFloat *paints = (TPixelFloat *)_aligned_malloc(count2 * sizeof(TPixelFloat), 16); @@ -171,7 +171,7 @@ void TRop::convert(const TRaster32P &rasOut, _aligned_free(inks); } else // SSE2 not supported -#endif // WIN32 +#endif // _WIN32 { std::vector paints(count2, TPixel32(255, 0, 0)); diff --git a/toonz/sources/common/tsound/tsound_nt.cpp b/toonz/sources/common/tsound/tsound_nt.cpp index 80a4908..bcdb147 100644 --- a/toonz/sources/common/tsound/tsound_nt.cpp +++ b/toonz/sources/common/tsound/tsound_nt.cpp @@ -2210,13 +2210,13 @@ bool setSrcMixMuxControl(MIXERCONTROL mxc, DWORD componentTypeSrc) // determino l'indice dell'item corrispondente alla linea sorgente // di tipo componentTypeSrc - MIXERCONTROLDETAILS_LISTTEXT *pmxcdSelectText = - new MIXERCONTROLDETAILS_LISTTEXT[dwMultipleItems]; + std::unique_ptr + pmxcdSelectText(new MIXERCONTROLDETAILS_LISTTEXT[dwMultipleItems]); - if (pmxcdSelectText != NULL) { + if (pmxcdSelectText) { // estraggo le info su tutte le linee associate al controllo ret = getControlDetails((HMIXEROBJ)0, dwSelectControlID, - dwMultipleItems, pmxcdSelectText); + dwMultipleItems, pmxcdSelectText.get()); if (ret == MMSYSERR_NOERROR) { for (DWORD dwi = 0; dwi < dwMultipleItems; dwi++) { @@ -2231,8 +2231,6 @@ bool setSrcMixMuxControl(MIXERCONTROL mxc, DWORD componentTypeSrc) } } - delete[] pmxcdSelectText; - if (!found) return false; } @@ -2242,11 +2240,11 @@ bool setSrcMixMuxControl(MIXERCONTROL mxc, DWORD componentTypeSrc) bool bRetVal = false; - MIXERCONTROLDETAILS_BOOLEAN *pmxcdSelectValue = - new MIXERCONTROLDETAILS_BOOLEAN[dwMultipleItems]; + std::unique_ptr + pmxcdSelectValue(new MIXERCONTROLDETAILS_BOOLEAN[dwMultipleItems]); - if (pmxcdSelectValue != NULL) { - ::ZeroMemory(pmxcdSelectValue, dwMultipleItems * sizeof(MIXERCONTROLDETAILS_BOOLEAN)); + if (pmxcdSelectValue) { + ::ZeroMemory(pmxcdSelectValue.get(), dwMultipleItems * sizeof(MIXERCONTROLDETAILS_BOOLEAN)); // impostazione del valore pmxcdSelectValue[dwIndexLine].fValue = (TINT32)1; // lVal; //dovrebbe esser uno @@ -2254,11 +2252,9 @@ bool setSrcMixMuxControl(MIXERCONTROL mxc, DWORD componentTypeSrc) ret = setControlDetails((HMIXEROBJ)0, dwSelectControlID, dwMultipleItems, - pmxcdSelectValue); + pmxcdSelectValue.get()); if (ret == MMSYSERR_NOERROR) bRetVal = true; - - delete[] pmxcdSelectValue; } return bRetVal; } diff --git a/toonz/sources/common/tsystem/cpuextensions.cpp b/toonz/sources/common/tsystem/cpuextensions.cpp index 5920ef4..8423513 100644 --- a/toonz/sources/common/tsystem/cpuextensions.cpp +++ b/toonz/sources/common/tsystem/cpuextensions.cpp @@ -1,7 +1,7 @@ #include "tsystem.h" -#ifdef WIN32 +#ifdef _WIN32 #include #include #include @@ -16,7 +16,7 @@ long TSystem::getCPUExtensions() } #else -#ifndef WIN32 +#ifndef _WIN32 long TSystem::getCPUExtensions() { return TSystem::CPUExtensionsNone; @@ -29,7 +29,7 @@ long CPUExtensionsAvailable = TSystem::CPUExtensionsNone; bool CPUExtensionsEnabled = true; bool FistTime = true; -//#ifdef WIN32 +//#ifdef _WIN32 //------------------------------------------------------------------------------ diff --git a/toonz/sources/common/tsystem/tfilepath.cpp b/toonz/sources/common/tsystem/tfilepath.cpp index ff579d0..df7705b 100644 --- a/toonz/sources/common/tsystem/tfilepath.cpp +++ b/toonz/sources/common/tsystem/tfilepath.cpp @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 //#define UNICODE // per le funzioni di conversione da/a UNC #include #include @@ -128,7 +128,7 @@ bool isUncName = false; pos=2; if(path.length()==2 || !isSlash(path[pos])) m_path.append(1,slash); } -#ifdef WIN32 +#ifdef _WIN32 else //se si tratta di un path in formato UNC e' del tipo "\\\\MachineName" //RICONTROLLARE! SE SI HA IP ADDRESS FALLIVA! if (path.length() >= 3 && path[0] == '\\' && path[1] == '\\' && (isalpha(path[2]) || isdigit(path[2])) ) @@ -287,7 +287,7 @@ TFilePath::TFilePath(const QString &path) bool TFilePath::operator==(const TFilePath &fp) const { -#ifdef WIN32 +#ifdef _WIN32 return _wcsicmp(m_path.c_str(), fp.m_path.c_str()) == 0; #else return m_path == fp.m_path; @@ -304,7 +304,7 @@ bool TFilePath::operator<(const TFilePath &fp) const int i2 = m_path.find(L"\\"); int j2 = fp.m_path.find(L"\\"); if (i2 == j2 && j2 == -1) -#ifdef WIN32 +#ifdef _WIN32 return _wcsicmp(m_path.c_str(), fp.m_path.c_str()) < 0; #else return m_path < fp.m_path; @@ -323,7 +323,7 @@ bool TFilePath::operator<(const TFilePath &fp) const jName = (j2 != -1) ? fp.m_path.substr(j1, j2 - j1) : fp.m_path; //se le due parti di path, conpresi tra slash sono uguali //itero il processo di confronto altrimenti ritorno -#ifdef WIN32 +#ifdef _WIN32 char differ; differ = _wcsicmp(iName.c_str(), jName.c_str()); if (differ != 0) @@ -340,7 +340,7 @@ bool TFilePath::operator<(const TFilePath &fp) const iName = m_path.substr(i1, m_path.size() - i1); jName = fp.m_path.substr(j1, fp.m_path.size() - j1); -#ifdef WIN32 +#ifdef _WIN32 return _wcsicmp(iName.c_str(), jName.c_str()) < 0; #else return TFilePath(iName) < TFilePath(jName); diff --git a/toonz/sources/common/tsystem/tfilepath_io.cpp b/toonz/sources/common/tsystem/tfilepath_io.cpp index d6ff84d..7a5c410 100644 --- a/toonz/sources/common/tsystem/tfilepath_io.cpp +++ b/toonz/sources/common/tsystem/tfilepath_io.cpp @@ -11,7 +11,7 @@ #include using namespace std; -#ifdef WIN32 +#ifdef _WIN32 #include #include diff --git a/toonz/sources/common/tsystem/tpluginmanager.cpp b/toonz/sources/common/tsystem/tpluginmanager.cpp index 0e002aa..b30f191 100644 --- a/toonz/sources/common/tsystem/tpluginmanager.cpp +++ b/toonz/sources/common/tsystem/tpluginmanager.cpp @@ -5,7 +5,7 @@ #include "tconvert.h" #include "tlogger.h" -#ifdef WIN32 +#ifdef _WIN32 #include #else @@ -34,7 +34,7 @@ class TPluginManager::Plugin { public: -#ifdef WIN32 +#ifdef _WIN32 typedef HINSTANCE Handle; #else typedef void *Handle; @@ -65,7 +65,7 @@ typedef const TPluginInfo *TnzLibMainProcType(); namespace { const char *TnzLibMainProcName = "TLibMain"; -#if !defined(WIN32) +#if !defined(_WIN32) const char *TnzLibMainProcName2 = "_TLibMain"; #endif } @@ -107,7 +107,7 @@ void TPluginManager::unloadPlugins() it != m_pluginTable.end(); ++it) { Plugin::Handle handle = (*it)->getHandle(); #ifndef LINUX -#ifdef WIN32 +#ifdef _WIN32 FreeLibrary(handle); #else dlclose(handle); @@ -133,7 +133,7 @@ void TPluginManager::loadPlugin(const TFilePath &fp) } TLogger::debug() << "Loading " << fp; -#ifdef WIN32 +#ifdef _WIN32 Plugin::Handle handle = LoadLibraryW(fp.getWideString().c_str()); #else wstring str_fp = fp.getWideString(); @@ -142,7 +142,7 @@ void TPluginManager::loadPlugin(const TFilePath &fp) if (!handle) { // non riesce a caricare la libreria; TLogger::warning() << "Unable to load " << fp; -#ifdef WIN32 +#ifdef _WIN32 wstring getFormattedMessage(DWORD lastError); TLogger::warning() << toString(getFormattedMessage(GetLastError())); #else @@ -154,7 +154,7 @@ void TPluginManager::loadPlugin(const TFilePath &fp) m_pluginTable.push_back(plugin); //cout << "loaded" << endl; TnzLibMainProcType *tnzLibMain = 0; -#ifdef WIN32 +#ifdef _WIN32 tnzLibMain = (TnzLibMainProcType *) GetProcAddress(handle, TnzLibMainProcName); #else @@ -168,7 +168,7 @@ void TPluginManager::loadPlugin(const TFilePath &fp) // La libreria non esporta TLibMain; TLogger::warning() << "Corrupted " << fp; -#ifdef WIN32 +#ifdef _WIN32 FreeLibrary(handle); #else dlclose(handle); @@ -185,7 +185,7 @@ void TPluginManager::loadPlugin(const TFilePath &fp) void TPluginManager::loadPlugins(const TFilePath &dir) { -#if defined(WIN32) +#if defined(_WIN32) const string extension = "dll"; #elif defined(LINUX) || defined(__sgi) const string extension = "so"; @@ -204,7 +204,7 @@ void TPluginManager::loadPlugins(const TFilePath &dir) continue; wstring fullpath = fp.getWideString(); -#ifdef WIN32 +#ifdef _WIN32 bool isDebugLibrary = (fullpath.find(L".d.") == fullpath.size() - (extension.size() + 3)); diff --git a/toonz/sources/common/tsystem/tsystem.cpp b/toonz/sources/common/tsystem/tsystem.cpp index 1ceb34f..019687e 100644 --- a/toonz/sources/common/tsystem/tsystem.cpp +++ b/toonz/sources/common/tsystem/tsystem.cpp @@ -23,7 +23,7 @@ using namespace std; #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #include @@ -165,7 +165,7 @@ QString TSystem::getUserName() for (j = 0; j < list.size(); j++) { QString value = list.at(j); QString user; -#ifdef WIN32 +#ifdef _WIN32 if (value.startsWith("USERNAME=")) user = value.right(value.size() - 9); #else @@ -364,7 +364,7 @@ else */ //------------------------------------------------------------ /* -#ifdef WIN32 +#ifdef _WIN32 wstring getFormattedMessage(DWORD lastError) { @@ -446,7 +446,7 @@ void TSystem::deleteFile(const TFilePath &fp) void TSystem::hideFile(const TFilePath &fp) { -#ifdef WIN32 +#ifdef _WIN32 if (!SetFileAttributesW(fp.getWideString().c_str(), FILE_ATTRIBUTE_HIDDEN)) throw TSystemException(fp, "can't hide file!"); #else // MACOSX, and others @@ -931,7 +931,7 @@ bool TSystem::touchParentDir(const TFilePath &fp) bool TSystem::showDocument(const TFilePath &path) { -#ifdef WIN32 +#ifdef _WIN32 int ret = (int) ShellExecuteW(0, L"open", path.getWideString().c_str(), 0, 0, SW_SHOWNORMAL); if (ret <= 32) { diff --git a/toonz/sources/common/tsystem/tsystempd.cpp b/toonz/sources/common/tsystem/tsystempd.cpp index f1db615..3a74825 100644 --- a/toonz/sources/common/tsystem/tsystempd.cpp +++ b/toonz/sources/common/tsystem/tsystempd.cpp @@ -1,11 +1,11 @@ - - -#ifdef WIN32 +#ifdef _WIN32 #ifndef UNICODE #define UNICODE #endif #endif +#include + #include "tsystem.h" //#include "tunicode.h" #include "tfilepath_io.h" @@ -21,7 +21,7 @@ #undef PLATFORM -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #define PLATFORM WIN32 #include @@ -102,7 +102,7 @@ PLATFORM_NOT_SUPPORTED using namespace std; -#ifdef WIN32 +#ifdef _WIN32 wstring getFormattedMessage(DWORD lastError) { @@ -122,12 +122,11 @@ wstring getFormattedMessage(DWORD lastError) if (!wSize) return wstring(); - wchar_t *wBuffer = new wchar_t[wSize + 1]; - MultiByteToWideChar(0, 0, (char *)lpMsgBuf, -1, wBuffer, wSize); + std::unique_ptr wBuffer(new wchar_t[wSize + 1]); + MultiByteToWideChar(0, 0, (char *)lpMsgBuf, -1, wBuffer.get(), wSize); wBuffer[wSize] = '\0'; - wstring wmsg(wBuffer); + wstring wmsg(wBuffer.get()); - delete[] wBuffer; LocalFree(lpMsgBuf); return wmsg; } @@ -138,7 +137,7 @@ wstring getFormattedMessage(DWORD lastError) void TSystem::outputDebug(string s) { #ifdef TNZCORE_LIGHT -#ifdef WIN32 +#ifdef _WIN32 OutputDebugString((LPCWSTR)s.c_str()); #else cerr << s << endl; @@ -159,7 +158,7 @@ int TSystem::getProcessId() bool TSystem::memoryShortage() { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUSEX memStatus; memStatus.dwLength = sizeof(MEMORYSTATUSEX); @@ -205,7 +204,7 @@ TINT64 TSystem::getFreeMemorySize(bool onlyPhisicalMemory) TINT64 totalFree = 0; -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUSEX buff; buff.dwLength = sizeof(MEMORYSTATUSEX); @@ -263,7 +262,7 @@ TINT64 TSystem::getFreeMemorySize(bool onlyPhisicalMemory) @ @ @ERROR : PLATFORM NOT SUPPORTED #endif -#ifndef WIN32 +#ifndef _WIN32 #else #endif @@ -287,7 +286,7 @@ TINT64 TSystem::getDiskSize(const TFilePath &diskName) assert(0); return 0; } -#ifndef WIN32 +#ifndef _WIN32 struct statfs buf; wstring str_diskname = diskName.getWideString(); #ifdef __sgi @@ -327,7 +326,7 @@ TINT64 TSystem::getFreeDiskSize(const TFilePath &diskName) assert(0); return 0; } -#ifndef WIN32 +#ifndef _WIN32 struct statfs buf; wstring str_diskname = diskName.getWideString(); #ifdef __sgi @@ -361,7 +360,7 @@ TINT64 TSystem::getFreeDiskSize(const TFilePath &diskName) TINT64 TSystem::getMemorySize(bool onlyPhisicalMemory) { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUS buff; GlobalMemoryStatus(&buff); @@ -400,7 +399,7 @@ TINT64 TSystem::getMemorySize(bool onlyPhisicalMemory) @ @ @ERROR : PLATFORM NOT SUPPORTED #endif -#ifndef WIN32 +#ifndef _WIN32 #else #endif } @@ -409,7 +408,7 @@ TINT64 TSystem::getMemorySize(bool onlyPhisicalMemory) void TSystem::moveFileToRecycleBin(const TFilePath &fp) { -#if defined(WIN32) +#if defined(_WIN32) // // from http://msdn.microsoft.com/msdnmag/issues/01/04/c/default.aspx // @@ -497,7 +496,7 @@ TString TSystemException::getMessage() const DEFAULT: msg = L": Unknown error"; -#ifndef WIN32 +#ifndef _WIN32 CASE ELOOP : msg = L": Too many symbolic links were encountered in translating path."; #ifndef MACOSX CASE EMULTIHOP : msg = L": Components of path require hopping to multiple remote machines and the file system does not allow it."; diff --git a/toonz/sources/common/tsystem/uncpath.cpp b/toonz/sources/common/tsystem/uncpath.cpp index fb1205d..92ed0ac 100644 --- a/toonz/sources/common/tsystem/uncpath.cpp +++ b/toonz/sources/common/tsystem/uncpath.cpp @@ -3,7 +3,7 @@ #include "tsystem.h" #include "tconvert.h" -#ifdef WIN32 +#ifdef _WIN32 #define UNICODE // per le funzioni di conversione da/a UNC #include #include @@ -22,7 +22,7 @@ bool TSystem::isUNC(const TFilePath &path) TFilePath TSystem::toUNC(const TFilePath &fp) { -#ifdef WIN32 +#ifdef _WIN32 if (QString::fromStdWString(fp.getWideString()).startsWith('+')) return fp; if (isUNC(fp)) @@ -146,7 +146,7 @@ TFilePath TSystem::toUNC(const TFilePath &fp) TFilePath TSystem::toLocalPath(const TFilePath &fp) { -#ifdef WIN32 +#ifdef _WIN32 if (!isUNC(fp)) return TFilePath(fp); diff --git a/toonz/sources/common/ttest/ttest.cpp b/toonz/sources/common/ttest/ttest.cpp index 568bf80..dba0d64 100644 --- a/toonz/sources/common/ttest/ttest.cpp +++ b/toonz/sources/common/ttest/ttest.cpp @@ -213,7 +213,7 @@ TFilePath getTestFile(string name) TFilePath testFile; TFilePath parentDir = TSystem::getBinDir().getParentDir(); -#ifndef WIN32 +#ifndef _WIN32 parentDir = parentDir.getParentDir(); #endif diff --git a/toonz/sources/common/tvectorimage/drawutil.cpp b/toonz/sources/common/tvectorimage/drawutil.cpp index b9e82ff..92510eb 100644 --- a/toonz/sources/common/tvectorimage/drawutil.cpp +++ b/toonz/sources/common/tvectorimage/drawutil.cpp @@ -248,7 +248,7 @@ for(UINT i=0; igetEdgeCount(); i++) void lefttRotateBits(UCHAR *buf, int bufferSize) { UINT *buffer = (UINT *)buf; - register UINT app; + UINT app; for (int i = 0; i < bufferSize; i++, buffer++) { app = *buffer; *buffer = app << 8 | app >> 24; diff --git a/toonz/sources/common/tvectorimage/tcomputeregions.cpp b/toonz/sources/common/tvectorimage/tcomputeregions.cpp index 68b6567..6a9bafb 100644 --- a/toonz/sources/common/tvectorimage/tcomputeregions.cpp +++ b/toonz/sources/common/tvectorimage/tcomputeregions.cpp @@ -612,7 +612,7 @@ void TVectorImage::Imp::doEraseIntersection(int index, vector *toBeDeleted) //----------------------------------------------------------------------------- -UINT TVectorImage::Imp::getFillData(IntersectionBranch *&v) +UINT TVectorImage::Imp::getFillData(std::unique_ptr& v) { //print(m_intersectionData->m_intList, "C:\\temp\\intersectionPrimaSave.txt"); @@ -636,7 +636,7 @@ UINT TVectorImage::Imp::getFillData(IntersectionBranch *&v) branchesBefore[currInt + 1] = branchesBefore[currInt] + strokeListSize; } - v = new IntersectionBranch[size]; + v.reset(new IntersectionBranch[size]); currInt = 0; p1 = m_intersectionData->m_intList.first(); for (; p1; p1 = p1->next(), currInt++) { @@ -737,7 +737,7 @@ TStroke *reconstructAutocloseStroke(Intersection *p1, } //namespace //----------------------------------------------------------------------------- -void TVectorImage::Imp::setFillData(IntersectionBranch *v, UINT branchCount, bool doComputeRegions) +void TVectorImage::Imp::setFillData(std::unique_ptr const& v, UINT branchCount, bool doComputeRegions) { #ifdef _DEBUG /*ofstream of("C:\\temp\\fillDataIn.txt"); diff --git a/toonz/sources/common/tvectorimage/tl2lautocloser.cpp b/toonz/sources/common/tvectorimage/tl2lautocloser.cpp index f91ee2b..4c285c6 100644 --- a/toonz/sources/common/tvectorimage/tl2lautocloser.cpp +++ b/toonz/sources/common/tvectorimage/tl2lautocloser.cpp @@ -10,7 +10,7 @@ #include //============================================================================= -#ifdef WIN32 +#ifdef _WIN32 class MyTimer { @@ -393,7 +393,7 @@ void TL2LAutocloser::Imp::search( if (strokea == 0 || strokeb == 0) return; /* -#ifdef WIN32 +#ifdef _WIN32 MyTimer timer; qDebug() << "search started"; timer.start(); @@ -511,7 +511,7 @@ void TL2LAutocloser::Imp::search( segments.push_back(segment); } /* -#ifdef WIN32 +#ifdef _WIN32 double elapsed = timer.elapsedSeconds(); qDebug() << "search completed. time=" << elapsed << "s"; #endif diff --git a/toonz/sources/common/tvectorimage/tl2lautocloser.h b/toonz/sources/common/tvectorimage/tl2lautocloser.h index 2a4cbbd..39f22ca 100644 --- a/toonz/sources/common/tvectorimage/tl2lautocloser.h +++ b/toonz/sources/common/tvectorimage/tl2lautocloser.h @@ -15,7 +15,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/common/tvectorimage/tsegmentadjuster.h b/toonz/sources/common/tvectorimage/tsegmentadjuster.h index c0f21f1..8e0149c 100644 --- a/toonz/sources/common/tvectorimage/tsegmentadjuster.h +++ b/toonz/sources/common/tvectorimage/tsegmentadjuster.h @@ -16,7 +16,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/common/tvectorimage/tsweepboundary.cpp b/toonz/sources/common/tvectorimage/tsweepboundary.cpp index 03da58d..cb96328 100644 --- a/toonz/sources/common/tvectorimage/tsweepboundary.cpp +++ b/toonz/sources/common/tvectorimage/tsweepboundary.cpp @@ -12,7 +12,7 @@ //#include "drawutil.h" #include "tvectorimage.h" -#ifdef WIN32 +#ifdef _WIN32 #include #include #endif @@ -317,7 +317,7 @@ void removeFalseHoles(const vector &strokes); inline void TraceLinkedQuadraticList(LinkedQuadraticList &quadraticList) { -#ifdef WIN32 +#ifdef _WIN32 _RPT0(_CRT_WARN, "\n__________________________________________________\n"); LinkedQuadraticList::iterator it = quadraticList.begin(); diff --git a/toonz/sources/common/tvectorimage/tvectorimage.cpp b/toonz/sources/common/tvectorimage/tvectorimage.cpp index d514bd8..07fdbf2 100644 --- a/toonz/sources/common/tvectorimage/tvectorimage.cpp +++ b/toonz/sources/common/tvectorimage/tvectorimage.cpp @@ -1177,14 +1177,9 @@ void TVectorImage::putRegion(TRegion *region) void TVectorImage::Imp::cloneRegions(TVectorImage::Imp &out, bool doComputeRegions) { - IntersectionBranch *v; - UINT size; - - size = getFillData(v); + std::unique_ptr v; + UINT size = getFillData(v); out.setFillData(v, size, doComputeRegions); - - if (size) - delete[] v; } //----------------------------------------------------------------------------- @@ -1635,14 +1630,14 @@ void TVectorImage::invalidateBBox() */ //----------------------------------------------------------------------------- -void TVectorImage::setFillData(IntersectionBranch *v, UINT branchCount, bool doComputeRegions) +void TVectorImage::setFillData(std::unique_ptr const& v, UINT branchCount, bool doComputeRegions) { m_imp->setFillData(v, branchCount, doComputeRegions); } //----------------------------------------------------------------------------- -UINT TVectorImage::getFillData(IntersectionBranch *&v) +UINT TVectorImage::getFillData(std::unique_ptr& v) { return m_imp->getFillData(v); } @@ -1667,7 +1662,7 @@ bool TVectorImage::isStrokeStyleEnabled(int index) //----------------------------------------------------------------------------- -void TVectorImage::getUsedStyles(set &styles) const +void TVectorImage::getUsedStyles(std::set &styles) const { UINT strokeCount = getStrokeCount(); UINT i = 0; @@ -2861,7 +2856,7 @@ bool TVectorImage::Imp::canMoveStrokes(int strokeIndex, int count, int moveBefor int i, j = 0; - vector groupsAfterMoving(m_strokes.size()); + std::vector groupsAfterMoving(m_strokes.size()); if (strokeIndex < moveBefore) { for (i = 0; i < strokeIndex; i++) groupsAfterMoving[j++] = m_strokes[i]->m_groupId; @@ -2892,7 +2887,7 @@ bool TVectorImage::Imp::canMoveStrokes(int strokeIndex, int count, int moveBefor i = 0; TGroupId currGroupId; - set groupSet; + std::set groupSet; while (i < (int)groupsAfterMoving.size()) { currGroupId = groupsAfterMoving[i]; @@ -2912,11 +2907,11 @@ bool TVectorImage::Imp::canMoveStrokes(int strokeIndex, int count, int moveBefor //----------------------------------------------------------------- -void TVectorImage::Imp::regroupGhosts(vector &changedStrokes) +void TVectorImage::Imp::regroupGhosts(std::vector &changedStrokes) { TGroupId currGroupId; - set groupMap; - set::iterator it; + std::set groupMap; + std::set::iterator it; UINT i = 0; while (i < m_strokes.size()) { diff --git a/toonz/sources/common/tvectorimage/tvectorimageP.h b/toonz/sources/common/tvectorimage/tvectorimageP.h index e81e7b8..a1b2a9a 100644 --- a/toonz/sources/common/tvectorimage/tvectorimageP.h +++ b/toonz/sources/common/tvectorimage/tvectorimageP.h @@ -7,7 +7,6 @@ #include "tvectorimage.h" #include "tregion.h" #include "tcurves.h" -using namespace std; //----------------------------------------------------------------------------- @@ -164,8 +163,8 @@ public: void cloneRegions(TVectorImage::Imp &out, bool doComputeRegions = true); void eraseIntersection(int index); - UINT getFillData(TVectorImage::IntersectionBranch *&v); - void setFillData(TVectorImage::IntersectionBranch *v, UINT branchCount, bool doComputeRegions = true); + UINT getFillData(std::unique_ptr& v); + void setFillData(std::unique_ptr const& v, UINT branchCount, bool doComputeRegions = true); void notifyChangedStrokes(const vector &strokeIndexArray, const vector &oldVectorStrokeArray, bool areFlipped); void insertStrokeAt(VIStroke *stroke, int strokeIndex, bool recomputeRegions = true); void moveStroke(int fromIndex, int toIndex); diff --git a/toonz/sources/common/tvrender/qtofflinegl.cpp b/toonz/sources/common/tvrender/qtofflinegl.cpp index 4c4c4ff..750802f 100644 --- a/toonz/sources/common/tvrender/qtofflinegl.cpp +++ b/toonz/sources/common/tvrender/qtofflinegl.cpp @@ -6,7 +6,7 @@ //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 void swapRedBlueChannels(void *buffer, int bufferSize) // Flips The Red And Blue Bytes (WidthxHeight) { @@ -51,7 +51,7 @@ void swapRedBlueChannels(void *buffer, int bufferSize) // Flips The Red And Blue void rightRotateBits(UCHAR *buf, int bufferSize) { UINT *buffer = (UINT *)buf; - register UINT app; + UINT app; for (int i = 0; i < bufferSize; i++, buffer++) { app = *buffer; *buffer = app >> 8 | app << 24; @@ -61,7 +61,7 @@ void rightRotateBits(UCHAR *buf, int bufferSize) void rightRotateBits(UCHAR *buf, int bufferSize) { UINT *buffer = (UINT *)buf; - register UINT app; + UINT app; for (int i = 0; i < bufferSize; i++, buffer++) { app = *buffer; *buffer = (app >> 16 & 0x000000ff) | (app << 16 & 0x00ff0000) | (app & 0xff00ff00); @@ -127,7 +127,7 @@ void QtOfflineGL::createContext(TDimension rasterSize, std::shared_ptr tempKernPairs(new KERNINGPAIR[pairsCount]); + GetKerningPairsW(hdc, pairsCount, tempKernPairs.get()); for (UINT i = 0; i < pairsCount; i++) { pair key = make_pair(tempKernPairs[i].wFirst, tempKernPairs[i].wSecond); m_kerningPairs[key] = tempKernPairs[i].iKernAmount; } - delete[] tempKernPairs; } else m_hasKerning = false; @@ -132,17 +131,17 @@ TPoint TFont::drawChar(TVectorImageP &image, wchar_t charcode, wchar_t nextCharC return TPoint(); } - LPVOID lpvBuffer = new char[charMemorySize]; + std::unique_ptr lpvBuffer(new char[charMemorySize]); - charMemorySize = GetGlyphOutlineW(m_pimpl->m_hdc, charcode, GGO_NATIVE, &gm, charMemorySize, lpvBuffer, &mat2); + charMemorySize = GetGlyphOutlineW(m_pimpl->m_hdc, charcode, GGO_NATIVE, &gm, charMemorySize, lpvBuffer.get(), &mat2); if (charMemorySize == GDI_ERROR) { assert(0); return TPoint(); } - TTPOLYGONHEADER *header = (TTPOLYGONHEADER *)lpvBuffer; + TTPOLYGONHEADER *header = (TTPOLYGONHEADER *)lpvBuffer.get(); - while ((char *)header < (char *)lpvBuffer + charMemorySize) { + while ((char *)header < (char *)lpvBuffer.get() + charMemorySize) { points.clear(); TThickPoint startPoint = toThickPoint(header->pfxStart); points.push_back(startPoint); @@ -204,8 +203,6 @@ TPoint TFont::drawChar(TVectorImageP &image, wchar_t charcode, wchar_t nextCharC header = (TTPOLYGONHEADER *)curve; } - delete[] lpvBuffer; - image->group(0, image->getStrokeCount()); return getDistance(charcode, nextCharCode); diff --git a/toonz/sources/common/tvrender/tglregions.cpp b/toonz/sources/common/tvrender/tglregions.cpp index 5ef8493..746ef59 100644 --- a/toonz/sources/common/tvrender/tglregions.cpp +++ b/toonz/sources/common/tvrender/tglregions.cpp @@ -17,7 +17,7 @@ #include "tcurves.h" #include "tstrokeoutline.h" -#ifndef WIN32 +#ifndef _WIN32 #define CALLBACK #endif diff --git a/toonz/sources/common/tvrender/tinbetween.cpp b/toonz/sources/common/tvrender/tinbetween.cpp index f9d2c39..4dcf7bd 100644 --- a/toonz/sources/common/tvrender/tinbetween.cpp +++ b/toonz/sources/common/tvrender/tinbetween.cpp @@ -156,11 +156,11 @@ inline bool isTooComplex(UINT n1, UINT n2, UINT maxSubsetNumber = 100) if (n > (one << ((sizeof(UINT) * 8 - 1) / r))) return true; - register UINT product1 = n; //product1 = n*(n-1)* ...(n-r+1) - for (register UINT i = 1; i < r; i++) + UINT product1 = n; //product1 = n*(n-1)* ...(n-r+1) + for (UINT i = 1; i < r; i++) product1 *= --n; - register UINT rFact = r; + UINT rFact = r; while (r > 1) rFact *= --r; diff --git a/toonz/sources/common/tvrender/tofflinegl.cpp b/toonz/sources/common/tvrender/tofflinegl.cpp index bccfb70..c1df1fa 100644 --- a/toonz/sources/common/tvrender/tofflinegl.cpp +++ b/toonz/sources/common/tvrender/tofflinegl.cpp @@ -59,7 +59,7 @@ void TOfflineGL::setContextManager(TGLContextManager *contextManager) // WIN32Implementation : implementazione offlineGL WIN32 //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 namespace { @@ -447,7 +447,7 @@ public: void rightRotateBits(UCHAR *buf, int bufferSize) { UINT *buffer = (UINT *)buf; - register UINT app; + UINT app; for (int i = 0; i < bufferSize; i++, buffer++) { app = *buffer; *buffer = app >> 8 | app << 24; @@ -457,7 +457,7 @@ public: void rightRotateBits(UCHAR *buf, int bufferSize) { UINT *buffer = (UINT *)buf; - register UINT app; + UINT app; for (int i = 0; i < bufferSize; i++, buffer++) { app = *buffer; *buffer = (app >> 16 & 0x000000ff) | (app << 16 & 0x00ff0000) | (app & 0xff00ff00); diff --git a/toonz/sources/common/tvrender/tregionprop.cpp b/toonz/sources/common/tvrender/tregionprop.cpp index 9559803..9fe775a 100644 --- a/toonz/sources/common/tvrender/tregionprop.cpp +++ b/toonz/sources/common/tvrender/tregionprop.cpp @@ -15,7 +15,7 @@ //#include "tdebugmessage.h" //#include "tflash.h" -#ifndef WIN32 +#ifndef _WIN32 #define CALLBACK #endif diff --git a/toonz/sources/common/tvrender/tsimplecolorstyles.cpp b/toonz/sources/common/tvrender/tsimplecolorstyles.cpp index f9f96a9..dfb8b1f 100644 --- a/toonz/sources/common/tvrender/tsimplecolorstyles.cpp +++ b/toonz/sources/common/tvrender/tsimplecolorstyles.cpp @@ -28,7 +28,7 @@ #include "tsimplecolorstyles.h" -#ifndef WIN32 +#ifndef _WIN32 #define CALLBACK #endif @@ -119,7 +119,7 @@ void drawAntialiasedOutline(const std::vector &_v, const TStroke // DisplayListManager definition //************************************************************************************* -#ifdef WIN32 +#ifdef _WIN32 namespace { @@ -292,7 +292,7 @@ public: } // namespace -#endif // WIN32 +#endif // _WIN32 //************************************************************************************* // TSimpleStrokeStyle implementation @@ -1460,7 +1460,7 @@ void TVectorImagePatternStrokeStyle::computeTransformations(vector &tra void TVectorImagePatternStrokeStyle::clearGlDisplayLists() { -#ifdef WIN32 +#ifdef _WIN32 DisplayListManager *pmgr = DisplayListManager::instance(); assert(pmgr); pmgr->clearLists(); @@ -1590,7 +1590,7 @@ void TVectorImagePatternStrokeStyle::drawStroke(const TVectorRenderData &rd, con tglMultMatrix(totalTransformation); CHECK_GL_ERROR -#ifdef WIN32 +#ifdef _WIN32 GLuint listId = DisplayListManager::instance()->getDisplayListId(imgPointer, m_name, fid, rd); if (listId != 0) { diff --git a/toonz/sources/common/tvrender/ttessellator.cpp b/toonz/sources/common/tvrender/ttessellator.cpp index ab48aae..d91ada3 100644 --- a/toonz/sources/common/tvrender/ttessellator.cpp +++ b/toonz/sources/common/tvrender/ttessellator.cpp @@ -12,7 +12,7 @@ //#include "tlevel_io.h" -#ifndef WIN32 +#ifndef _WIN32 #define CALLBACK #endif // To avoid linking problems with HP ZX2000 @@ -93,7 +93,7 @@ extern "C" void CALLBACK myCombine(GLdouble coords[3], GLdouble *d[4], //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 typedef GLvoid(CALLBACK *GluCallback)(void); #endif diff --git a/toonz/sources/common/twain/ttwain.h b/toonz/sources/common/twain/ttwain.h index b1ba6b8..5e5c983 100644 --- a/toonz/sources/common/twain/ttwain.h +++ b/toonz/sources/common/twain/ttwain.h @@ -3,7 +3,7 @@ #ifndef __TTWAIN_H__ #define __TTWAIN_H__ -#ifdef WIN32 +#ifdef _WIN32 #include #else #ifndef _UNIX_ diff --git a/toonz/sources/common/twain/ttwainP.h b/toonz/sources/common/twain/ttwainP.h index 84ff961..86e88eb 100644 --- a/toonz/sources/common/twain/ttwainP.h +++ b/toonz/sources/common/twain/ttwainP.h @@ -25,7 +25,7 @@ typedef enum TWAINSTATE { TWAIN_TRANSFERRING /* image in transit */ } TWAINSTATE; -#ifdef WIN32 +#ifdef _WIN32 #ifdef x64 #define DSM_FILENAME "TWAINDSM.DLL" #else diff --git a/toonz/sources/common/twain/ttwain_error.c b/toonz/sources/common/twain/ttwain_error.c index 2df522d..0b2860b 100644 --- a/toonz/sources/common/twain/ttwain_error.c +++ b/toonz/sources/common/twain/ttwain_error.c @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif @@ -128,7 +128,7 @@ void TTWAIN_RecordError(void) } if (TTwainData.ErrRC == TWRC_FAILURE && TTwainData.ErrCC == TWCC_OPERATIONERROR) { -#ifdef WIN32 +#ifdef _WIN32 OutputDebugString(Msg_out); #else #ifdef TOONZDEBUG diff --git a/toonz/sources/common/twain/ttwain_global_def.h b/toonz/sources/common/twain/ttwain_global_def.h index c0a740d..994d46e 100644 --- a/toonz/sources/common/twain/ttwain_global_def.h +++ b/toonz/sources/common/twain/ttwain_global_def.h @@ -3,7 +3,7 @@ /*max@home*/ #ifndef __GLOBAL_DEF_H__ #define __GLOBAL_DEF_H__ -#ifdef WIN32 +#ifdef _WIN32 #define GLOBAL_LOCK(P) GlobalLock(P) #define GLOBAL_ALLOC(T, S) GlobalAlloc(T, S) #define GLOBAL_FREE(P) GlobalFree(P) diff --git a/toonz/sources/common/twain/ttwain_state.c b/toonz/sources/common/twain/ttwain_state.c index a0c360e..28db069 100644 --- a/toonz/sources/common/twain/ttwain_state.c +++ b/toonz/sources/common/twain/ttwain_state.c @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif @@ -203,7 +203,7 @@ int TTWAIN_MessageHook(void *lpmsg) //printf("%s\n", __PRETTY_FUNCTION__); if (TTWAIN_GetState() >= TWAIN_SOURCE_ENABLED) { /* source enabled */ -#ifdef WIN32 +#ifdef _WIN32 TW_EVENT twEvent; twEvent.pEvent = (TW_MEMREF)lpmsg; twEvent.TWMessage = MSG_NULL; @@ -639,7 +639,7 @@ void *TTWAIN_AcquireNative(void *hwnd) return hnative; } /*---------------------------------------------------------------------------*/ -#ifdef WIN32 +#ifdef _WIN32 typedef void(MyFun)(HWND); diff --git a/toonz/sources/common/twain/ttwain_util.c b/toonz/sources/common/twain/ttwain_util.c index d639227..af691b2 100644 --- a/toonz/sources/common/twain/ttwain_util.c +++ b/toonz/sources/common/twain/ttwain_util.c @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif @@ -782,7 +782,7 @@ l'immagine) if (!handle) return TRUE; /*non sono semplicamente riuscito a prendere info riguardo il pixelFlavor, ma setPixelType e' andato a buon fine */ -#ifdef WIN32 +#ifdef _WIN32 container = (TW_ENUMERATION *)handle; #else container = (TW_ENUMERATION *)GLOBAL_LOCK(handle); diff --git a/toonz/sources/common/twain/twain.h b/toonz/sources/common/twain/twain.h index 84ae0a1..771fdf2 100644 --- a/toonz/sources/common/twain/twain.h +++ b/toonz/sources/common/twain/twain.h @@ -103,11 +103,11 @@ #endif /* Microsoft C/C++ Compiler */ -#if defined(WIN32) || defined(WIN64) || defined(_WINDOWS) +#if defined(_WIN32) || defined(WIN64) || defined(_WINDOWS) #define TWH_CMP_MSC #if defined(_WIN64) || defined(WIN64) #define TWH_64BIT -#elif defined(WIN32) || defined(_WIN32) +#elif defined(_WIN32) || defined(_WIN32) #define TWH_32BIT #endif @@ -1844,7 +1844,7 @@ typedef struct { * Depreciated Items * ****************************************************************************/ #ifdef _MSWIN_ -#if defined(WIN32) || defined(WIN64) +#if defined(_WIN32) || defined(WIN64) #define TW_HUGE #elif !defined(TWH_CMP_GNU) #define TW_HUGE huge diff --git a/toonz/sources/image/avi/tiio_avi.cpp b/toonz/sources/image/avi/tiio_avi.cpp index cf85215..9fae64e 100644 --- a/toonz/sources/image/avi/tiio_avi.cpp +++ b/toonz/sources/image/avi/tiio_avi.cpp @@ -156,7 +156,7 @@ private: // //=========================================================== -#ifdef WIN32 +#ifdef _WIN32 TLevelWriterAvi::TLevelWriterAvi(const TFilePath &path, TPropertyGroup *winfo) : TLevelWriter(path, winfo), m_aviFile(0), m_videoStream(0), m_audioStream(0), m_bitmapinfo(0), m_outputFmt(0), m_hic(0), m_initDone(false), IOError(0), m_st(0), m_bpp(32), m_maxDataSize(0), m_buffer(0), m_firstframe(-1) @@ -647,10 +647,10 @@ private: // //=========================================================== -#ifdef WIN32 +#ifdef _WIN32 TLevelReaderAvi::TLevelReaderAvi(const TFilePath &path) : TLevelReader(path) -#ifdef WIN32 +#ifdef _WIN32 , m_srcBitmapInfo(0), m_dstBitmapInfo(0), m_hic(0), IOError(0), m_prevFrame(-1), m_decompressedBuffer(0) #endif @@ -1035,7 +1035,7 @@ TImageP TLevelReaderAvi::load(int frameIndex) // //=========================================================== -#ifdef WIN32 +#ifdef _WIN32 Tiio::AviWriterProperties::AviWriterProperties() : m_codec("Codec") { diff --git a/toonz/sources/image/avi/tiio_avi.h b/toonz/sources/image/avi/tiio_avi.h index 0b7ebf8..d69c3a3 100644 --- a/toonz/sources/image/avi/tiio_avi.h +++ b/toonz/sources/image/avi/tiio_avi.h @@ -3,7 +3,7 @@ #ifndef TIIO_AVI_H #define TIIO_AVI_H -#ifdef WIN32 +#ifdef _WIN32 #include #include #endif @@ -33,7 +33,7 @@ public: private: TThread::Mutex m_mutex; -#ifdef WIN32 +#ifdef _WIN32 PAVIFILE m_aviFile; PAVISTREAM m_videoStream; PAVISTREAM m_audioStream; @@ -53,7 +53,7 @@ private: void doSaveSoundTrack(); void searchForCodec(); -#ifdef WIN32 +#ifdef _WIN32 int compressFrame(BITMAPINFOHEADER *outHeader, void **bufferOut, int frameIndex, DWORD flagsIn, DWORD &flagsOut); #endif @@ -80,7 +80,7 @@ public: TThread::Mutex m_mutex; void *m_decompressedBuffer; -#ifdef WIN32 +#ifdef _WIN32 private: PAVISTREAM m_videoStream; BITMAPINFO *m_srcBitmapInfo, *m_dstBitmapInfo; diff --git a/toonz/sources/image/compatibility/inforegion.c b/toonz/sources/image/compatibility/inforegion.c index ec3712d..837400c 100644 --- a/toonz/sources/image/compatibility/inforegion.c +++ b/toonz/sources/image/compatibility/inforegion.c @@ -6,7 +6,7 @@ /*---------------------------------------------------------------------------*/ void getInfoRegion( - register INFO_REGION *region, + INFO_REGION *region, int x1_out, int y1_out, int x2_out, int y2_out, int scale, int width_in, int height_in) { @@ -17,11 +17,11 @@ void getInfoRegion( * ca cui prendere (leggere) la regione voluta (output). */ - register int x1_in, y1_in, x2_in, y2_in; + int x1_in, y1_in, x2_in, y2_in; #define SWAP(a, b) \ { \ - register int tmp; \ + int tmp; \ tmp = a; \ a = b; \ b = tmp; \ @@ -142,7 +142,7 @@ int get_info_region(EXT_INFO_REGION *region, #define SWAP(a, b) \ { \ - register int tmp; \ + int tmp; \ tmp = a; \ a = b; \ b = tmp; \ diff --git a/toonz/sources/image/compatibility/inforegion.h b/toonz/sources/image/compatibility/inforegion.h index fd3dbd3..0df4f2f 100644 --- a/toonz/sources/image/compatibility/inforegion.h +++ b/toonz/sources/image/compatibility/inforegion.h @@ -42,7 +42,7 @@ int get_info_region(EXT_INFO_REGION *region, int width_in, int height_in, int orientation); void getInfoRegion( - register INFO_REGION *region, + INFO_REGION *region, int x1_out, int y1_out, int x2_out, diff --git a/toonz/sources/image/compatibility/tfile_io.c b/toonz/sources/image/compatibility/tfile_io.c index 1995573..11c0cb5 100644 --- a/toonz/sources/image/compatibility/tfile_io.c +++ b/toonz/sources/image/compatibility/tfile_io.c @@ -2,7 +2,7 @@ #include "tfile_io.h" -#ifdef WIN32 +#ifdef _WIN32 #include #include diff --git a/toonz/sources/image/compatibility/tnz4.h b/toonz/sources/image/compatibility/tnz4.h index 52ef231..d84950c 100644 --- a/toonz/sources/image/compatibility/tnz4.h +++ b/toonz/sources/image/compatibility/tnz4.h @@ -32,7 +32,7 @@ TNZ_LITTLE_ENDIAN undefined !! #define TBOOL int typedef struct LPIXEL { -#ifdef WIN32 +#ifdef _WIN32 unsigned char b, g, r, m; #elif defined(__sgi) unsigned char m, b, g, r; @@ -46,7 +46,7 @@ TNZ_LITTLE_ENDIAN undefined !! } LPIXEL; typedef struct SPIXEL { -#ifdef WIN32 +#ifdef _WIN32 unsigned short b, g, r, m; #elif defined(__sgi) unsigned short m, b, g, r; @@ -121,7 +121,7 @@ typedef struct IMAGE { #define CROP(X, MIN, MAX) (X < MIN ? MIN : (X > MAX ? MAX : X)) -#ifdef WIN32 +#ifdef _WIN32 #define LPIXEL_TO_BGRM(X) (X) #else #if TNZ_LITTLE_ENDIAN diff --git a/toonz/sources/image/compatibility/tnz4_cpp.cpp b/toonz/sources/image/compatibility/tnz4_cpp.cpp index c701a73..6c083b9 100644 --- a/toonz/sources/image/compatibility/tnz4_cpp.cpp +++ b/toonz/sources/image/compatibility/tnz4_cpp.cpp @@ -7,7 +7,7 @@ extern "C" { #include #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #endif diff --git a/toonz/sources/image/mov/tiio_movW.cpp b/toonz/sources/image/mov/tiio_movW.cpp index 4e748c7..f41e612 100644 --- a/toonz/sources/image/mov/tiio_movW.cpp +++ b/toonz/sources/image/mov/tiio_movW.cpp @@ -326,7 +326,7 @@ Tiio::TifWriterProperties::TifWriterProperties() { m_byteOrdering.addValue(L"IBM PC"); m_byteOrdering.addValue(L"Mac"); -#ifdef WIN32 +#ifdef _WIN32 m_byteOrdering.setValue(L"IBM PC"); #else m_byteOrdering.setValue(L"Mac"); diff --git a/toonz/sources/image/pli/pli_io.cpp b/toonz/sources/image/pli/pli_io.cpp index 3184d72..ca493bd 100644 --- a/toonz/sources/image/pli/pli_io.cpp +++ b/toonz/sources/image/pli/pli_io.cpp @@ -1,4 +1,4 @@ - +#include #ifndef XPRESS @@ -19,7 +19,7 @@ #if defined(MACOSX) #include -#elif defined(WIN32) +#elif defined(_WIN32) #include #endif @@ -304,7 +304,7 @@ UINT TStyleParam::getSize() /*=====================================================================*/ -#ifdef WIN32 +#ifdef _WIN32 #define CHECK_FOR_READ_ERROR(filePath) #else #define CHECK_FOR_READ_ERROR(filePath) \ @@ -365,7 +365,7 @@ public: UCHAR m_currDinamicTypeBytesNum; TUINT32 m_tagLength; TUINT32 m_bufLength; - UCHAR *m_buf; + std::unique_ptr m_buf; TAffine m_affine; int m_precisionScale; std::map m_frameOffsInFile; @@ -513,7 +513,20 @@ static inline short complement2(USHORT val) /*=====================================================================*/ ParsedPliImp::ParsedPliImp() - : m_majorVersionNumber(0), m_minorVersionNumber(0), m_framesNumber(0), m_thickRatio(1.0), m_maxThickness(0.0), m_firstTag(NULL), m_lastTag(NULL), m_currTag(NULL), m_iChan(), m_oChan(0), m_bufLength(0), m_buf(NULL), m_affine(), m_precisionScale(REGION_COMPUTING_PRECISION), m_creator("") + : m_majorVersionNumber(0) + , m_minorVersionNumber(0) + , m_framesNumber(0) + , m_thickRatio(1.0) + , m_maxThickness(0.0) + , m_firstTag(NULL) + , m_lastTag(NULL) + , m_currTag(NULL) + , m_iChan() + , m_oChan(0) + , m_bufLength(0) + , m_affine() + , m_precisionScale(REGION_COMPUTING_PRECISION) + , m_creator("") { } @@ -525,8 +538,21 @@ ParsedPliImp::ParsedPliImp(UCHAR majorVersionNumber, UCHAR precision, UCHAR maxThickness, double autocloseTolerance) - : m_majorVersionNumber(majorVersionNumber), m_minorVersionNumber(minorVersionNumber), m_framesNumber(framesNumber), m_maxThickness(maxThickness), m_autocloseTolerance(autocloseTolerance), m_thickRatio(maxThickness / 255.0), m_firstTag(NULL), m_lastTag(NULL), m_currTag(NULL), m_iChan(), m_oChan(0), m_bufLength(0), m_buf(NULL), m_affine(TScale(1.0 / pow(10.0, precision))), m_precisionScale(REGION_COMPUTING_PRECISION), m_creator("") - + : m_majorVersionNumber(majorVersionNumber) + , m_minorVersionNumber(minorVersionNumber) + , m_framesNumber(framesNumber) + , m_maxThickness(maxThickness) + , m_autocloseTolerance(autocloseTolerance) + , m_thickRatio(maxThickness / 255.0) + , m_firstTag(NULL) + , m_lastTag(NULL) + , m_currTag(NULL) + , m_iChan() + , m_oChan(0) + , m_bufLength(0) + , m_affine(TScale(1.0 / pow(10.0, precision))) + , m_precisionScale(REGION_COMPUTING_PRECISION) + , m_creator("") { } @@ -534,9 +560,17 @@ ParsedPliImp::ParsedPliImp(UCHAR majorVersionNumber, ParsedPliImp::ParsedPliImp(const TFilePath &filename, bool readInfo) : m_majorVersionNumber(0), m_minorVersionNumber(0) - // , m_filename(filename) - , - m_framesNumber(0), m_thickRatio(1.0), m_maxThickness(0), m_firstTag(NULL), m_lastTag(NULL), m_currTag(NULL), m_iChan(), m_oChan(0), m_bufLength(0), m_buf(NULL), m_precisionScale(REGION_COMPUTING_PRECISION), m_creator("") + , m_framesNumber(0) + , m_thickRatio(1.0) + , m_maxThickness(0) + , m_firstTag(NULL) + , m_lastTag(NULL) + , m_currTag(NULL) + , m_iChan() + , m_oChan(0) + , m_bufLength(0) + , m_precisionScale(REGION_COMPUTING_PRECISION) + , m_creator("") { TUINT32 magic; // TUINT32 fileLenght; @@ -545,7 +579,7 @@ ParsedPliImp::ParsedPliImp(const TFilePath &filename, bool readInfo) // cerr< quadratic(new TThickQuadratic[numQuadratics]); for (unsigned int i = 0; i < numQuadratics; i++) { quadratic[i].setThickP0(p); @@ -1177,7 +1208,7 @@ PliTag *ParsedPliImp::readThickQuadraticChainTag(bool isLoop) ThickQuadraticChainTag *tag = new ThickQuadraticChainTag(); tag->m_numCurves = numQuadratics; - tag->m_curve = quadratic; + tag->m_curve = std::move(quadratic); tag->m_isLoop = isLoop; tag->m_maxThickness = maxThickness; @@ -1188,40 +1219,35 @@ PliTag *ParsedPliImp::readThickQuadraticChainTag(bool isLoop) PliTag *ParsedPliImp::readGroupTag() { - PliObjectTag **object; - UCHAR type; - TUINT32 numObjects, bufOffs = 0; + TUINT32 bufOffs = 0; - type = m_buf[bufOffs++]; + UCHAR type = m_buf[bufOffs++]; assert(type < GroupTag::TYPE_HOW_MANY); - numObjects = (m_tagLength - 1) / m_currDinamicTypeBytesNum; - object = new PliObjectTag *[numObjects]; + TUINT32 numObjects = (m_tagLength - 1) / m_currDinamicTypeBytesNum; + std::unique_ptr object(new PliObjectTag *[numObjects]); - TUINT32 *tagOffs = new TUINT32[numObjects]; + std::unique_ptr tagOffs(new TUINT32[numObjects]); - unsigned int i = 0; - for (i = 0; i < numObjects; i++) { + for (TUINT32 i = 0; i < numObjects; i++) { readDinamicData(tagOffs[i], bufOffs); } TagElem *elem; - for (i = 0; i < numObjects; i++) + for (TUINT32 i = 0; i < numObjects; i++) while (!(object[i] = (PliObjectTag *)findTagFromOffset(tagOffs[i]))) if ((elem = readTag())) addTag(*elem); else assert(false); - GroupTag *tag = new GroupTag(); + std::unique_ptr tag(new GroupTag()); tag->m_type = type; tag->m_numObjects = numObjects; - tag->m_object = object; - delete[] tagOffs; - //delete object; + tag->m_object = std::move(object); - return tag; + return tag.release(); } /*=====================================================================*/ @@ -1239,7 +1265,7 @@ PliTag *ParsedPliImp::readColorTag() assert(attribute < ColorTag::ATTRIBUTE_HOW_MANY); TUINT32 numColors = (m_tagLength - 2) / m_currDinamicTypeBytesNum; - TUINT32 *colorArray = new TUINT32[numColors]; + std::unique_ptr colorArray(new TUINT32[numColors]); for (unsigned int i = 0; i < numColors; i++) { TUINT32 color; @@ -1248,11 +1274,8 @@ PliTag *ParsedPliImp::readColorTag() colorArray[i] = color; } - ColorTag *tag = new ColorTag(style, attribute, numColors, colorArray); - - delete[] colorArray; - - return tag; + std::unique_ptr tag(new ColorTag(style, attribute, numColors, std::move(colorArray))); + return tag.release(); } /*=====================================================================*/ @@ -1306,7 +1329,7 @@ PliTag *ParsedPliImp::readStyleTag() int paramArraySize = paramArray.size(); StyleTag *tag = new StyleTag(id, pageIndex, paramArraySize, - (paramArraySize == 0) ? 0 : &(paramArray[0])); + (paramArraySize > 0) ? paramArray.data() : nullptr); m_currDinamicTypeBytesNum = currDinamicTypeBytesNumSaved; return tag; @@ -1386,7 +1409,7 @@ UINT ParsedPliImp::readRasterData(TRaster32P &r, TUINT32 &bufOffs) r.create((int)lx, (int)ly); UINT size = lx * ly * 4; r->lock(); - memcpy(r->getRawData(), m_buf + bufOffs, size); + memcpy(r->getRawData(), m_buf.get() + bufOffs, size); r->unlock(); bufOffs += size; return size + 2 + 2; @@ -1527,7 +1550,7 @@ PliTag *ParsedPliImp::readBitmapTag() r.create(lx, ly); r->lock(); - memcpy(r->getRawData(), m_buf + bufOffs, lx * ly * 4); + memcpy(r->getRawData(), m_buf.get() + bufOffs, lx * ly * 4); r->unlock(); BitmapTag *tag = new BitmapTag(r); @@ -1538,9 +1561,8 @@ PliTag *ParsedPliImp::readBitmapTag() PliTag *ParsedPliImp::readImageTag() { - PliObjectTag **object; USHORT frame; - TUINT32 numObjects, bufOffs = 0; + TUINT32 bufOffs = 0; if (m_isIrixEndian) frame = m_buf[bufOffs + 1] | (m_buf[bufOffs] << 8); @@ -1556,28 +1578,24 @@ PliTag *ParsedPliImp::readImageTag() ++headerLength; } - numObjects = (m_tagLength - headerLength) / m_currDinamicTypeBytesNum; - object = new PliObjectTag *[numObjects]; + TUINT32 numObjects = (m_tagLength - headerLength) / m_currDinamicTypeBytesNum; + std::unique_ptr object(new PliObjectTag*[numObjects]); - TUINT32 *tagOffs = new TUINT32[numObjects]; - unsigned int i; - for (i = 0; i < numObjects; i++) { + std::unique_ptr tagOffs(new TUINT32[numObjects]); + for (TUINT32 i = 0; i < numObjects; i++) { readDinamicData(tagOffs[i], bufOffs); } TagElem *elem; - for (i = 0; i < numObjects; i++) + for (TUINT32 i = 0; i < numObjects; i++) while (!(object[i] = (PliObjectTag *)findTagFromOffset(tagOffs[i]))) if ((elem = readTag())) addTag(*elem); else assert(false); - ImageTag *tag = new ImageTag(TFrameId(frame, letter), numObjects, object); - delete[] tagOffs; - delete[] object; - - return tag; + std::unique_ptr tag(new ImageTag(TFrameId(frame, letter), numObjects, std::move(object))); + return tag.release(); } /*=====================================================================*/ @@ -1628,7 +1646,7 @@ PliTag *ParsedPliImp::readIntersectionDataTag() readTUINT32Data(branchCount, bufOffs); - IntersectionBranch *branchArray = new IntersectionBranch[branchCount]; + std::unique_ptr branchArray(new IntersectionBranch[branchCount]); UINT i; for (i = 0; i < branchCount; i++) { @@ -1667,7 +1685,7 @@ PliTag *ParsedPliImp::readIntersectionDataTag() IntersectionDataTag *tag = new IntersectionDataTag(); tag->m_branchCount = branchCount; - tag->m_branchArray = branchArray; + tag->m_branchArray = std::move(branchArray); return tag; } @@ -2580,11 +2598,6 @@ double ParsedPli::getThickRatio() const ParsedPliImp::~ParsedPliImp() { - if (m_buf) { - delete[] m_buf; - m_buf = NULL; - } - TagElem *tag = m_firstTag; while (tag) { TagElem *auxTag = tag; diff --git a/toonz/sources/image/pli/pli_io.h b/toonz/sources/image/pli/pli_io.h index b8bdf38..0e2fc2c 100644 --- a/toonz/sources/image/pli/pli_io.h +++ b/toonz/sources/image/pli/pli_io.h @@ -1,13 +1,14 @@ - - #ifndef _PLI_IO_H #define _PLI_IO_H -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4661) #pragma warning(disable : 4018) #endif +#include +#include + #include "tfilepath.h" #include "tvectorimage.h" #include "tstroke.h" @@ -232,46 +233,47 @@ class ThickQuadraticChainTag : public PliGeometricTag public: TUINT32 m_numCurves; - TThickQuadratic *m_curve; + std::unique_ptr m_curve; bool m_isLoop; double m_maxThickness; TStroke::OutlineOptions m_outlineOptions; ThickQuadraticChainTag() - : PliGeometricTag(THICK_QUADRATIC_CHAIN_GOBJ), m_numCurves(0), m_curve(0), m_maxThickness(1) {} + : PliGeometricTag(THICK_QUADRATIC_CHAIN_GOBJ) + , m_numCurves(0) + , m_maxThickness(1) + { + } ThickQuadraticChainTag(TUINT32 numCurves, const TThickQuadratic *curve, double maxThickness) - : PliGeometricTag(THICK_QUADRATIC_CHAIN_GOBJ), m_numCurves(numCurves), m_maxThickness(maxThickness <= 0 ? 1 : maxThickness) + : PliGeometricTag(THICK_QUADRATIC_CHAIN_GOBJ) + , m_numCurves(numCurves) + , m_maxThickness(maxThickness <= 0 ? 1 : maxThickness) { - if (m_numCurves == 0) - m_curve = 0; - else { - m_curve = new TThickQuadratic[m_numCurves]; - for (UINT i = 0; i < m_numCurves; i++) + if (m_numCurves > 0) { + m_curve.reset(new TThickQuadratic[m_numCurves]); + for (UINT i = 0; i < m_numCurves; i++) { m_curve[i] = curve[i]; + } } } ThickQuadraticChainTag(const ThickQuadraticChainTag &chainTag) - : PliGeometricTag(THICK_QUADRATIC_CHAIN_GOBJ), m_numCurves(chainTag.m_numCurves), m_maxThickness(chainTag.m_maxThickness) + : PliGeometricTag(THICK_QUADRATIC_CHAIN_GOBJ) + , m_numCurves(chainTag.m_numCurves) + , m_maxThickness(chainTag.m_maxThickness) { - if (m_numCurves == 0) - m_curve = 0; - else { - m_curve = new TThickQuadratic[m_numCurves]; - for (UINT i = 0; i < m_numCurves; i++) + if (m_numCurves > 0) { + m_curve.reset(new TThickQuadratic[m_numCurves]); + for (UINT i = 0; i < m_numCurves; i++) { m_curve[i] = chainTag.m_curve[i]; + } } } - ~ThickQuadraticChainTag() - { - delete[] m_curve; - } - private: // not implemented - const ThickQuadraticChainTag &operator=(const ThickQuadraticChainTag &chainTag); + const ThickQuadraticChainTag &operator=(const ThickQuadraticChainTag &chainTag) = delete; }; //===================================================================== @@ -326,10 +328,10 @@ public: attributeType m_attribute; TUINT32 m_numColors; - TUINT32 *m_color; + std::unique_ptr m_color; ColorTag(); - ColorTag(styleType style, attributeType attribute, TUINT32 numColors, TUINT32 *m_color); + ColorTag(styleType style, attributeType attribute, TUINT32 numColors, std::unique_ptr color); ColorTag(const ColorTag &colorTag); ~ColorTag(); }; @@ -342,7 +344,7 @@ public: USHORT m_id; USHORT m_pageIndex; int m_numParams; - TStyleParam *m_param; + std::unique_ptr m_param; StyleTag(); StyleTag(int id, USHORT pagePaletteindex, int m_numParams, TStyleParam *m_params); @@ -381,10 +383,11 @@ public: UCHAR m_type; TUINT32 m_numObjects; - PliObjectTag **m_object; + std::unique_ptr m_object; GroupTag(); - GroupTag(UCHAR type, TUINT32 numObjects, PliObjectTag **object); + GroupTag(UCHAR type, TUINT32 numObjects, PliObjectTag** object); + GroupTag(UCHAR type, TUINT32 numObjects, std::unique_ptr object); GroupTag(const GroupTag &groupTag); ~GroupTag(); }; @@ -397,10 +400,11 @@ public: TFrameId m_numFrame; TUINT32 m_numObjects; - PliObjectTag **m_object; + std::unique_ptr m_object; //ImageTag(); - ImageTag(const TFrameId &frameId, TUINT32 numObjects, PliObjectTag **object); + ImageTag(const TFrameId &numFrame, TUINT32 numObjects, PliObjectTag** object); + ImageTag(const TFrameId &frameId, TUINT32 numObjects, std::unique_ptr object); ImageTag(const ImageTag &imageTag); ~ImageTag(); }; @@ -424,10 +428,10 @@ class IntersectionDataTag : public PliObjectTag { public: UINT m_branchCount; - TVectorImage::IntersectionBranch *m_branchArray; + std::unique_ptr m_branchArray; IntersectionDataTag(); - IntersectionDataTag(UINT branchCount, TVectorImage::IntersectionBranch *branchArray); + IntersectionDataTag(UINT branchCount, std::unique_ptr branchArray); IntersectionDataTag(const IntersectionDataTag &tag); ~IntersectionDataTag(); diff --git a/toonz/sources/image/pli/tags.cpp b/toonz/sources/image/pli/tags.cpp index 2588687..c2d1d62 100644 --- a/toonz/sources/image/pli/tags.cpp +++ b/toonz/sources/image/pli/tags.cpp @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4661) #endif @@ -176,35 +176,46 @@ PaletteWithAlphaTag::~PaletteWithAlphaTag() /*=====================================================================*/ GroupTag::GroupTag() - : PliObjectTag(PliTag::GROUP_GOBJ), m_type(GroupTag::NONE), m_numObjects(0), m_object(NULL) + : PliObjectTag(PliTag::GROUP_GOBJ) + , m_type(GroupTag::NONE) + , m_numObjects(0) { } /*=====================================================================*/ - -GroupTag::GroupTag(UCHAR type, TUINT32 numObjects, PliObjectTag **object) - : PliObjectTag(PliTag::GROUP_GOBJ), m_type(type), m_numObjects(numObjects) +GroupTag::GroupTag(UCHAR type, TUINT32 numObjects, PliObjectTag** object) + : PliObjectTag(PliTag::GROUP_GOBJ) + , m_type(type) + , m_numObjects(numObjects) { - if (m_numObjects == 0) - m_object = NULL; - else { - m_object = new PliObjectTag *[m_numObjects]; - for (UINT i = 0; i < m_numObjects; i++) + if (m_numObjects > 0) { + m_object.reset(new PliObjectTag*[m_numObjects]); + for (UINT i = 0; i < m_numObjects; i++) { m_object[i] = object[i]; + } } } +GroupTag::GroupTag(UCHAR type, TUINT32 numObjects, std::unique_ptr object) + : PliObjectTag(PliTag::GROUP_GOBJ) + , m_type(type) + , m_numObjects(numObjects) + , m_object(std::move(object)) +{ +} + /*=====================================================================*/ GroupTag::GroupTag(const GroupTag &groupTag) - : PliObjectTag(PliTag::GROUP_GOBJ), m_type(groupTag.m_type), m_numObjects(groupTag.m_numObjects) + : PliObjectTag(PliTag::GROUP_GOBJ) + , m_type(groupTag.m_type) + , m_numObjects(groupTag.m_numObjects) { - if (m_numObjects == 0) - m_object = NULL; - else { - m_object = new PliObjectTag *[m_numObjects]; - for (UINT i = 0; i < m_numObjects; i++) + if (m_numObjects > 0) { + m_object.reset(new PliObjectTag*[m_numObjects]); + for (UINT i = 0; i < m_numObjects; i++) { m_object[i] = groupTag.m_object[i]; + } } } @@ -212,47 +223,48 @@ GroupTag::GroupTag(const GroupTag &groupTag) GroupTag::~GroupTag() { - if (m_numObjects) - delete[] m_object; } /*=====================================================================*/ /*=====================================================================*/ StyleTag::StyleTag() - : PliObjectTag(PliTag::STYLE_NGOBJ), m_id(0), m_numParams(0), m_pageIndex(0), m_param(NULL) + : PliObjectTag(PliTag::STYLE_NGOBJ) + , m_id(0) + , m_numParams(0) + , m_pageIndex(0) { } /*=====================================================================*/ StyleTag::StyleTag(int id, USHORT pagePaletteIndex, int numParams, TStyleParam *param) - : PliObjectTag(PliTag::STYLE_NGOBJ), m_id(id), m_numParams(numParams) -{ - //assert(pagePaletteIndex>=0 && pagePaletteIndex<65536); - - m_pageIndex = pagePaletteIndex; - - if (numParams == 0) - m_param = NULL; - else { - m_param = new TStyleParam[m_numParams]; - for (UINT i = 0; i < (UINT)m_numParams; i++) + : PliObjectTag(PliTag::STYLE_NGOBJ) + , m_id(id) + , m_pageIndex(pagePaletteIndex) + , m_numParams(numParams) +{ + if (numParams > 0) { + m_param.reset(new TStyleParam[m_numParams]); + for (UINT i = 0; i < (UINT)m_numParams; i++) { m_param[i] = param[i]; + } } } /*=====================================================================*/ StyleTag::StyleTag(const StyleTag &styleTag) - : PliObjectTag(PliTag::STYLE_NGOBJ), m_id(styleTag.m_id), m_pageIndex(styleTag.m_pageIndex), m_numParams(styleTag.m_numParams) -{ - if (styleTag.m_numParams == 0) - m_param = NULL; - else { - m_param = new TStyleParam[styleTag.m_numParams]; - for (UINT i = 0; i < (UINT)styleTag.m_numParams; i++) + : PliObjectTag(PliTag::STYLE_NGOBJ) + , m_id(styleTag.m_id) + , m_pageIndex(styleTag.m_pageIndex) + , m_numParams(styleTag.m_numParams) +{ + if (styleTag.m_numParams > 0) { + m_param.reset(new TStyleParam[styleTag.m_numParams]); + for (UINT i = 0; i < (UINT)styleTag.m_numParams; i++) { m_param[i] = styleTag.m_param[i]; + } } } @@ -260,41 +272,42 @@ StyleTag::StyleTag(const StyleTag &styleTag) StyleTag::~StyleTag() { - delete[] m_param; } //===================================================================== ColorTag::ColorTag() - : PliObjectTag(PliTag::COLOR_NGOBJ), m_style(STYLE_NONE), m_attribute(ATTRIBUTE_NONE), m_numColors(0), m_color(NULL) + : PliObjectTag(PliTag::COLOR_NGOBJ) + , m_style(STYLE_NONE) + , m_attribute(ATTRIBUTE_NONE) + , m_numColors(0) { } /*=====================================================================*/ ColorTag::ColorTag(ColorTag::styleType style, ColorTag::attributeType attribute, - TUINT32 numColors, TUINT32 *color) - : PliObjectTag(PliTag::COLOR_NGOBJ), m_style(style), m_attribute(attribute), m_numColors(numColors) + TUINT32 numColors, std::unique_ptr color) + : PliObjectTag(PliTag::COLOR_NGOBJ) + , m_style(style) + , m_attribute(attribute) + , m_numColors(numColors) + , m_color(std::move(color)) { - if (m_numColors == 0) - m_color = NULL; - else { - m_color = new TUINT32[m_numColors]; - for (UINT i = 0; i < m_numColors; i++) - m_color[i] = color[i]; - } } /*=====================================================================*/ ColorTag::ColorTag(const ColorTag &tag) - : PliObjectTag(PliTag::COLOR_NGOBJ), m_style(tag.m_style), m_attribute(tag.m_attribute), m_numColors(tag.m_numColors) -{ - if (tag.m_numColors == 0) - m_color = NULL; - else { - m_color = new TUINT32[m_numColors]; - for (UINT i = 0; i < m_numColors; i++) + : PliObjectTag(PliTag::COLOR_NGOBJ) + , m_style(tag.m_style) + , m_attribute(tag.m_attribute) + , m_numColors(tag.m_numColors) +{ + if (tag.m_numColors > 0) { + m_color.reset(new TUINT32[m_numColors]); + for (UINT i = 0; i < m_numColors; i++) { m_color[i] = tag.m_color[i]; + } } } @@ -302,8 +315,6 @@ ColorTag::ColorTag(const ColorTag &tag) ColorTag::~ColorTag() { - if (m_numColors) - delete[] m_color; } /*=====================================================================*/ @@ -339,28 +350,31 @@ BitmapTag::~BitmapTag() /*=====================================================================*/ IntersectionDataTag::IntersectionDataTag() - : PliObjectTag(PliTag::INTERSECTION_DATA_GOBJ), m_branchCount(0), m_branchArray(0) + : PliObjectTag(PliTag::INTERSECTION_DATA_GOBJ) + , m_branchCount(0) { } /*=====================================================================*/ -IntersectionDataTag::IntersectionDataTag(UINT branchCount, IntersectionBranch *branchArray) - : PliObjectTag(PliTag::INTERSECTION_DATA_GOBJ), m_branchCount(branchCount), m_branchArray(branchArray) +IntersectionDataTag::IntersectionDataTag(UINT branchCount, std::unique_ptr branchArray) + : PliObjectTag(PliTag::INTERSECTION_DATA_GOBJ) + , m_branchCount(branchCount) + , m_branchArray(std::move(branchArray)) { } /*=====================================================================*/ IntersectionDataTag::IntersectionDataTag(const IntersectionDataTag &tag) - : PliObjectTag(PliTag::INTERSECTION_DATA_GOBJ), m_branchCount(tag.m_branchCount) + : PliObjectTag(PliTag::INTERSECTION_DATA_GOBJ) + , m_branchCount(tag.m_branchCount) { - if (m_branchCount == 0) - m_branchArray = 0; - else { - m_branchArray = new IntersectionBranch[m_branchCount]; - for (UINT i = 0; i < m_branchCount; i++) + if (m_branchCount == 0) { + m_branchArray.reset(new IntersectionBranch[m_branchCount]); + for (UINT i = 0; i < m_branchCount; i++) { m_branchArray[i] = tag.m_branchArray[i]; + } } } @@ -368,8 +382,6 @@ IntersectionDataTag::IntersectionDataTag(const IntersectionDataTag &tag) IntersectionDataTag::~IntersectionDataTag() { - if (m_branchCount) - delete[] m_branchArray; } /*=====================================================================*/ @@ -407,30 +419,39 @@ PrecisionScaleTag::PrecisionScaleTag(int precisionScale) }*/ /*=====================================================================*/ - -ImageTag::ImageTag(const TFrameId &numFrame, TUINT32 numObjects, PliObjectTag **object) - : PliObjectTag(PliTag::IMAGE_GOBJ), m_numFrame(numFrame), m_numObjects(numObjects) +ImageTag::ImageTag(const TFrameId &numFrame, TUINT32 numObjects, PliObjectTag** object) + : PliObjectTag(PliTag::IMAGE_GOBJ) + , m_numFrame(numFrame) + , m_numObjects(numObjects) { - if (m_numObjects == 0) - m_object = NULL; - else { - m_object = new PliObjectTag *[m_numObjects]; - for (UINT i = 0; i < m_numObjects; i++) + if (m_numObjects > 0) { + m_object.reset(new PliObjectTag*[m_numObjects]); + for (UINT i = 0; i < m_numObjects; i++) { m_object[i] = object[i]; + } } } +ImageTag::ImageTag(const TFrameId &numFrame, TUINT32 numObjects, std::unique_ptr object) + : PliObjectTag(PliTag::IMAGE_GOBJ) + , m_numFrame(numFrame) + , m_numObjects(numObjects) + , m_object(std::move(object)) +{ +} + /*=====================================================================*/ ImageTag::ImageTag(const ImageTag &imageTag) - : PliObjectTag(PliTag::IMAGE_GOBJ), m_numFrame(imageTag.m_numFrame), m_numObjects(imageTag.m_numObjects) + : PliObjectTag(PliTag::IMAGE_GOBJ) + , m_numFrame(imageTag.m_numFrame) + , m_numObjects(imageTag.m_numObjects) { - if (m_numObjects == 0) - m_object = NULL; - else { - m_object = new PliObjectTag *[m_numObjects]; - for (UINT i = 0; i < m_numObjects; i++) + if (m_numObjects > 0) { + m_object.reset(new PliObjectTag*[m_numObjects]); + for (UINT i = 0; i < m_numObjects; i++) { m_object[i] = imageTag.m_object[i]; + } } } @@ -438,8 +459,6 @@ ImageTag::ImageTag(const ImageTag &imageTag) ImageTag::~ImageTag() { - if (m_numObjects && m_object) - delete[] m_object; } /*=====================================================================*/ diff --git a/toonz/sources/image/pli/tiio_pli.cpp b/toonz/sources/image/pli/tiio_pli.cpp index 559f47d..9900762 100644 --- a/toonz/sources/image/pli/tiio_pli.cpp +++ b/toonz/sources/image/pli/tiio_pli.cpp @@ -167,7 +167,6 @@ void buildPalette(ParsedPli *pli, const TImageP img) // se c'e' una reference image, uso il primo stile della palette per memorizzare il path TFilePath fp; if ((fp = vPalette->getRefImgPath()) != TFilePath()) { - //StyleTag *refImageTag = new StyleTag(0, 0, 1, &TStyleParam("refimage"+toString(fp))); TStyleParam styleParam("refimage" + toString(fp)); StyleTag *refImageTag = new StyleTag(0, 0, 1, &styleParam); pli->m_palette_tags.push_back((PliObjectTag *)refImageTag); @@ -181,7 +180,7 @@ void buildPalette(ParsedPli *pli, const TImageP img) vector pageNames(vPalette->getPageCount()); for (i = 0; i < pageNames.size(); i++) pageNames[i] = TStyleParam(toString(vPalette->getPage(i)->getName())); - StyleTag *pageNamesTag = new StyleTag(0, 0, pageNames.size(), &(pageNames[0])); + StyleTag *pageNamesTag = new StyleTag(0, 0, pageNames.size(), pageNames.data()); pli->m_palette_tags.push_back((PliObjectTag *)pageNamesTag); @@ -206,7 +205,7 @@ void buildPalette(ParsedPli *pli, const TImageP img) style->save(chan); //viene riempito lo stream; assert(pageIndex >= 0 && pageIndex <= 65535); - StyleTag *styleTag = new StyleTag(i, pageIndex, stream.size(), &(stream[0])); + StyleTag *styleTag = new StyleTag(i, pageIndex, stream.size(), stream.data()); pli->m_palette_tags.push_back((PliObjectTag *)styleTag); } @@ -238,7 +237,7 @@ void buildPalette(ParsedPli *pli, const TImageP img) style->save(chan); //viene riempito lo stream; assert(pageIndex >= 0 && pageIndex <= 65535); - StyleTag *styleTag = new StyleTag(i, pageIndex, stream.size(), &(stream[0])); + StyleTag *styleTag = new StyleTag(i, pageIndex, stream.size(), stream.data()); pli->m_palette_tags.push_back((PliObjectTag *)styleTag); } } @@ -470,12 +469,11 @@ void putStroke(TStroke *stroke, int &currStyleId, vector &tags) assert(styleId >= 0); if (currStyleId == -1 || styleId != currStyleId) { currStyleId = styleId; - TUINT32 color[1]; + std::unique_ptr color(new TUINT32[1]); color[0] = (TUINT32)styleId; - ColorTag *colorTag = new ColorTag(ColorTag::SOLID, ColorTag::STROKE_COLOR, 1, color); - //pli->addTag((PliTag *)(colorTag)); - tags.push_back((PliObjectTag *)colorTag); + std::unique_ptr colorTag(new ColorTag(ColorTag::SOLID, ColorTag::STROKE_COLOR, 1, std::move(color))); + tags.push_back(colorTag.release()); } //If the outline options are non-standard (not round), add the outline infos @@ -518,18 +516,17 @@ void TImageWriterPli::save(const TImageP &img) // in modo da non incrementare il numero di frame correnti ++m_lwp->m_frameNumber; - UINT intersectionSize; - IntersectionBranch *v; - intersectionSize = tempVecImg->getFillData(v); + std::unique_ptr v; + UINT intersectionSize = tempVecImg->getFillData(v); // alloco l'oggetto m_lwp->m_pli ( di tipo ParsedPli ) che si occupa di costruire la struttura if (!m_lwp->m_pli) { - m_lwp->m_pli = new ParsedPli(m_lwp->m_frameNumber, m_precision, 40, tempVecImg->getAutocloseTolerance()); + m_lwp->m_pli.reset(new ParsedPli(m_lwp->m_frameNumber, m_precision, 40, tempVecImg->getAutocloseTolerance())); m_lwp->m_pli->setCreator(m_lwp->m_creator); } - buildPalette(m_lwp->m_pli, img); + buildPalette(m_lwp->m_pli.get(), img); - ParsedPli *pli = m_lwp->m_pli; + ParsedPli *pli = m_lwp->m_pli.get(); /* comunico che il numero di frame e' aumentato (il parsed lo riceve nel @@ -562,27 +559,14 @@ void TImageWriterPli::save(const TImageP &img) } if (intersectionSize > 0) { - PliTag *tag = new IntersectionDataTag(intersectionSize, v); - //pli->addTag((PliTag *)tag); + PliTag *tag = new IntersectionDataTag(intersectionSize, std::move(v)); tags.push_back((PliObjectTag *)tag); } - /* questo campo per ora non viene utilizzato per l'attuale struttura delle stroke - if (!tempVecImg->m_textLabel.empty()) - { - groupTag[count] = new TextTag(tempVecImg->m_textLabel); - pli->addTag(groupTag[count++]); - } - */ - int tagsSize = tags.size(); - ImageTag *imageTagPtr = new ImageTag(m_frameId, - tagsSize, - (tagsSize == 0) ? 0 : &(tags[0])); //, true); + std::unique_ptr imageTagPtr(new ImageTag(m_frameId, tagsSize, (tagsSize > 0) ? tags.data() : nullptr)); - pli->addTag(imageTagPtr); - //for (i=0; isize(); i++) - // pli->addTag((*tags)[i]); + pli->addTag(imageTagPtr.release()); // il ritorno e' fissato a false in quanto la // scrittura avviene alla distruzione dello scrittore di livelli @@ -591,7 +575,8 @@ void TImageWriterPli::save(const TImageP &img) //============================================================================= TLevelWriterPli::TLevelWriterPli(const TFilePath &path, TPropertyGroup *winfo) - : TLevelWriter(path, winfo), m_pli(0), m_frameNumber(0) + : TLevelWriter(path, winfo) + , m_frameNumber(0) { } @@ -599,31 +584,22 @@ TLevelWriterPli::TLevelWriterPli(const TFilePath &path, TPropertyGroup *winfo) TLevelWriterPli::~TLevelWriterPli() { - if (m_pli) { - try { - - // aggiungo il tag della palette - CurrStyle = NULL; - assert(!m_pli->m_palette_tags.empty()); - GroupTag *groupTag = new GroupTag(GroupTag::PALETTE, m_pli->m_palette_tags.size(), &(m_pli->m_palette_tags[0])); - m_pli->addTag((PliTag *)groupTag, true); - QString his; - if (m_contentHistory) { - his = m_contentHistory->serialize(); - TextTag *textTag = new TextTag(his.toStdString()); - m_pli->addTag((PliTag *)textTag, true); - } - //m_pli->addTag((PliTag *)(new PaletteWithAlphaTag(m_colorArray.size(), &m_colorArray[0]))); - m_pli->writePli(m_path); - /*UINT i; - for (i=0; im_numObjects; i++) - { - delete groupTag->m_object[i]; - }*/ - - delete m_pli; - } catch (...) { + if (!m_pli) { + return; + } + try { + // aggiungo il tag della palette + CurrStyle = NULL; + assert(!m_pli->m_palette_tags.empty()); + std::unique_ptr groupTag(new GroupTag(GroupTag::PALETTE, m_pli->m_palette_tags.size(), m_pli->m_palette_tags.data())); + m_pli->addTag(groupTag.release(), true); + if (m_contentHistory) { + QString his = m_contentHistory->serialize(); + std::unique_ptr textTag(new TextTag(his.toStdString())); + m_pli->addTag(textTag.release(), true); } + m_pli->writePli(m_path); + } catch (...) { } } @@ -843,7 +819,7 @@ GroupTag *makeGroup(TVectorImageP &vi, int &currStyleId, int &index, int currDep assert(false); } index = i; - return new GroupTag(GroupTag::STROKE, tags.size(), &(tags[0])); + return new GroupTag(GroupTag::STROKE, tags.size(), tags.data()); } //============================================================================= diff --git a/toonz/sources/image/pli/tiio_pli.h b/toonz/sources/image/pli/tiio_pli.h index 81bdbd5..36cab36 100644 --- a/toonz/sources/image/pli/tiio_pli.h +++ b/toonz/sources/image/pli/tiio_pli.h @@ -1,8 +1,8 @@ - - #ifndef TTIO_PLI_INCLUDED #define TTIO_PLI_INCLUDED +#include + #include "tlevel_io.h" class ParsedPli; @@ -33,7 +33,7 @@ private: class TLevelWriterPli : public TLevelWriter { //! object to manage a pli - ParsedPli *m_pli; + std::unique_ptr m_pli; //! number of frame in pli UINT m_frameNumber; diff --git a/toonz/sources/image/png/tiio_png.cpp b/toonz/sources/image/png/tiio_png.cpp index af29db9..1e4038f 100644 --- a/toonz/sources/image/png/tiio_png.cpp +++ b/toonz/sources/image/png/tiio_png.cpp @@ -2,6 +2,8 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #endif +#include + #include "tmachine.h" #include "texception.h" #include "tfilepath.h" @@ -55,12 +57,24 @@ class PngReader : public Tiio::Reader unsigned int m_sig_read; int m_y; bool m_is16bitEnabled; - unsigned char *m_rowBuffer; - unsigned char *m_tempBuffer; //Buffer temporaneo + std::unique_ptr m_rowBuffer; + std::unique_ptr m_tempBuffer; //Buffer temporaneo int m_canDelete; public: PngReader() - : m_chan(0), m_png_ptr(0), m_info_ptr(0), m_end_info_ptr(0), m_bit_depth(0), m_color_type(0), m_interlace_type(0), m_compression_type(0), m_filter_type(0), m_sig_read(0), m_y(0), m_is16bitEnabled(true), m_rowBuffer(0), m_tempBuffer(0), m_canDelete(0) + : m_chan(0) + , m_png_ptr(0) + , m_info_ptr(0) + , m_end_info_ptr(0) + , m_bit_depth(0) + , m_color_type(0) + , m_interlace_type(0) + , m_compression_type(0) + , m_filter_type(0) + , m_sig_read(0) + , m_y(0) + , m_is16bitEnabled(true) + , m_canDelete(0) { } @@ -69,8 +83,6 @@ public: if (m_canDelete == 1) { png_destroy_read_struct(&m_png_ptr, &m_info_ptr, &m_end_info_ptr); } - delete[] m_rowBuffer; - delete[] m_tempBuffer; } virtual bool read16BitIsEnabled() const { return m_is16bitEnabled; } @@ -140,9 +152,6 @@ public: } int rowBytes = png_get_rowbytes(m_png_ptr, m_info_ptr); - if (m_rowBuffer) - delete[] m_rowBuffer; - //m_rowBuffer = new unsigned char[rowBytes]; TUINT32 lx = 0, ly = 0; png_get_IHDR(m_png_ptr, m_info_ptr, &lx, &ly, &m_bit_depth, &m_color_type, @@ -157,11 +166,11 @@ public: if (channels == 1 || channels == 2) { if (m_bit_depth < 8) // (m_bit_depth == 1 || m_bit_depth == 2 || m_bit_depth == 4) - m_rowBuffer = new unsigned char[lx * 3]; + m_rowBuffer.reset(new unsigned char[lx * 3]); else - m_rowBuffer = new unsigned char[rowBytes * 4]; + m_rowBuffer.reset(new unsigned char[rowBytes * 4]); } else { - m_rowBuffer = new unsigned char[rowBytes]; + m_rowBuffer.reset(new unsigned char[rowBytes]); } if (m_color_type == PNG_COLOR_TYPE_PALETTE) { @@ -211,11 +220,11 @@ public: if (m_interlace_type == 1) { if (channels == 1 || channels == 2) { if (m_bit_depth < 8) - m_tempBuffer = new unsigned char[ly * lx * 3]; + m_tempBuffer.reset(new unsigned char[ly * lx * 3]); else - m_tempBuffer = new unsigned char[ly * rowBytes * 4]; + m_tempBuffer.reset(new unsigned char[ly * rowBytes * 4]); } else { - m_tempBuffer = new unsigned char[ly * rowBytes]; + m_tempBuffer.reset(new unsigned char[ly * rowBytes]); } } } @@ -225,8 +234,7 @@ public: readLineInterlace(&buffer[0], x0, x1, shrink); m_y++; if (m_tempBuffer && m_y == ly) { - delete[] m_tempBuffer; - m_tempBuffer = 0; + m_tempBuffer.reset(); } return; } @@ -236,14 +244,13 @@ public: return; m_y++; - png_bytep row_pointer = m_rowBuffer; + png_bytep row_pointer = m_rowBuffer.get(); png_read_row(m_png_ptr, row_pointer, NULL); writeRow(buffer); if (m_tempBuffer && m_y == ly) { - delete[] m_tempBuffer; - m_tempBuffer = 0; + m_tempBuffer.reset(); } } @@ -257,11 +264,11 @@ public: if (m_interlace_type == 1) { if (channels == 1 || channels == 2) { if (m_bit_depth < 8) // (m_bit_depth == 1 || m_bit_depth == 2 || m_bit_depth == 4) - m_tempBuffer = new unsigned char[ly * lx * 3]; + m_tempBuffer.reset(new unsigned char[ly * lx * 3]); else - m_tempBuffer = new unsigned char[ly * rowBytes * 4]; + m_tempBuffer.reset(new unsigned char[ly * rowBytes * 4]); } else { - m_tempBuffer = new unsigned char[ly * rowBytes]; + m_tempBuffer.reset(new unsigned char[ly * rowBytes]); } } } @@ -270,8 +277,7 @@ public: readLineInterlace(&buffer[0], x0, x1, shrink); m_y++; if (m_tempBuffer && m_y == ly) { - delete[] m_tempBuffer; - m_tempBuffer = 0; + m_tempBuffer.reset(); } return; } @@ -281,14 +287,13 @@ public: return; m_y++; - png_bytep row_pointer = m_rowBuffer; + png_bytep row_pointer = m_rowBuffer.get(); png_read_row(m_png_ptr, row_pointer, NULL); writeRow(buffer); if (m_tempBuffer && m_y == ly) { - delete[] m_tempBuffer; - m_tempBuffer = 0; + m_tempBuffer.reset(); } } @@ -303,7 +308,7 @@ public: free(lineBuffer); } else { m_y++; - png_bytep row_pointer = m_rowBuffer; + png_bytep row_pointer = m_rowBuffer.get(); png_read_row(m_png_ptr, row_pointer, NULL); } } @@ -468,43 +473,43 @@ public: if ((channels == 4 || channels == 3) && m_bit_depth == 16) { for (int i = 0; i < count; i += 2) { for (int j = 0; j < channels * 2; j++) { - (m_tempBuffer + (dstY * rowBytes))[(i * dstDx + dstX) * channels + j] = m_rowBuffer[i * channels + j]; + (m_tempBuffer.get() + (dstY * rowBytes))[(i * dstDx + dstX) * channels + j] = m_rowBuffer[i * channels + j]; } } } else if (channels == 2 && m_bit_depth == 16) { for (int i = 0; i < count; i += 2) { for (int j = 0; j < 4 * 2; j++) { - (m_tempBuffer + (dstY * rowBytes * 4))[(i * dstDx + dstX) * 4 + j] = m_rowBuffer[i * 4 + j]; + (m_tempBuffer.get() + (dstY * rowBytes * 4))[(i * dstDx + dstX) * 4 + j] = m_rowBuffer[i * 4 + j]; } } } else if (channels == 1 && m_bit_depth == 16) { for (int i = 0; i < count; i += 2) { for (int j = 0; j < 3 * 2; j++) { - (m_tempBuffer + (dstY * rowBytes * 4))[(i * dstDx + dstX) * 3 + j] = m_rowBuffer[i * 3 + j]; + (m_tempBuffer.get() + (dstY * rowBytes * 4))[(i * dstDx + dstX) * 3 + j] = m_rowBuffer[i * 3 + j]; } } } else if (channels == 1 && m_bit_depth == 8) { for (int i = 0; i < count; i++) { for (int j = 0; j < 3; j++) { - (m_tempBuffer + (dstY * rowBytes * 4))[(i * dstDx + dstX) * 3 + j] = m_rowBuffer[i * 3 + j]; + (m_tempBuffer.get() + (dstY * rowBytes * 4))[(i * dstDx + dstX) * 3 + j] = m_rowBuffer[i * 3 + j]; } } } else if (channels == 2 && m_bit_depth == 8) { for (int i = 0; i < count; i++) { for (int j = 0; j < 4; j++) { - (m_tempBuffer + (dstY * rowBytes * 4))[(i * dstDx + dstX) * 4 + j] = m_rowBuffer[i * 4 + j]; + (m_tempBuffer.get() + (dstY * rowBytes * 4))[(i * dstDx + dstX) * 4 + j] = m_rowBuffer[i * 4 + j]; } } } else if ((channels == 1 || channels == 2) && m_bit_depth < 8) { for (int i = 0; i < count; i++) { for (int j = 0; j < 3; j++) { - (m_tempBuffer + (dstY * lx * 3))[(i * dstDx + dstX) * 3 + j] = m_rowBuffer[i * 3 + j]; + (m_tempBuffer.get() + (dstY * lx * 3))[(i * dstDx + dstX) * 3 + j] = m_rowBuffer[i * 3 + j]; } } } else { for (int i = 0; i < count; i++) { for (int j = 0; j < channels; j++) { - (m_tempBuffer + (dstY * rowBytes))[(i * dstDx + dstX) * channels + j] = m_rowBuffer[i * channels + j]; + (m_tempBuffer.get() + (dstY * rowBytes))[(i * dstDx + dstX) * channels + j] = m_rowBuffer[i * channels + j]; } } } @@ -524,7 +529,7 @@ public: int channels = png_get_channels(m_png_ptr, m_info_ptr); int rowBytes = png_get_rowbytes(m_png_ptr, m_info_ptr); - png_bytep row_pointer = m_rowBuffer; + png_bytep row_pointer = m_rowBuffer.get(); int lx = m_info.m_lx; @@ -581,11 +586,11 @@ public: // fase di copia if (channels == 1 || channels == 2) { if (m_bit_depth < 8) - memcpy(m_rowBuffer, m_tempBuffer + ((m_y)*lx * 3), lx * 3); + memcpy(m_rowBuffer.get(), m_tempBuffer.get() + ((m_y)*lx * 3), lx * 3); else - memcpy(m_rowBuffer, m_tempBuffer + ((m_y)*rowBytes * 4), rowBytes * 4); + memcpy(m_rowBuffer.get(), m_tempBuffer.get() + ((m_y)*rowBytes * 4), rowBytes * 4); } else { - memcpy(m_rowBuffer, m_tempBuffer + ((m_y)*rowBytes), rowBytes); + memcpy(m_rowBuffer.get(), m_tempBuffer.get() + ((m_y)*rowBytes), rowBytes); } // fase di copia vecchia @@ -611,7 +616,7 @@ public: int lx = m_info.m_lx; int rowBytes = png_get_rowbytes(m_png_ptr, m_info_ptr); - png_bytep row_pointer = m_rowBuffer; + png_bytep row_pointer = m_rowBuffer.get(); while (passPng <= passRow && rowNumber < numRows) //finchè il passo d'interlacciamento è minore o uguale //del passo desiderato effettua tante volte le lettura della riga @@ -652,9 +657,9 @@ public: // fase di copia if (channels == 1 || channels == 2) { - memcpy(m_rowBuffer, m_tempBuffer + ((m_y)*rowBytes * 4), rowBytes * 4); + memcpy(m_rowBuffer.get(), m_tempBuffer.get() + ((m_y)*rowBytes * 4), rowBytes * 4); } else { - memcpy(m_rowBuffer, m_tempBuffer + ((m_y)*rowBytes), rowBytes); + memcpy(m_rowBuffer.get(), m_tempBuffer.get() + ((m_y)*rowBytes), rowBytes); } // fase di copia diff --git a/toonz/sources/image/psd/tiio_psd.cpp b/toonz/sources/image/psd/tiio_psd.cpp index a3b962b..e091604 100644 --- a/toonz/sources/image/psd/tiio_psd.cpp +++ b/toonz/sources/image/psd/tiio_psd.cpp @@ -78,7 +78,7 @@ TLevelP TLevelReaderPsd::loadInfo() m_frameTable.clear(); for (int i = 0; i < framesCount; i++) { TFrameId frame(i + 1); - m_frameTable.insert(make_pair(frame, psdparser->getFrameId(m_layerId, i))); + m_frameTable.insert(std::make_pair(frame, psdparser->getFrameId(m_layerId, i))); level->setFrame(frame, TImageP()); } return level; diff --git a/toonz/sources/image/quantel/filequantel.c b/toonz/sources/image/quantel/filequantel.c index 839ed14..bdaf230 100644 --- a/toonz/sources/image/quantel/filequantel.c +++ b/toonz/sources/image/quantel/filequantel.c @@ -16,7 +16,7 @@ #include "filequantel.h" #include "filequantelP.h" -#ifdef WIN32 +#ifdef _WIN32 #define STAT_BUF struct _stat #else #define STAT_BUF struct stat diff --git a/toonz/sources/image/quantel/filequantelP.h b/toonz/sources/image/quantel/filequantelP.h index 31629fc..eaf8fd3 100644 --- a/toonz/sources/image/quantel/filequantelP.h +++ b/toonz/sources/image/quantel/filequantelP.h @@ -110,29 +110,27 @@ } #define QUANTEL_FILL_LINE_OF_RGB(xmarg, xsize, rbuf, gbuf, bbuf, RGBbuf) \ - { \ - register int i; \ - \ - QUANTEL_FILL_LINE_OF_BLACK(rbuf, gbuf, bbuf, xmarg) \ - for (i = xmarg; i < xsize + xmarg; i++) { \ - rbuf[i] = (USHORT)RGBbuf->r; \ - gbuf[i] = (USHORT)RGBbuf->g; \ - bbuf[i] = (USHORT)RGBbuf->b; \ - RGBbuf++; \ - } \ - QUANTEL_FILL_LINE_OF_BLACK(rbuf + i, gbuf + i, bbuf + i, xmarg) \ + { \ + int i; \ + QUANTEL_FILL_LINE_OF_BLACK(rbuf, gbuf, bbuf, xmarg) \ + for (i = xmarg; i < xsize + xmarg; i++) { \ + rbuf[i] = (USHORT)RGBbuf->r; \ + gbuf[i] = (USHORT)RGBbuf->g; \ + bbuf[i] = (USHORT)RGBbuf->b; \ + RGBbuf++; \ + } \ + QUANTEL_FILL_LINE_OF_BLACK(rbuf + i, gbuf + i, bbuf + i, xmarg) \ } -#define QUANTEL_FILL_LINE_OF_RGB2(xmarg, rbuf, gbuf, bbuf, RGBbuf) \ - { \ - register i, _dx; \ - \ +#define QUANTEL_FILL_LINE_OF_RGB2(xmarg, rbuf, gbuf, bbuf, RGBbuf) \ + { \ + int i; \ QUANTEL_FILL_LINE_OF_BLACK(rbuf, gbuf, bbuf, xmarg) \ for (i = xmarg; i < (QUANTEL_XSIZE - xmarg); i++) { \ - rbuf[i] = (USHORT)RGBbuf->r; \ - gbuf[i] = (USHORT)RGBbuf->g; \ - bbuf[i] = (USHORT)RGBbuf->b; \ - RGBbuf++; \ + rbuf[i] = (USHORT)RGBbuf->r; \ + gbuf[i] = (USHORT)RGBbuf->g; \ + bbuf[i] = (USHORT)RGBbuf->b; \ + RGBbuf++; \ } \ QUANTEL_FILL_LINE_OF_BLACK(rbuf + i, gbuf + i, bbuf + i, xmarg) \ } diff --git a/toonz/sources/image/sgi/filesgi.cpp b/toonz/sources/image/sgi/filesgi.cpp index 60aa8b5..f5abd4b 100644 --- a/toonz/sources/image/sgi/filesgi.cpp +++ b/toonz/sources/image/sgi/filesgi.cpp @@ -32,7 +32,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #else @@ -103,21 +103,21 @@ const int IMAGERGB_HEADER_SIZE = sizeof(IMAGERGB); #define _IOERR 0x20 #endif -static USHORT *ibufalloc(register IMAGERGB *image, int bpp); -static void cvtshorts(USHORT buffer[], register TINT32 n); -static void cvtTINT32s(TUINT32 *buffer, register TINT32 n); +static USHORT *ibufalloc(IMAGERGB *image, int bpp); +static void cvtshorts(USHORT buffer[], TINT32 n); +static void cvtTINT32s(TUINT32 *buffer, TINT32 n); static void cvtimage(IMAGERGB *image); static void img_rle_expand(USHORT *rlebuf, int ibpp, USHORT *expbuf, int obpp); -static int img_getrowsize(register IMAGERGB *image); +static int img_getrowsize(IMAGERGB *image); static TUINT32 img_optseek(IMAGERGB *image, TUINT32 offset); static TINT32 rgb_img_read(IMAGERGB *image, char *buffer, TINT32 count); static int img_badrow(IMAGERGB *image, int y, int z); static TUINT32 img_seek(IMAGERGB *image, UINT y, UINT z, UINT offs); static TINT32 RGB_img_write(IMAGERGB *image, char *buffer, TINT32 count); -static void img_setrowsize(register IMAGERGB *image, UINT cnt, UINT y, UINT z); +static void img_setrowsize(IMAGERGB *image, UINT cnt, UINT y, UINT z); static TINT32 img_rle_compact(USHORT *expbuf, int ibpp, USHORT *rlebuf, int obpp, int cnt); -static int iflush(register IMAGERGB *image); +static int iflush(IMAGERGB *image); /*-------------------------------------------------------------------------*/ @@ -205,10 +205,9 @@ static IMAGERGB *iopen(int fd, OpenMode openMode, unsigned int type, unsigned int dim, unsigned int xsize, unsigned int ysize, unsigned int zsize, short dorev) { - register IMAGERGB *image; + IMAGERGB *image; extern int errno; int tablesize, f = fd; - register int i, max; image = (IMAGERGB *)malloc((int)sizeof(IMAGERGB)); @@ -281,8 +280,8 @@ static IMAGERGB *iopen(int fd, OpenMode openMode, if (openMode == OpenWrite) { //WRITE - max = image->ysize * image->zsize; - for (i = 0; i < max; i++) { + int max = image->ysize * image->zsize; + for (int i = 0; i < max; i++) { image->rowstart[i] = 0; image->rowsize[i] = -1; } @@ -291,7 +290,7 @@ static IMAGERGB *iopen(int fd, OpenMode openMode, tablesize = image->ysize * image->zsize * (int)sizeof(TINT32); lseek(f, 512L, 0); if (read(f, image->rowstart, tablesize) != tablesize) { -#ifdef WIN32 +#ifdef _WIN32 DWORD error; error = GetLastError(); #endif @@ -302,7 +301,7 @@ static IMAGERGB *iopen(int fd, OpenMode openMode, if (image->dorev) cvtTINT32s(image->rowstart, tablesize); if (read(f, image->rowsize, tablesize) != tablesize) { -#ifdef WIN32 +#ifdef _WIN32 DWORD error; error = GetLastError(); #endif @@ -337,7 +336,7 @@ static IMAGERGB *iopen(int fd, OpenMode openMode, /*-------------------------------------------------------------------------*/ -static USHORT *ibufalloc(register IMAGERGB *image, int bpp) +static USHORT *ibufalloc(IMAGERGB *image, int bpp) { return (USHORT *)malloc(IBUFSIZE(image->xsize) * bpp); } @@ -347,14 +346,11 @@ static USHORT *ibufalloc(register IMAGERGB *image, int bpp) Inverte gli short del buffer */ -static void cvtshorts(unsigned short buffer[], register TINT32 n) +static void cvtshorts(unsigned short buffer[], TINT32 n) { - register short i; - register TINT32 nshorts = n >> 1; - register unsigned short swrd; - - for (i = 0; i < nshorts; i++) { - swrd = *buffer; + TINT32 nshorts = n >> 1; + for (int i = 0; i < nshorts; i++) { + unsigned short swrd = *buffer; *buffer++ = (swrd >> 8) | (swrd << 8); } return; @@ -368,12 +364,9 @@ static void cvtshorts(unsigned short buffer[], register TINT32 n) static void cvtTINT32s(TUINT32 buffer[], TINT32 n) { - register short i; - register TINT32 nTINT32s = n >> 2; - register TUINT32 lwrd; - - for (i = 0; i < nTINT32s; i++) { - lwrd = buffer[i]; + TINT32 nTINT32s = n >> 2; + for (int i = 0; i < nTINT32s; i++) { + TUINT32 lwrd = buffer[i]; buffer[i] = ((lwrd >> 24) | (lwrd >> 8 & 0xff00) | (lwrd << 8 & 0xff0000) | @@ -424,27 +417,27 @@ static void img_rle_expand(unsigned short *rlebuf, int ibpp, unsigned short *expbuf, int obpp) { if (ibpp == 1 && obpp == 1) { - register unsigned char *iptr = (unsigned char *)rlebuf; - register unsigned char *optr = (unsigned char *)expbuf; - register unsigned short pixel, count; + unsigned char *iptr = (unsigned char *)rlebuf; + unsigned char *optr = (unsigned char *)expbuf; + unsigned short pixel, count; EXPAND_CODE(unsigned char); } else if (ibpp == 1 && obpp == 2) { - register unsigned char *iptr = (unsigned char *)rlebuf; - register unsigned short *optr = expbuf; - register unsigned short pixel, count; + unsigned char *iptr = (unsigned char *)rlebuf; + unsigned short *optr = expbuf; + unsigned short pixel, count; EXPAND_CODE(unsigned short); } else if (ibpp == 2 && obpp == 1) { - register unsigned short *iptr = rlebuf; - register unsigned char *optr = (unsigned char *)expbuf; - register unsigned short pixel, count; + unsigned short *iptr = rlebuf; + unsigned char *optr = (unsigned char *)expbuf; + unsigned short pixel, count; EXPAND_CODE(unsigned char); } else if (ibpp == 2 && obpp == 2) { - register unsigned short *iptr = rlebuf; - register unsigned short *optr = expbuf; - register unsigned short pixel, count; + unsigned short *iptr = rlebuf; + unsigned short *optr = expbuf; + unsigned short pixel, count; EXPAND_CODE(unsigned short); } else @@ -457,7 +450,7 @@ static void img_rle_expand(unsigned short *rlebuf, int ibpp, */ /*-----------------------------------------------------------------------------*/ -static int img_getrowsize(register IMAGERGB *image) +static int img_getrowsize(IMAGERGB *image) { switch (image->dim) { case 1: @@ -571,7 +564,7 @@ static TUINT32 img_seek(IMAGERGB *image, static int new_getrow(IMAGERGB *image, void *buffer, UINT y, UINT z) { - register short cnt; + short cnt; if (!(image->flags & (_IORW | _IOREAD))) return -1; @@ -655,7 +648,7 @@ static TINT32 RGB_img_write(IMAGERGB *image, char *buffer, TINT32 count) /*-----------------------------------------------------------------------------*/ -static void img_setrowsize(register IMAGERGB *image, UINT cnt, UINT y, UINT z) +static void img_setrowsize(IMAGERGB *image, UINT cnt, UINT y, UINT z) { TINT32 *sizeptr = 0; @@ -717,42 +710,42 @@ static TINT32 img_rle_compact(unsigned short *expbuf, int ibpp, unsigned short * int obpp, int cnt) { if (ibpp == 1 && obpp == 1) { - register unsigned char *iptr = (unsigned char *)expbuf; - register unsigned char *ibufend = iptr + cnt; - register unsigned char *sptr; - register unsigned char *optr = (unsigned char *)rlebuf; - register TUINT32 todo, cc; - register TINT32 count; + unsigned char *iptr = (unsigned char *)expbuf; + unsigned char *ibufend = iptr + cnt; + unsigned char *sptr; + unsigned char *optr = (unsigned char *)rlebuf; + TUINT32 todo, cc; + TINT32 count; COMPACT_CODE(unsigned char); return optr - (unsigned char *)rlebuf; } else if (ibpp == 1 && obpp == 2) { - register unsigned char *iptr = (unsigned char *)expbuf; - register unsigned char *ibufend = iptr + cnt; - register unsigned char *sptr; - register unsigned short *optr = rlebuf; - register TUINT32 todo, cc; - register TINT32 count; + unsigned char *iptr = (unsigned char *)expbuf; + unsigned char *ibufend = iptr + cnt; + unsigned char *sptr; + unsigned short *optr = rlebuf; + TUINT32 todo, cc; + TINT32 count; COMPACT_CODE(unsigned short); return optr - rlebuf; } else if (ibpp == 2 && obpp == 1) { - register unsigned short *iptr = expbuf; - register unsigned short *ibufend = iptr + cnt; - register unsigned short *sptr; - register unsigned char *optr = (unsigned char *)rlebuf; - register TUINT32 todo, cc; - register TINT32 count; + unsigned short *iptr = expbuf; + unsigned short *ibufend = iptr + cnt; + unsigned short *sptr; + unsigned char *optr = (unsigned char *)rlebuf; + TUINT32 todo, cc; + TINT32 count; COMPACT_CODE(unsigned char); return optr - (unsigned char *)rlebuf; } else if (ibpp == 2 && obpp == 2) { - register unsigned short *iptr = expbuf; - register unsigned short *ibufend = iptr + cnt; - register unsigned short *sptr; - register unsigned short *optr = rlebuf; - register unsigned short todo, cc; - register TINT32 count; + unsigned short *iptr = expbuf; + unsigned short *ibufend = iptr + cnt; + unsigned short *sptr; + unsigned short *optr = rlebuf; + unsigned short todo, cc; + TINT32 count; COMPACT_CODE(unsigned short); return optr - rlebuf; @@ -881,7 +874,7 @@ static int new_putrow(IMAGERGB *image, void *buffer, UINT y, UINT z) /*----------------------------------------------------------------------------*/ -static int iflush(register IMAGERGB *image) +static int iflush(IMAGERGB *image) { unsigned short *base; diff --git a/toonz/sources/image/tif/tiio_tif.cpp b/toonz/sources/image/tif/tiio_tif.cpp index 2864e59..1bfa09c 100644 --- a/toonz/sources/image/tif/tiio_tif.cpp +++ b/toonz/sources/image/tif/tiio_tif.cpp @@ -1,5 +1,3 @@ - - #if _MSC_VER >= 1400 #define _CRT_SECURE_NO_DEPRECATE 1 #endif @@ -11,6 +9,8 @@ #include #endif +#include + #include "tiio.h" #include "tpixel.h" #include "tsystem.h" @@ -25,7 +25,7 @@ extern "C" { #include "tiio_tif.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include "windows.h" #endif @@ -448,7 +448,7 @@ void TifReader::readLine(short *buffer, int x0, int x1, int shrink) // Allocate a sufficient buffer to store a single tile int tileSize = tileWidth * tileHeight; - uint64 *tile = new uint64[tileSize]; + std::unique_ptr tile(new uint64[tileSize]); int x = 0; int y = tileHeight * m_stripIndex; @@ -458,7 +458,7 @@ void TifReader::readLine(short *buffer, int x0, int x1, int shrink) // Traverse the tiles row while (x < m_info.m_lx) { - int ret = TIFFReadRGBATile_64(m_tiff, x, y, tile); + int ret = TIFFReadRGBATile_64(m_tiff, x, y, tile.get()); assert(ret); int tileRowSize = tmin((int)tileWidth, m_info.m_lx - x) * pixelSize; @@ -467,14 +467,12 @@ void TifReader::readLine(short *buffer, int x0, int x1, int shrink) for (int ty = 0; ty < lastTy; ++ty) { memcpy( m_stripBuffer + (ty * m_rowLength + x) * pixelSize, - (UCHAR *)tile + ty * tileWidth * pixelSize, + (UCHAR *)tile.get() + ty * tileWidth * pixelSize, tileRowSize); } x += tileWidth; } - - delete[] tile; } else { int y = m_rowsPerStrip * m_stripIndex; int ok = TIFFReadRGBAStrip_64(m_tiff, y, (uint64 *)m_stripBuffer); @@ -575,7 +573,7 @@ void TifReader::readLine(char *buffer, int x0, int x1, int shrink) assert(tileWidth > 0 && tileHeight > 0); int tileSize = tileWidth * tileHeight; - uint32 *tile = new uint32[tileSize]; + std::unique_ptr tile(new uint32[tileSize]); int x = 0; int y = tileHeight * m_stripIndex; @@ -583,7 +581,7 @@ void TifReader::readLine(char *buffer, int x0, int x1, int shrink) int lastTy = tmin((int)tileHeight, m_info.m_ly - y); while (x < m_info.m_lx) { - int ret = TIFFReadRGBATile(m_tiff, x, y, tile); + int ret = TIFFReadRGBATile(m_tiff, x, y, tile.get()); assert(ret); int tileRowSize = tmin((int)tileWidth, (int)(m_info.m_lx - x)) * pixelSize; @@ -591,14 +589,12 @@ void TifReader::readLine(char *buffer, int x0, int x1, int shrink) for (int ty = 0; ty < lastTy; ++ty) { memcpy( m_stripBuffer + (ty * m_rowLength + x) * pixelSize, - (UCHAR *)tile + ty * tileWidth * pixelSize, + (UCHAR *)tile.get() + ty * tileWidth * pixelSize, tileRowSize); } x += tileWidth; } - - delete[] tile; } else { int y = m_rowsPerStrip * m_stripIndex; int ok = TIFFReadRGBAStrip(m_tiff, y, (uint32 *)m_stripBuffer); @@ -658,7 +654,7 @@ Tiio::TifWriterProperties::TifWriterProperties() { m_byteOrdering.addValue(L"IBM PC"); m_byteOrdering.addValue(L"Mac"); -#ifdef WIN32 +#ifdef _WIN32 m_byteOrdering.setValue(L"IBM PC"); #else m_byteOrdering.setValue(L"Mac"); diff --git a/toonz/sources/image/tiio.cpp b/toonz/sources/image/tiio.cpp index fd4a893..4507a63 100644 --- a/toonz/sources/image/tiio.cpp +++ b/toonz/sources/image/tiio.cpp @@ -17,7 +17,7 @@ #include //Platform-specific includes -#ifdef WIN32 +#ifdef _WIN32 #ifndef x64 #define float_t Float_t @@ -153,14 +153,14 @@ void initImageIo(bool lightVersion) if (!lightVersion) { -#ifdef WIN32 +#ifdef _WIN32 TLevelWriter::define("avi", TLevelWriterAvi::create, true); TLevelReader::define("avi", TLevelReaderAvi::create); TFileType::declare("avi", TFileType::RASTER_LEVEL); Tiio::defineWriterProperties("avi", new Tiio::AviWriterProperties()); -#endif // WIN32 +#endif // _WIN32 if (IsQuickTimeInstalled()) { TLevelWriter::define("mov", TLevelWriterMov::create, true); @@ -175,7 +175,7 @@ void initImageIo(bool lightVersion) } /* -#if (defined(WIN32) && !defined(x64)) +#if (defined(_WIN32) && !defined(x64)) TLevelWriter::define("pct", TLevelWriterPicPct::create, true); TLevelReader::define("pct", TLevelReaderPicPct::create); @@ -190,7 +190,7 @@ void initImageIo(bool lightVersion) TFileType::declare("pict", TFileType::RASTER_LEVEL); Tiio::defineWriterProperties("pict", new Tiio::PctWriterProperties()); -#endif // WIN32 && 32-bit +#endif // _WIN32 && 32-bit */ } } diff --git a/toonz/sources/image/tzp/avl.c b/toonz/sources/image/tzp/avl.c index f7a9304..a8201b7 100644 --- a/toonz/sources/image/tzp/avl.c +++ b/toonz/sources/image/tzp/avl.c @@ -8,7 +8,7 @@ | | *----------------------------------------------------------------------------*/ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4113) #pragma warning(disable : 4996) @@ -94,7 +94,7 @@ typedef struct avl_path PATH; #ifdef VAX #define SET_STRCMP(cmp, str1, str2) \ { \ - register char *p1, *p2; \ + char *p1, *p2; \ for (p1 = (str1), p2 = (str2); *p1 && *p1 == *p2; p1++, p2++) \ ; \ (cmp) = *(unsigned char *)p1 - *(unsigned char *)p2; \ diff --git a/toonz/sources/image/tzp/tiio_plt.cpp b/toonz/sources/image/tzp/tiio_plt.cpp index 019631b..a10beb6 100644 --- a/toonz/sources/image/tzp/tiio_plt.cpp +++ b/toonz/sources/image/tzp/tiio_plt.cpp @@ -7,7 +7,7 @@ #include "tiffio.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include "windows.h" #endif diff --git a/toonz/sources/image/tzp/tiio_tzp.cpp b/toonz/sources/image/tzp/tiio_tzp.cpp index 80213dd..84d9c4a 100644 --- a/toonz/sources/image/tzp/tiio_tzp.cpp +++ b/toonz/sources/image/tzp/tiio_tzp.cpp @@ -11,7 +11,7 @@ //#include "tspecialstyleid.h" #include -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include "windows.h" #endif diff --git a/toonz/sources/include/ext/Potential.h b/toonz/sources/include/ext/Potential.h index 35fbb6c..d8d224e 100644 --- a/toonz/sources/include/ext/Potential.h +++ b/toonz/sources/include/ext/Potential.h @@ -25,7 +25,7 @@ class TStroke; -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) // to avoid annoying warning #pragma warning(push) #pragma warning(disable : 4290) @@ -96,7 +96,7 @@ public: }; } -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) #pragma warning(pop) #endif diff --git a/toonz/sources/include/ext/StrokeDeformation.h b/toonz/sources/include/ext/StrokeDeformation.h index d4a306b..19ac29b 100644 --- a/toonz/sources/include/ext/StrokeDeformation.h +++ b/toonz/sources/include/ext/StrokeDeformation.h @@ -30,7 +30,7 @@ class TStroke; -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) // to avoid annoying warning #pragma warning(push) #pragma warning(disable : 4251) @@ -197,7 +197,7 @@ public: }; } -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) #pragma warning(pop) #endif diff --git a/toonz/sources/include/ext/StrokeDeformationImpl.h b/toonz/sources/include/ext/StrokeDeformationImpl.h index febf72f..693c4a1 100644 --- a/toonz/sources/include/ext/StrokeDeformationImpl.h +++ b/toonz/sources/include/ext/StrokeDeformationImpl.h @@ -21,7 +21,7 @@ #include "ExtUtil.h" -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) // to avoid annoying warning #pragma warning(push) #pragma warning(disable : 4251) @@ -194,7 +194,7 @@ public: }; } -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) #pragma warning(pop) #endif diff --git a/toonz/sources/include/ext/StrokeParametricDeformer.h b/toonz/sources/include/ext/StrokeParametricDeformer.h index abd3218..b32414a 100644 --- a/toonz/sources/include/ext/StrokeParametricDeformer.h +++ b/toonz/sources/include/ext/StrokeParametricDeformer.h @@ -20,7 +20,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) // to avoid annoying warning #pragma warning(push) #pragma warning(disable : 4290) @@ -154,7 +154,7 @@ private: }; } -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) #pragma warning(pop) #endif diff --git a/toonz/sources/include/ext/Types.h b/toonz/sources/include/ext/Types.h index bd1ccfe..6a101a4 100644 --- a/toonz/sources/include/ext/Types.h +++ b/toonz/sources/include/ext/Types.h @@ -24,7 +24,7 @@ #include #include -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) // to avoid annoying warning #pragma warning(push) #pragma warning(disable : 4290) @@ -127,7 +127,7 @@ public: }; } -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) #pragma warning(pop) #endif diff --git a/toonz/sources/include/ext/plasticdeformerstorage.h b/toonz/sources/include/ext/plasticdeformerstorage.h index 36cab1b..70a0c1e 100644 --- a/toonz/sources/include/ext/plasticdeformerstorage.h +++ b/toonz/sources/include/ext/plasticdeformerstorage.h @@ -35,8 +35,8 @@ class PlasticSkeletonDeformation; struct DVAPI PlasticDeformerData { PlasticDeformer m_deformer; //!< The mesh deformer itself - double *m_so; //!< (owned) Faces' stacking order - double *m_output; //!< (owned) Output vertex coordinates + std::unique_ptr m_so; //!< (owned) Faces' stacking order + std::unique_ptr m_output; //!< (owned) Output vertex coordinates std::vector m_faceHints; //!< Handles' face hints @@ -56,7 +56,7 @@ private: //*********************************************************************************************** struct DVAPI PlasticDeformerDataGroup { - PlasticDeformerData *m_datas; //!< (owned) The deformer datas array. One per mesh. + std::unique_ptr m_datas; //!< (owned) The deformer datas array. One per mesh. std::vector m_handles; //!< Source handles (emanated from skeleton vertices). std::vector m_dstHandles; //!< Corresponding destination handle positions diff --git a/toonz/sources/include/ext/plasticskeleton.h b/toonz/sources/include/ext/plasticskeleton.h index 774ce79..17fc47a 100644 --- a/toonz/sources/include/ext/plasticskeleton.h +++ b/toonz/sources/include/ext/plasticskeleton.h @@ -152,7 +152,7 @@ private: //=============================================================================== -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/ext/plasticskeletondeformation.h b/toonz/sources/include/ext/plasticskeletondeformation.h index 17dad65..5776bab 100644 --- a/toonz/sources/include/ext/plasticskeletondeformation.h +++ b/toonz/sources/include/ext/plasticskeletondeformation.h @@ -251,7 +251,7 @@ typedef PlasticSkeletonDeformation SkD; //=============================================================================== -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/movsettings.h b/toonz/sources/include/movsettings.h index a6eb7fb..b75e0e3 100644 --- a/toonz/sources/include/movsettings.h +++ b/toonz/sources/include/movsettings.h @@ -15,7 +15,7 @@ #if !(defined(x64) || defined(__LP64__)) -#ifdef WIN32 +#ifdef _WIN32 #define list List #define map Map @@ -44,7 +44,7 @@ //#include "tlevel_io.h" #include "tproperty.h" -#else //WIN32 +#else // _WIN32 #define list List #define map Map @@ -60,7 +60,7 @@ #undef iterator #undef float_t -#endif //!WIN32 +#endif // !_WIN32 void DVAPI fromPropertiesToAtoms(TPropertyGroup &pg, QTAtomContainer &atoms); void DVAPI fromAtomsToProperties(const QTAtomContainer &atoms, TPropertyGroup &pg); diff --git a/toonz/sources/include/t32bitsrv_wrap.h b/toonz/sources/include/t32bitsrv_wrap.h index 5e2a6da..d12fc10 100644 --- a/toonz/sources/include/t32bitsrv_wrap.h +++ b/toonz/sources/include/t32bitsrv_wrap.h @@ -44,7 +44,7 @@ static QString srvName() return name; } -#ifdef WIN32 +#ifdef _WIN32 static QString srvCmdline() { static QString cmd("srv/t32bitsrv.exe " + srvName()); diff --git a/toonz/sources/include/tatomicvar.h b/toonz/sources/include/tatomicvar.h index a95ca8d..9be7724 100644 --- a/toonz/sources/include/tatomicvar.h +++ b/toonz/sources/include/tatomicvar.h @@ -13,7 +13,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #include #elif defined(__sgi) #include @@ -227,7 +227,7 @@ public: long operator++() { -#ifdef WIN32 +#ifdef _WIN32 return InterlockedIncrement(&m_var); #elif defined(__sgi) return ++m_var; @@ -244,7 +244,7 @@ public: long operator+=(long value) { -#ifdef WIN32 +#ifdef _WIN32 InterlockedExchangeAdd(&m_var, value); return m_var; @@ -266,7 +266,7 @@ public: long operator--() { -#ifdef WIN32 +#ifdef _WIN32 return InterlockedDecrement(&m_var); #elif defined(__sgi) return --m_var; @@ -300,7 +300,7 @@ public: #endif }; -#ifdef WIN32 +#ifdef _WIN32 long m_var; #elif defined(__sgi) long m_var; diff --git a/toonz/sources/include/tcachedlevel.h b/toonz/sources/include/tcachedlevel.h index 992ec4f..82584af 100644 --- a/toonz/sources/include/tcachedlevel.h +++ b/toonz/sources/include/tcachedlevel.h @@ -7,7 +7,7 @@ PER ORA SI PUO' USARE LA CACHE SOLO CON WINDOWS */ -#ifdef WIN32 +#ifdef _WIN32 #include #endif @@ -292,7 +292,7 @@ private: int m_viewFrameMin, m_viewFrameMax; -#ifdef WIN32 +#ifdef _WIN32 HANDLE m_hFile, m_hMap; LPVOID m_fileMapAddress; diff --git a/toonz/sources/include/tcli.h b/toonz/sources/include/tcli.h index 5aa2f59..e46fcf8 100644 --- a/toonz/sources/include/tcli.h +++ b/toonz/sources/include/tcli.h @@ -242,16 +242,11 @@ public: template class MultiArgumentT : public MultiArgument { - T *m_values; + std::unique_ptr m_values; public: MultiArgumentT(string name, string help) - : MultiArgument(name, help), m_values(0){}; - ~MultiArgumentT() - { - if (m_values) - delete[] m_values; - }; + : MultiArgument(name, help) {} T operator[](int index) { assert(0 <= index && index < m_count); @@ -273,17 +268,13 @@ public: void resetValue() { - if (m_values) - delete[] m_values; - m_values = 0; + m_values.reset(); m_count = m_index = 0; }; void allocate(int count) { - if (m_values) - delete[] m_values; - m_values = count ? new T[count] : 0; + m_values.reset((count > 0) ? new T[count] : nullptr); m_count = count; m_index = 0; }; @@ -298,7 +289,7 @@ typedef UsageElement *UsageElementPtr; class DVAPI UsageLine { protected: - UsageElementPtr *m_elements; + std::unique_ptr m_elements; int m_count; public: diff --git a/toonz/sources/include/tcolorstyles.h b/toonz/sources/include/tcolorstyles.h index 2700dbc..7aa65fe 100644 --- a/toonz/sources/include/tcolorstyles.h +++ b/toonz/sources/include/tcolorstyles.h @@ -362,7 +362,7 @@ protected: //-------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif typedef TSmartPointerT TColorStyleP; diff --git a/toonz/sources/include/tcolumnset.h b/toonz/sources/include/tcolumnset.h index 534f4bb..4a8b613 100644 --- a/toonz/sources/include/tcolumnset.h +++ b/toonz/sources/include/tcolumnset.h @@ -54,7 +54,7 @@ private: //--------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/tcommon.h b/toonz/sources/include/tcommon.h index 9bd6950..b55efa0 100644 --- a/toonz/sources/include/tcommon.h +++ b/toonz/sources/include/tcommon.h @@ -3,7 +3,7 @@ #ifndef T_COMMON_INCLUDED #define T_COMMON_INCLUDED -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4786) #pragma warning(disable : 4251) #pragma warning(disable : 4146) @@ -137,7 +137,7 @@ typedef unsigned short USHORT; typedef short SHORT; typedef unsigned int UINT; -#ifndef WIN32 +#ifndef _WIN32 typedef unsigned char BYTE; #endif @@ -232,7 +232,7 @@ const int c_minint = ~c_maxint; const unsigned int c_maxuint = (unsigned int)(~0U); -#ifdef WIN32 +#ifdef _WIN32 #define DV_EXPORT_API __declspec(dllexport) #define DV_IMPORT_API __declspec(dllimport) #define DV_EXPORT_VAR __declspec(dllexport) @@ -244,7 +244,7 @@ const unsigned int c_maxuint = (unsigned int)(~0U); #define DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #define DV_ALIGNED(val) __declspec(align(val)) #else #define DV_ALIGNED(val) __attribute__((aligned(val))) @@ -277,7 +277,7 @@ inline TINT32 swapTINT32(TINT32 val) } inline USHORT swapUshort(USHORT val) { return val >> 8 | val << 8; } -inline ostream &operator<<(ostream &out, const string &s) +inline std::ostream &operator<<(std::ostream &out, const std::string &s) { return out << s.c_str(); } diff --git a/toonz/sources/include/tcontenthistory.h b/toonz/sources/include/tcontenthistory.h index a563279..ce882e2 100644 --- a/toonz/sources/include/tcontenthistory.h +++ b/toonz/sources/include/tcontenthistory.h @@ -10,7 +10,6 @@ #include #include -using namespace std; #undef DVAPI #undef DVVAR #ifdef TNZCORE_EXPORTS diff --git a/toonz/sources/include/tconvert.h b/toonz/sources/include/tconvert.h index c496867..dc9344a 100644 --- a/toonz/sources/include/tconvert.h +++ b/toonz/sources/include/tconvert.h @@ -18,31 +18,31 @@ class TFilePath; #define DVAPI DV_IMPORT_API #endif -DVAPI bool isInt(string s); -DVAPI bool isDouble(string s); +DVAPI bool isInt(std::string s); +DVAPI bool isDouble(std::string s); -DVAPI string toString(int v); -DVAPI string toString(unsigned long v); -DVAPI string toString(unsigned long long v); -DVAPI string toString(double v, int prec = -1); -DVAPI string toString(wstring s); -DVAPI string toString(const TFilePath &fp); -DVAPI string toString(void *p); +DVAPI std::string toString(int v); +DVAPI std::string toString(unsigned long v); +DVAPI std::string toString(unsigned long long v); +DVAPI std::string toString(double v, int prec = -1); +DVAPI std::string toString(wstring s); +DVAPI std::string toString(const TFilePath &fp); +DVAPI std::string toString(void *p); -DVAPI int toInt(string s); -DVAPI double toDouble(string s); +DVAPI int toInt(std::string s); +DVAPI double toDouble(std::string s); -DVAPI bool isInt(wstring s); -DVAPI bool isDouble(wstring s); +DVAPI bool isInt(std::wstring s); +DVAPI bool isDouble(std::wstring s); -DVAPI wstring toWideString(string s); -DVAPI wstring toWideString(int v); -DVAPI wstring toWideString(double v, int prec = -1); +DVAPI std::wstring toWideString(std::string s); +DVAPI std::wstring toWideString(int v); +DVAPI std::wstring toWideString(double v, int prec = -1); -DVAPI int toInt(wstring s); -DVAPI double toDouble(wstring s); +DVAPI int toInt(std::wstring s); +DVAPI double toDouble(std::wstring s); -inline bool fromStr(int &v, string s) +inline bool fromStr(int &v, std::string s) { if (isInt(s)) { v = toInt(s); @@ -51,7 +51,7 @@ inline bool fromStr(int &v, string s) return false; } -inline bool fromStr(double &v, string s) +inline bool fromStr(double &v, std::string s) { if (isDouble(s)) { v = toDouble(s); @@ -60,17 +60,17 @@ inline bool fromStr(double &v, string s) return false; } -inline bool fromStr(string &out, string s) +inline bool fromStr(std::string &out, std::string s) { out = s; return true; } -DVAPI string toUpper(string a); -DVAPI string toLower(string a); +DVAPI std::string toUpper(std::string a); +DVAPI std::string toLower(std::string a); -DVAPI wstring toUpper(wstring a); -DVAPI wstring toLower(wstring a); +DVAPI std::wstring toUpper(std::wstring a); +DVAPI std::wstring toLower(std::wstring a); #ifndef TNZCORE_LIGHT #include diff --git a/toonz/sources/include/tdata.h b/toonz/sources/include/tdata.h index 9ca3980..d34d8f9 100644 --- a/toonz/sources/include/tdata.h +++ b/toonz/sources/include/tdata.h @@ -19,7 +19,7 @@ //------------------------------------------------------------------- class TData; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif @@ -55,7 +55,7 @@ public: //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) #endif @@ -72,7 +72,7 @@ public: TFilePath getFilePath(int i) const; }; -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif diff --git a/toonz/sources/include/tdoubleparam.h b/toonz/sources/include/tdoubleparam.h index 3cc51f6..c391709 100644 --- a/toonz/sources/include/tdoubleparam.h +++ b/toonz/sources/include/tdoubleparam.h @@ -40,7 +40,7 @@ class Grammar; class CalculatorNodeVisitor; } -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TPersistDeclarationT; #endif diff --git a/toonz/sources/include/tfarmcontroller.h b/toonz/sources/include/tfarmcontroller.h index d484673..81faf5f 100644 --- a/toonz/sources/include/tfarmcontroller.h +++ b/toonz/sources/include/tfarmcontroller.h @@ -18,7 +18,7 @@ class TFilePath; #undef TFARMAPI #endif -#ifdef WIN32 +#ifdef _WIN32 #ifdef TFARM_EXPORTS #define TFARMAPI __declspec(dllexport) #else diff --git a/toonz/sources/include/tfarmserver.h b/toonz/sources/include/tfarmserver.h index 3470f04..9e57f89 100644 --- a/toonz/sources/include/tfarmserver.h +++ b/toonz/sources/include/tfarmserver.h @@ -15,7 +15,7 @@ #undef TFARMAPI #endif -#ifdef WIN32 +#ifdef _WIN32 #ifdef TFARM_EXPORTS #define TFARMAPI __declspec(dllexport) #else diff --git a/toonz/sources/include/tfarmtask.h b/toonz/sources/include/tfarmtask.h index aa05298..26346bd 100644 --- a/toonz/sources/include/tfarmtask.h +++ b/toonz/sources/include/tfarmtask.h @@ -12,7 +12,7 @@ #undef TFARMAPI #endif -#ifdef WIN32 +#ifdef _WIN32 #ifdef TFARM_EXPORTS #define TFARMAPI __declspec(dllexport) #else diff --git a/toonz/sources/include/tfont.h b/toonz/sources/include/tfont.h index 84763e7..6487c36 100644 --- a/toonz/sources/include/tfont.h +++ b/toonz/sources/include/tfont.h @@ -54,7 +54,7 @@ private: friend class TFontManager; Impl *m_pimpl; -#ifdef WIN32 +#ifdef _WIN32 TFont(const LOGFONTW &, HDC hdc); #else TFont(ATSUFontID, int size); diff --git a/toonz/sources/include/tfx.h b/toonz/sources/include/tfx.h index 4be1eaa..dc6807d 100644 --- a/toonz/sources/include/tfx.h +++ b/toonz/sources/include/tfx.h @@ -361,7 +361,7 @@ public: //=================================================================== -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif typedef TSmartPointerT TFxP; diff --git a/toonz/sources/include/tgeometry.h b/toonz/sources/include/tgeometry.h index d689575..28ac4a6 100644 --- a/toonz/sources/include/tgeometry.h +++ b/toonz/sources/include/tgeometry.h @@ -105,7 +105,7 @@ inline ostream &operator<<(ostream &out, const TPointT &p) typedef TPointT TPoint, TPointI; typedef TPointT TPointD; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TPointT; template class DVAPI TPointT; #endif @@ -330,7 +330,7 @@ inline ostream &operator<<(ostream &out, const T3DPointT &p) typedef T3DPointT T3DPoint, T3DPointI; typedef T3DPointT T3DPointD; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI T3DPointT; template class DVAPI T3DPointT; #endif @@ -618,7 +618,7 @@ inline ostream &operator<<(ostream &out, const TDimensionT &p) return out << "(" << p.lx << ", " << p.ly << ")"; } -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TDimensionT; template class DVAPI TDimensionT; #endif @@ -786,7 +786,7 @@ public: typedef TRectT TRect, TRectI; typedef TRectT TRectD; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TRectT; template class DVAPI TRectT; #endif diff --git a/toonz/sources/include/tgl.h b/toonz/sources/include/tgl.h index c41a05f..6f3e3cc 100644 --- a/toonz/sources/include/tgl.h +++ b/toonz/sources/include/tgl.h @@ -6,7 +6,7 @@ //#include "tgeometry.h" #include "tmachine.h" -#ifdef WIN32 +#ifdef _WIN32 #include //#endif @@ -247,7 +247,7 @@ void DVAPI tglBuildMipmaps(std::vector &rasters, //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 typedef std::pair TGlContext; #else typedef void *TGlContext; diff --git a/toonz/sources/include/timage.h b/toonz/sources/include/timage.h index 39129df..de5fa33 100644 --- a/toonz/sources/include/timage.h +++ b/toonz/sources/include/timage.h @@ -86,7 +86,7 @@ private: //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/timage_io.h b/toonz/sources/include/timage_io.h index 5918f94..ac80f00 100644 --- a/toonz/sources/include/timage_io.h +++ b/toonz/sources/include/timage_io.h @@ -181,7 +181,7 @@ public: //----------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif @@ -248,7 +248,7 @@ public: //----------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/timagecache.h b/toonz/sources/include/timagecache.h index ec44926..a9f8f94 100644 --- a/toonz/sources/include/timagecache.h +++ b/toonz/sources/include/timagecache.h @@ -169,7 +169,7 @@ public: //----------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/tlevel.h b/toonz/sources/include/tlevel.h index cf9b240..80d7ade 100644 --- a/toonz/sources/include/tlevel.h +++ b/toonz/sources/include/tlevel.h @@ -72,7 +72,7 @@ public: //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/tlevel_io.h b/toonz/sources/include/tlevel_io.h index 15d34ea..034a141 100644 --- a/toonz/sources/include/tlevel_io.h +++ b/toonz/sources/include/tlevel_io.h @@ -7,7 +7,7 @@ #include "timage_io.h" #include "tproperty.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4290) #pragma warning(disable : 4251) @@ -113,7 +113,7 @@ private: //----------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif @@ -221,7 +221,7 @@ public: //----------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/tmacrofx.h b/toonz/sources/include/tmacrofx.h index 9e200fe..23f4496 100644 --- a/toonz/sources/include/tmacrofx.h +++ b/toonz/sources/include/tmacrofx.h @@ -15,7 +15,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/tmeshimage.h b/toonz/sources/include/tmeshimage.h index 5c84e12..8d91328 100644 --- a/toonz/sources/include/tmeshimage.h +++ b/toonz/sources/include/tmeshimage.h @@ -145,7 +145,7 @@ public: //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif @@ -204,7 +204,7 @@ public: //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -215,7 +215,7 @@ public: TMeshImageP() {} TMeshImageP(TMeshImage *image) : DerivedSmartPointer(image) {} TMeshImageP(TImageP image) : DerivedSmartPointer(image) {} -#if !defined(WIN32) +#if !defined(_WIN32) TMeshImageP(TImage *image) : DerivedSmartPointer(TImageP(image)) { } diff --git a/toonz/sources/include/tmsgcore.h b/toonz/sources/include/tmsgcore.h index 8e328da..36f8e11 100644 --- a/toonz/sources/include/tmsgcore.h +++ b/toonz/sources/include/tmsgcore.h @@ -41,8 +41,6 @@ void DVAPI warning(const QString &msg); void DVAPI info(const QString &msg); }; -using namespace DVGui; - class DVAPI TMsgCore : public QObject { Q_OBJECT @@ -59,7 +57,7 @@ public: //client side // 'send' returns false if the tmessage is not active in the application (tipically, in console applications such as tcomposer) - bool send(MsgType type, const QString &message); + bool send(DVGui::MsgType type, const QString &message); void connectTo(const QString &address = ""); //server side diff --git a/toonz/sources/include/tnotanimatableparam.h b/toonz/sources/include/tnotanimatableparam.h index b4cab57..d44b5c2 100644 --- a/toonz/sources/include/tnotanimatableparam.h +++ b/toonz/sources/include/tnotanimatableparam.h @@ -26,7 +26,7 @@ // TNotAnimatableParamChange //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) #endif @@ -185,7 +185,7 @@ public: // //========================================================= -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TNotAnimatableParam; class TIntParam; template class DVAPI TPersistDeclarationT; @@ -220,7 +220,7 @@ DEFINE_PARAM_SMARTPOINTER(TIntParam, int) // //========================================================= -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TNotAnimatableParam; class TBoolParam; template class DVAPI TPersistDeclarationT; @@ -248,7 +248,7 @@ DEFINE_PARAM_SMARTPOINTER(TBoolParam, bool) // //========================================================= -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TNotAnimatableParam; class TFilePathParam; template class DVAPI TPersistDeclarationT; @@ -274,7 +274,7 @@ DEFINE_PARAM_SMARTPOINTER(TFilePathParam, TFilePath) // //========================================================= -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TNotAnimatableParam; class TStringParam; template class DVAPI TPersistDeclarationT; @@ -358,7 +358,7 @@ public: // //========================================================= -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TNotAnimatableParam; class TNADoubleParam; template class DVAPI TPersistDeclarationT; @@ -457,7 +457,7 @@ TUndo *TNotAnimatableParamChange::createUndo() const //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif diff --git a/toonz/sources/include/tnztypes.h b/toonz/sources/include/tnztypes.h index 3e70dfc..b6ada7e 100644 --- a/toonz/sources/include/tnztypes.h +++ b/toonz/sources/include/tnztypes.h @@ -3,7 +3,7 @@ #ifndef TNZTYPES_H #define TNZTYPES_H -#ifdef WIN32 +#ifdef _WIN32 #define TINT32 __int32 typedef unsigned __int32 TUINT32; typedef __int64 TINT64; diff --git a/toonz/sources/include/tools/cursors.h b/toonz/sources/include/tools/cursors.h index 3311174..0bfe01d 100644 --- a/toonz/sources/include/tools/cursors.h +++ b/toonz/sources/include/tools/cursors.h @@ -14,7 +14,7 @@ enum { CURSOR_HOURGLASS, CURSOR_NO, CURSOR_DUMMY, -#ifndef WIN32 +#ifndef _WIN32 CURSOR_DND, CURSOR_QUESTION, #endif diff --git a/toonz/sources/include/tools/toolutils.h b/toonz/sources/include/tools/toolutils.h index 7a30272..cab1634 100644 --- a/toonz/sources/include/tools/toolutils.h +++ b/toonz/sources/include/tools/toolutils.h @@ -37,8 +37,6 @@ #define DVVAR DV_IMPORT_VAR #endif -using namespace std; - //=================================================================== // Forward declarations diff --git a/toonz/sources/include/toonz/Naa2TlvConverter.h b/toonz/sources/include/toonz/Naa2TlvConverter.h index ca368b3..807f505 100644 --- a/toonz/sources/include/toonz/Naa2TlvConverter.h +++ b/toonz/sources/include/toonz/Naa2TlvConverter.h @@ -30,14 +30,13 @@ class WorkRaster public: typedef T Pixel; WorkRaster(int lx, int ly) : m_lx(lx), m_ly(ly), m_buffer(new Pixel[lx * ly]) {} - ~WorkRaster() { delete[] m_buffer; } inline int getLx() const { return m_lx; } inline int getLy() const { return m_ly; } - inline Pixel *pixels(int y = 0) const { return m_buffer + m_lx * y; } + inline Pixel *pixels(int y = 0) const { return m_buffer.get() + m_lx * y; } private: - Pixel *m_buffer; + std::unique_ptr m_buffer; int m_lx, m_ly; }; diff --git a/toonz/sources/include/toonz/imagemanager.h b/toonz/sources/include/toonz/imagemanager.h index 273c056..94aa6c0 100644 --- a/toonz/sources/include/toonz/imagemanager.h +++ b/toonz/sources/include/toonz/imagemanager.h @@ -262,7 +262,7 @@ private: //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif diff --git a/toonz/sources/include/toonz/tproject.h b/toonz/sources/include/toonz/tproject.h index bd52fed..7be64a3 100644 --- a/toonz/sources/include/toonz/tproject.h +++ b/toonz/sources/include/toonz/tproject.h @@ -95,7 +95,7 @@ private: TProject &operator=(const TProject &); }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif typedef TSmartPointerT TProjectP; diff --git a/toonz/sources/include/toonz/tstageobject.h b/toonz/sources/include/toonz/tstageobject.h index 4d25db0..12177fc 100644 --- a/toonz/sources/include/toonz/tstageobject.h +++ b/toonz/sources/include/toonz/tstageobject.h @@ -547,7 +547,7 @@ private: //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/toonz/tstageobjectspline.h b/toonz/sources/include/toonz/tstageobjectspline.h index b2b46f9..345798d 100644 --- a/toonz/sources/include/toonz/tstageobjectspline.h +++ b/toonz/sources/include/toonz/tstageobjectspline.h @@ -92,7 +92,7 @@ private: void updatePosPathKeyframes(TStroke *oldSpline, TStroke *newSpline); }; -#ifdef WIN32 +#ifdef _WIN32 template class TSmartPointerT; #endif diff --git a/toonz/sources/include/toonz/txshchildlevel.h b/toonz/sources/include/toonz/txshchildlevel.h index f2613c3..846db0e 100644 --- a/toonz/sources/include/toonz/txshchildlevel.h +++ b/toonz/sources/include/toonz/txshchildlevel.h @@ -92,7 +92,7 @@ private: TXshChildLevel &operator=(const TXshChildLevel &); }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif typedef TSmartPointerT TXshChildLevelP; diff --git a/toonz/sources/include/toonz/txshcolumn.h b/toonz/sources/include/toonz/txshcolumn.h index 93f0a16..29f4a95 100644 --- a/toonz/sources/include/toonz/txshcolumn.h +++ b/toonz/sources/include/toonz/txshcolumn.h @@ -232,7 +232,7 @@ public: void setColorTag(int colorTag) { m_colorTag = colorTag; } //Usato solo in tabkids }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif typedef TSmartPointerT TXshColumnP; diff --git a/toonz/sources/include/toonz/txsheet.h b/toonz/sources/include/toonz/txsheet.h index ee91d06..9e2104f 100644 --- a/toonz/sources/include/toonz/txsheet.h +++ b/toonz/sources/include/toonz/txsheet.h @@ -456,7 +456,7 @@ private: //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif typedef TSmartPointerT TXsheetP; diff --git a/toonz/sources/include/toonz/txshlevel.h b/toonz/sources/include/toonz/txshlevel.h index 6d04bd5..7ac5b88 100644 --- a/toonz/sources/include/toonz/txshlevel.h +++ b/toonz/sources/include/toonz/txshlevel.h @@ -146,7 +146,7 @@ private: TXshLevel &operator=(const TXshLevel &); }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif diff --git a/toonz/sources/include/toonz/txshlevelcolumn.h b/toonz/sources/include/toonz/txshlevelcolumn.h index 1a1c5c2..fb2be48 100644 --- a/toonz/sources/include/toonz/txshlevelcolumn.h +++ b/toonz/sources/include/toonz/txshlevelcolumn.h @@ -90,7 +90,7 @@ private: TXshLevelColumn &operator=(const TXshLevelColumn &); }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif diff --git a/toonz/sources/include/toonz/txshmeshcolumn.h b/toonz/sources/include/toonz/txshmeshcolumn.h index d31129b..e7b88d5 100644 --- a/toonz/sources/include/toonz/txshmeshcolumn.h +++ b/toonz/sources/include/toonz/txshmeshcolumn.h @@ -44,7 +44,7 @@ private: //--------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/toonz/txshpalettecolumn.h b/toonz/sources/include/toonz/txshpalettecolumn.h index e633aea..70e8802 100644 --- a/toonz/sources/include/toonz/txshpalettecolumn.h +++ b/toonz/sources/include/toonz/txshpalettecolumn.h @@ -56,7 +56,7 @@ private: TXshPaletteColumn &operator=(const TXshPaletteColumn &); }; -#ifdef WIN32 +#ifdef _WIN32 template class TSmartPointerT; #endif diff --git a/toonz/sources/include/toonz/txshpalettelevel.h b/toonz/sources/include/toonz/txshpalettelevel.h index 3f14714..494e2a0 100644 --- a/toonz/sources/include/toonz/txshpalettelevel.h +++ b/toonz/sources/include/toonz/txshpalettelevel.h @@ -106,7 +106,7 @@ private: TXshPaletteLevel &operator=(const TXshPaletteLevel &); }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif typedef TSmartPointerT TXshPaletteLevelP; diff --git a/toonz/sources/include/toonz/txshsimplelevel.h b/toonz/sources/include/toonz/txshsimplelevel.h index 93eadb1..253478d 100644 --- a/toonz/sources/include/toonz/txshsimplelevel.h +++ b/toonz/sources/include/toonz/txshsimplelevel.h @@ -361,7 +361,7 @@ private: //===================================================================================== -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif typedef TSmartPointerT TXshSimpleLevelP; diff --git a/toonz/sources/include/toonz/txshsoundcolumn.h b/toonz/sources/include/toonz/txshsoundcolumn.h index 4a62f92..f121bd6 100644 --- a/toonz/sources/include/toonz/txshsoundcolumn.h +++ b/toonz/sources/include/toonz/txshsoundcolumn.h @@ -149,7 +149,7 @@ protected slots: void onTimerOut(); }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif typedef TSmartPointerT TXshSoundColumnP; diff --git a/toonz/sources/include/toonz/txshsoundlevel.h b/toonz/sources/include/toonz/txshsoundlevel.h index 9340f3a..9f4608c 100644 --- a/toonz/sources/include/toonz/txshsoundlevel.h +++ b/toonz/sources/include/toonz/txshsoundlevel.h @@ -93,7 +93,7 @@ private: TXshSoundLevel &operator=(const TXshSoundLevel &); }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif typedef TSmartPointerT TXshSoundLevelP; diff --git a/toonz/sources/include/toonz/txshsoundtextcolumn.h b/toonz/sources/include/toonz/txshsoundtextcolumn.h index bed8dff..fb7c88b 100644 --- a/toonz/sources/include/toonz/txshsoundtextcolumn.h +++ b/toonz/sources/include/toonz/txshsoundtextcolumn.h @@ -44,7 +44,7 @@ public: void saveData(TOStream &os); }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif typedef TSmartPointerT TXshSoundTextColumnP; diff --git a/toonz/sources/include/toonz/txshsoundtextlevel.h b/toonz/sources/include/toonz/txshsoundtextlevel.h index e9cfac8..17be83b 100644 --- a/toonz/sources/include/toonz/txshsoundtextlevel.h +++ b/toonz/sources/include/toonz/txshsoundtextlevel.h @@ -55,7 +55,7 @@ private: TXshSoundTextLevel &operator=(const TXshSoundTextLevel &); }; -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT; #endif typedef TSmartPointerT TXshSoundTextLevelP; diff --git a/toonz/sources/include/toonz/txshzeraryfxcolumn.h b/toonz/sources/include/toonz/txshzeraryfxcolumn.h index 6be833d..37f7318 100644 --- a/toonz/sources/include/toonz/txshzeraryfxcolumn.h +++ b/toonz/sources/include/toonz/txshzeraryfxcolumn.h @@ -85,7 +85,7 @@ private: TXshZeraryFxColumn &operator=(const TXshZeraryFxColumn &); }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/toonzqt/camerasettingswidget.h b/toonz/sources/include/toonzqt/camerasettingswidget.h index 9b863be..529de4f 100644 --- a/toonz/sources/include/toonzqt/camerasettingswidget.h +++ b/toonz/sources/include/toonzqt/camerasettingswidget.h @@ -3,7 +3,7 @@ #ifndef CAMERASETTINGSWIDGET_H #define CAMERASETTINGSWIDGET_H -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/cleanupcamerasettingswidget.h b/toonz/sources/include/toonzqt/cleanupcamerasettingswidget.h index eee872c..03d2047 100644 --- a/toonz/sources/include/toonzqt/cleanupcamerasettingswidget.h +++ b/toonz/sources/include/toonzqt/cleanupcamerasettingswidget.h @@ -3,7 +3,7 @@ #ifndef CLEANUPCAMERASETTINGSWIDGET_H #define CLEANUPCAMERASETTINGSWIDGET_H -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/colorfield.h b/toonz/sources/include/toonzqt/colorfield.h index 83cb8d0..f0abda3 100644 --- a/toonz/sources/include/toonzqt/colorfield.h +++ b/toonz/sources/include/toonzqt/colorfield.h @@ -3,7 +3,7 @@ #ifndef COLORFIELD_H #define COLORFIELD_H -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/combohistogram.h b/toonz/sources/include/toonzqt/combohistogram.h index 7f4f9dc..e65f2ed 100644 --- a/toonz/sources/include/toonzqt/combohistogram.h +++ b/toonz/sources/include/toonzqt/combohistogram.h @@ -19,7 +19,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/dvdialog.h b/toonz/sources/include/toonzqt/dvdialog.h index b3bf857..40f794c 100644 --- a/toonz/sources/include/toonzqt/dvdialog.h +++ b/toonz/sources/include/toonzqt/dvdialog.h @@ -34,7 +34,7 @@ class QLabel; class TXsheetHandle; class TPalette; -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif @@ -244,7 +244,7 @@ signals: 0 -> Cancel or Close Popup, 1,2,3,... -> checkbox clicked. */ -class DVAPI RadioButtonDialog : public Dialog +class DVAPI RadioButtonDialog : public DVGui::Dialog { Q_OBJECT @@ -267,7 +267,7 @@ int DVAPI RadioButtonMsgBox(MsgType type, const QString &labelText, //----------------------------------------------------------------------------- -class DVAPI ProgressDialog : public Dialog +class DVAPI ProgressDialog : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/include/toonzqt/dvtextedit.h b/toonz/sources/include/toonzqt/dvtextedit.h index 2b0f67e..63310bd 100644 --- a/toonz/sources/include/toonzqt/dvtextedit.h +++ b/toonz/sources/include/toonzqt/dvtextedit.h @@ -3,7 +3,7 @@ #ifndef DVTEXTEDIT_H #define DVTEXTEDIT_H -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/fxsettings.h b/toonz/sources/include/toonzqt/fxsettings.h index 1f2d590..19ced46 100644 --- a/toonz/sources/include/toonzqt/fxsettings.h +++ b/toonz/sources/include/toonzqt/fxsettings.h @@ -3,7 +3,7 @@ #ifndef FXSETTINGS_H #define FXSETTINGS_H -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif @@ -50,8 +50,6 @@ class TXshLevelHandle; class TObjectHandle; class ToonzScene; -using namespace DVGui; - //============================================================================= /*! \brief ParamsPage. View a page with fx params. @@ -132,7 +130,7 @@ class DVAPI ParamsPageSet : public QWidget Q_OBJECT TabBarContainter *m_tabBarContainer; - TabBar *m_tabBar; + DVGui::TabBar *m_tabBar; QStackedWidget *m_pagesList; ParamViewer *m_parent; diff --git a/toonz/sources/include/toonzqt/histogram.h b/toonz/sources/include/toonzqt/histogram.h index 15a7007..599bec8 100644 --- a/toonz/sources/include/toonzqt/histogram.h +++ b/toonz/sources/include/toonzqt/histogram.h @@ -21,7 +21,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/paramfield.h b/toonz/sources/include/toonzqt/paramfield.h index a73236f..047e1e6 100644 --- a/toonz/sources/include/toonzqt/paramfield.h +++ b/toonz/sources/include/toonzqt/paramfield.h @@ -3,7 +3,7 @@ #ifndef PARAMFIELD_H #define PARAMFIELD_H -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/styleeditor.h b/toonz/sources/include/toonzqt/styleeditor.h index 269c2c8..a47981a 100644 --- a/toonz/sources/include/toonzqt/styleeditor.h +++ b/toonz/sources/include/toonzqt/styleeditor.h @@ -76,8 +76,6 @@ class StyleEditor; //============================================= -using namespace DVGui; - //============================================================================= namespace StyleEditorGUI { @@ -337,7 +335,7 @@ signals: /*! \brief The ChannelLineEdit is a cutomized version of IntLineEdit for channel value. It calls selectAll() at the moment of the first click. */ -class ChannelLineEdit : public IntLineEdit +class ChannelLineEdit : public DVGui::IntLineEdit { Q_OBJECT @@ -591,11 +589,11 @@ class DVAPI StyleEditor : public QWidget TXshLevelHandle *m_levelHandle; //!< for clearing the level cache when the color changed - TabBar *m_styleBar; + DVGui::TabBar *m_styleBar; QStackedWidget *m_styleChooser; - StyleSample *m_newColor; //!< New style viewer (lower-right panel side). - StyleSample *m_oldColor; //!< Old style viewer (lower-right panel side). + DVGui::StyleSample *m_newColor; //!< New style viewer (lower-right panel side). + DVGui::StyleSample *m_oldColor; //!< Old style viewer (lower-right panel side). #ifndef STUDENT QPushButton *m_autoButton; //!< "Auto Apply" checkbox on the right panel side. diff --git a/toonz/sources/include/toonzqt/swatchviewer.h b/toonz/sources/include/toonzqt/swatchviewer.h index 5ac3151..7cd8f5e 100644 --- a/toonz/sources/include/toonzqt/swatchviewer.h +++ b/toonz/sources/include/toonzqt/swatchviewer.h @@ -3,7 +3,7 @@ #ifndef SWATCHVIEWER_H #define SWATCHVIEWER_H -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/tabbar.h b/toonz/sources/include/toonzqt/tabbar.h index 0b2b033..a2170b8 100644 --- a/toonz/sources/include/toonzqt/tabbar.h +++ b/toonz/sources/include/toonzqt/tabbar.h @@ -16,7 +16,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/toonzqt/tmessageviewer.h b/toonz/sources/include/toonzqt/tmessageviewer.h index 7376030..427ef44 100644 --- a/toonz/sources/include/toonzqt/tmessageviewer.h +++ b/toonz/sources/include/toonzqt/tmessageviewer.h @@ -23,8 +23,6 @@ class MySortFilterProxyModel; class QCheckBox; class QStandardItemModel; -using namespace DVGui; - class DVAPI TMessageRepository : public QObject { QStandardItemModel *m_sim; diff --git a/toonz/sources/include/toonzqt/validatedchoicedialog.h b/toonz/sources/include/toonzqt/validatedchoicedialog.h index 6e227ae..f5a1157 100644 --- a/toonz/sources/include/toonzqt/validatedchoicedialog.h +++ b/toonz/sources/include/toonzqt/validatedchoicedialog.h @@ -41,7 +41,7 @@ namespace DVGui ValidatedChoiceDialog() constructor. */ -class DVAPI ValidatedChoiceDialog : public Dialog +class DVAPI ValidatedChoiceDialog : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/include/tpalette.h b/toonz/sources/include/tpalette.h index f641467..6d506f9 100644 --- a/toonz/sources/include/tpalette.h +++ b/toonz/sources/include/tpalette.h @@ -23,7 +23,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) #endif @@ -315,13 +315,13 @@ private: //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif diff --git a/toonz/sources/include/tparam.h b/toonz/sources/include/tparam.h index 639861a..dc34bad 100644 --- a/toonz/sources/include/tparam.h +++ b/toonz/sources/include/tparam.h @@ -153,14 +153,14 @@ private: //--------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif typedef TSmartPointerT TParamP; //========================================================= -#ifdef WIN32 +#ifdef _WIN32 #define DVAPI_PARAM_SMARTPOINTER(PARAM) \ template class DVAPI TSmartPointerT; \ template class DVAPI TDerivedSmartPointerT; diff --git a/toonz/sources/include/tparamset.h b/toonz/sources/include/tparamset.h index 9b13375..8b68c2a 100644 --- a/toonz/sources/include/tparamset.h +++ b/toonz/sources/include/tparamset.h @@ -42,7 +42,7 @@ public: //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) #endif @@ -107,11 +107,11 @@ private: TParamSetImp *m_imp; }; -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -131,7 +131,7 @@ public: //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 class TPointParam; template class DVAPI TPersistDeclarationT; #endif @@ -173,7 +173,7 @@ DEFINE_PARAM_SMARTPOINTER(TPointParam, TPointD) //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 class TPixelParam; template class DVAPI TPersistDeclarationT; #endif @@ -240,7 +240,7 @@ public: //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 class TRangeParam; template class DVAPI TPersistDeclarationT; #endif diff --git a/toonz/sources/include/tpixel.h b/toonz/sources/include/tpixel.h index 4014f18..a866945 100644 --- a/toonz/sources/include/tpixel.h +++ b/toonz/sources/include/tpixel.h @@ -160,7 +160,7 @@ public: undefined machine order !!!! #endif -#ifdef WIN32 +#ifdef _WIN32 TPixelRGBM64() : r(0), g(0), b(0), m(maxChannelValue){}; TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue) : r(rr), g(gg), b(bb), m(mm){}; diff --git a/toonz/sources/include/tpluginmanager.h b/toonz/sources/include/tpluginmanager.h index 9aa6598..e4c01f6 100644 --- a/toonz/sources/include/tpluginmanager.h +++ b/toonz/sources/include/tpluginmanager.h @@ -55,7 +55,7 @@ public: // // L'entry point del plugin e' TLIBMAIN {....} // -#ifdef WIN32 +#ifdef _WIN32 #define TLIBMAIN \ extern "C" __declspec(dllexport) \ const TPluginInfo * \ diff --git a/toonz/sources/include/tproperty.h b/toonz/sources/include/tproperty.h index f844562..98cc3fb 100644 --- a/toonz/sources/include/tproperty.h +++ b/toonz/sources/include/tproperty.h @@ -16,7 +16,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) #endif @@ -163,7 +163,7 @@ private: }; //--------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TRangeProperty; template class DVAPI TRangeProperty; #endif @@ -503,7 +503,7 @@ private: //--------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif diff --git a/toonz/sources/include/traster.h b/toonz/sources/include/traster.h index cc35663..9596a0d 100644 --- a/toonz/sources/include/traster.h +++ b/toonz/sources/include/traster.h @@ -212,7 +212,7 @@ private: // Smart Pointer a TRaster // -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif @@ -440,7 +440,7 @@ inline TRasterPT::TRasterPT(int lx, int ly, int wrap, T *buffer, bool bufferO //--------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 // su NT e' necessario per evitare un warning nelle classi // esportate che si riferiscono a TRaster32P/TRaster64P // su IRIX non compila perche' non riesce ad instanziare le diff --git a/toonz/sources/include/trastercm.h b/toonz/sources/include/trastercm.h index 513c239..852d973 100644 --- a/toonz/sources/include/trastercm.h +++ b/toonz/sources/include/trastercm.h @@ -18,7 +18,7 @@ typedef TRasterT TRasterCM32; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT>; template class DVAPI TRasterPT; #endif diff --git a/toonz/sources/include/trasterfx.h b/toonz/sources/include/trasterfx.h index 94f9f47..92778fa 100644 --- a/toonz/sources/include/trasterfx.h +++ b/toonz/sources/include/trasterfx.h @@ -20,7 +20,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif @@ -266,7 +266,7 @@ public: //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -285,7 +285,7 @@ public: //=================================================================== -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TFxPortT; #endif typedef TFxPortT TRasterFxPort; @@ -321,7 +321,7 @@ public: //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -343,7 +343,7 @@ public: //=================================================================== -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TFxPortT; #endif @@ -409,12 +409,12 @@ void DVAPI removeRenderCache(const std::string &alias); //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif diff --git a/toonz/sources/include/trasterimage.h b/toonz/sources/include/trasterimage.h index fc62a45..90bd423 100644 --- a/toonz/sources/include/trasterimage.h +++ b/toonz/sources/include/trasterimage.h @@ -146,7 +146,7 @@ public: //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif diff --git a/toonz/sources/include/tregion.h b/toonz/sources/include/tregion.h index 2ac3e02..8c849b8 100644 --- a/toonz/sources/include/tregion.h +++ b/toonz/sources/include/tregion.h @@ -150,7 +150,7 @@ private: }; /* -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/trop_borders.h b/toonz/sources/include/trop_borders.h index c58359e..f98735b 100644 --- a/toonz/sources/include/trop_borders.h +++ b/toonz/sources/include/trop_borders.h @@ -147,7 +147,7 @@ class ImageMesh : public TSmartObject, public tcg::Mesh //-------------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class TSmartPointerT; #endif typedef TSmartPointerT ImageMeshP; diff --git a/toonz/sources/include/tscanner.h b/toonz/sources/include/tscanner.h index 4444c74..c8c0202 100644 --- a/toonz/sources/include/tscanner.h +++ b/toonz/sources/include/tscanner.h @@ -1,12 +1,6 @@ - - #ifndef TSCANNER_H #define TSCANNER_H -#ifdef WIN32 -#define NOMINMAX -#endif - #include "trasterimage.h" #include #include diff --git a/toonz/sources/include/tsound.h b/toonz/sources/include/tsound.h index 1920805..0000b0d 100644 --- a/toonz/sources/include/tsound.h +++ b/toonz/sources/include/tsound.h @@ -35,7 +35,7 @@ const int RIGHT = LEFT + 1; class TSoundTrack; class TSoundTransform; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/tsound_io.h b/toonz/sources/include/tsound_io.h index 52cbbba..1f99200 100644 --- a/toonz/sources/include/tsound_io.h +++ b/toonz/sources/include/tsound_io.h @@ -54,7 +54,7 @@ public: TSoundTrackReaderCreateProc *proc); }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif @@ -98,7 +98,7 @@ public: TSoundTrackWriterCreateProc *proc); }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; #endif diff --git a/toonz/sources/include/tsound_t.h b/toonz/sources/include/tsound_t.h index 9f4690b..f22de24 100644 --- a/toonz/sources/include/tsound_t.h +++ b/toonz/sources/include/tsound_t.h @@ -164,7 +164,7 @@ public: //!Applies a trasformation (echo, reverb, ect) to the object and returns the transformed soundtrack #if defined(MACOSX) || defined(LINUX) TSoundTrackP apply(TSoundTransform *transform); -#else // WIN32 +#else // _WIN32 TSoundTrackP apply(TSoundTransform *transform) { assert(transform); @@ -392,7 +392,7 @@ public: //============================================================================== -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSoundTrackT; template class DVAPI TSoundTrackT; template class DVAPI TSoundTrackT; diff --git a/toonz/sources/include/tspectrum.h b/toonz/sources/include/tspectrum.h index d8fa40f..2a94749 100644 --- a/toonz/sources/include/tspectrum.h +++ b/toonz/sources/include/tspectrum.h @@ -16,7 +16,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif @@ -193,7 +193,7 @@ public: } }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSpectrumT; template class DVAPI TSpectrumT; #endif @@ -201,7 +201,7 @@ template class DVAPI TSpectrumT; typedef TSpectrumT TSpectrum; typedef TSpectrumT TSpectrum64; -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(default : 4251) #endif diff --git a/toonz/sources/include/tspectrumparam.h b/toonz/sources/include/tspectrumparam.h index 6ea7433..5627e2e 100644 --- a/toonz/sources/include/tspectrumparam.h +++ b/toonz/sources/include/tspectrumparam.h @@ -26,7 +26,7 @@ class TPixelParamP; //============================================================= -#ifdef WIN32 +#ifdef _WIN32 class TSpectrumParam; template class DVAPI TPersistDeclarationT; #endif @@ -93,7 +93,7 @@ public: double keyframeIndexToFrame(int index) const; }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif diff --git a/toonz/sources/include/tstepparam.h b/toonz/sources/include/tstepparam.h index 61b9156..35c4632 100644 --- a/toonz/sources/include/tstepparam.h +++ b/toonz/sources/include/tstepparam.h @@ -24,7 +24,7 @@ #endif class TDoubleStepParam; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TPersistDeclarationT; #endif diff --git a/toonz/sources/include/tstopwatch.h b/toonz/sources/include/tstopwatch.h index 141ab1d..e15b4e0 100644 --- a/toonz/sources/include/tstopwatch.h +++ b/toonz/sources/include/tstopwatch.h @@ -58,7 +58,7 @@ class DVAPI TStopWatch START_USER m_startUser; //process starting reference time (unit=100-nanosecond) START_SYSTEM m_startSystem; //system starting reference time (unit=100-nanosecond) -#ifdef WIN32 +#ifdef _WIN32 LARGE_INTEGER m_hrStart; // high resolution starting reference (total) time #endif diff --git a/toonz/sources/include/tstrokeoutline.h b/toonz/sources/include/tstrokeoutline.h index 952910d..b570128 100644 --- a/toonz/sources/include/tstrokeoutline.h +++ b/toonz/sources/include/tstrokeoutline.h @@ -18,7 +18,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/include/tsystem.h b/toonz/sources/include/tsystem.h index b7209d4..ec888ef 100644 --- a/toonz/sources/include/tsystem.h +++ b/toonz/sources/include/tsystem.h @@ -5,7 +5,7 @@ //#include "texception.h" -#ifndef WIN32 +#ifndef _WIN32 #include #endif diff --git a/toonz/sources/include/ttokenizer.h b/toonz/sources/include/ttokenizer.h index cd20ea7..9a70ad3 100644 --- a/toonz/sources/include/ttokenizer.h +++ b/toonz/sources/include/ttokenizer.h @@ -5,7 +5,7 @@ #include "tcommon.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) #endif @@ -107,7 +107,7 @@ public: } // namespace TSyntax -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif diff --git a/toonz/sources/include/ttonecurveparam.h b/toonz/sources/include/ttonecurveparam.h index 6f40f03..f09ada7 100644 --- a/toonz/sources/include/ttonecurveparam.h +++ b/toonz/sources/include/ttonecurveparam.h @@ -10,7 +10,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif @@ -99,7 +99,7 @@ public: void saveData(TOStream &os); }; -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif diff --git a/toonz/sources/include/ttoonzimage.h b/toonz/sources/include/ttoonzimage.h index c84faf5..0dd93d2 100644 --- a/toonz/sources/include/ttoonzimage.h +++ b/toonz/sources/include/ttoonzimage.h @@ -120,7 +120,7 @@ private: //------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif diff --git a/toonz/sources/include/tunit.h b/toonz/sources/include/tunit.h index 768a3ff..6f11b6a 100644 --- a/toonz/sources/include/tunit.h +++ b/toonz/sources/include/tunit.h @@ -15,7 +15,7 @@ #define DVVAR DV_IMPORT_VAR #endif -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) #endif @@ -191,7 +191,7 @@ DVAPI void setCurrentDpiGetter(CurrentDpiGetter f); //--------------------------- -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif diff --git a/toonz/sources/include/tutil.h b/toonz/sources/include/tutil.h index 3ef19bc..208b5a7 100644 --- a/toonz/sources/include/tutil.h +++ b/toonz/sources/include/tutil.h @@ -6,7 +6,7 @@ #include "tcommon.h" #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #endif diff --git a/toonz/sources/include/tvectorgl.h b/toonz/sources/include/tvectorgl.h index f5b54d8..28945ef 100644 --- a/toonz/sources/include/tvectorgl.h +++ b/toonz/sources/include/tvectorgl.h @@ -3,7 +3,7 @@ #ifndef TVECTORGL_INCLUDED #define TVECTORGL_INCLUDED -#ifdef WIN32 +#ifdef _WIN32 #include // #endif diff --git a/toonz/sources/include/tvectorimage.h b/toonz/sources/include/tvectorimage.h index f80f239..586e66d 100644 --- a/toonz/sources/include/tvectorimage.h +++ b/toonz/sources/include/tvectorimage.h @@ -272,8 +272,8 @@ public: //! Call the following method after stroke modification void notifyChangedStrokes(int strokeIndex, TStroke *oldStroke = 0, bool isFlipped = false); - UINT getFillData(IntersectionBranch *&v); - void setFillData(IntersectionBranch *v, UINT size, bool doComputeRegions = true); + UINT getFillData(std::unique_ptr& v); + void setFillData(std::unique_ptr const& v, UINT size, bool doComputeRegions = true); void drawAutocloses(const TVectorRenderData &rd) const; //debug method @@ -368,7 +368,7 @@ DVAPI void getClosingPoints(const TRectD &rect, double fac, const TVectorImageP //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DVAPI TSmartPointerT; template class DVAPI TDerivedSmartPointerT; #endif @@ -379,7 +379,7 @@ public: TVectorImageP() {} TVectorImageP(TVectorImage *image) : DerivedSmartPointer(image) {} TVectorImageP(TImageP image) : DerivedSmartPointer(image) {} -#if !defined(WIN32) +#if !defined(_WIN32) TVectorImageP(TImage *image) : DerivedSmartPointer(TImageP(image)) { } diff --git a/toonz/sources/sound/aiff/tsio_aiff.cpp b/toonz/sources/sound/aiff/tsio_aiff.cpp index 9bebd85..0151547 100644 --- a/toonz/sources/sound/aiff/tsio_aiff.cpp +++ b/toonz/sources/sound/aiff/tsio_aiff.cpp @@ -169,17 +169,11 @@ class TSSNDChunk : public TAIFFChunk public: TUINT32 m_offset; //dall'inizio dei sample frames tra i wavedata TUINT32 m_blockSize; - UCHAR *m_waveData; + std::unique_ptr m_waveData; TSSNDChunk(string name, TINT32 length) : TAIFFChunk(name, length) {} - ~TSSNDChunk() - { - if (m_waveData) - delete[] m_waveData; - } - bool read(ifstream &is) { @@ -192,10 +186,10 @@ public: } // alloca il buffer dei campioni - m_waveData = new UCHAR[m_length - OFFSETBLOCSIZE_NBYTE]; + m_waveData.reset(new UCHAR[m_length - OFFSETBLOCSIZE_NBYTE]); if (!m_waveData) cout << " ERRORE " << endl; - is.read((char *)m_waveData, m_length - OFFSETBLOCSIZE_NBYTE); + is.read((char *)m_waveData.get(), m_length - OFFSETBLOCSIZE_NBYTE); return true; } @@ -215,7 +209,7 @@ public: os.write((char *)&length, sizeof(TINT32)); os.write((char *)&offset, sizeof(TINT32)); os.write((char *)&blockSize, sizeof(TINT32)); - os.write((char *)m_waveData, m_length - OFFSETBLOCSIZE_NBYTE); + os.write((char *)m_waveData.get(), m_length - OFFSETBLOCSIZE_NBYTE); return true; } }; @@ -242,7 +236,7 @@ ostream &operator<<(ostream &os, const TSSNDChunk &ssndChunk) void flipLong(unsigned char *ptrc) { - register unsigned char val; + unsigned char val; val = *(ptrc); *(ptrc) = *(ptrc + 3); @@ -427,7 +421,7 @@ TSoundTrackP TSoundTrackReaderAiff::load() memcpy( (void *)track->getRawData(), - (void *)(ssndChunk->m_waveData + ssndChunk->m_offset), + (void *)(ssndChunk->m_waveData.get() + ssndChunk->m_offset), commChunk->m_frames * commChunk->m_chans); break; @@ -444,11 +438,11 @@ TSoundTrackP TSoundTrackReaderAiff::load() if (!TNZ_LITTLE_ENDIAN) memcpy( (void *)track->getRawData(), - (void *)(ssndChunk->m_waveData + ssndChunk->m_offset), + (void *)(ssndChunk->m_waveData.get() + ssndChunk->m_offset), commChunk->m_frames * track->getSampleSize()); else swapAndCopySamples( - (short *)(ssndChunk->m_waveData + ssndChunk->m_offset), + (short *)(ssndChunk->m_waveData.get() + ssndChunk->m_offset), (short *)track->getRawData(), (TINT32)(commChunk->m_frames * commChunk->m_chans)); break; @@ -468,21 +462,21 @@ TSoundTrackP TSoundTrackReaderAiff::load() for (int i = 0; i < (int)(commChunk->m_frames * commChunk->m_chans); ++i) { //dovrebbe andare bene anche adesso *(begin + 4 * i) = 0; *(begin + 4 * i + 1) = - *(ssndChunk->m_waveData + ssndChunk->m_offset + 3 * i); + *(ssndChunk->m_waveData.get() + ssndChunk->m_offset + 3 * i); *(begin + 4 * i + 2) = - *(ssndChunk->m_waveData + ssndChunk->m_offset + 3 * i + 1); + *(ssndChunk->m_waveData.get() + ssndChunk->m_offset + 3 * i + 1); *(begin + 4 * i + 3) = - *(ssndChunk->m_waveData + ssndChunk->m_offset + 3 * i + 2); + *(ssndChunk->m_waveData.get() + ssndChunk->m_offset + 3 * i + 2); } } else { UCHAR *begin = (UCHAR *)track->getRawData(); for (int i = 0; i < (int)(commChunk->m_frames * commChunk->m_chans); ++i) { *(begin + 4 * i) = - *(ssndChunk->m_waveData + ssndChunk->m_offset + 3 * i + 2); + *(ssndChunk->m_waveData.get() + ssndChunk->m_offset + 3 * i + 2); *(begin + 4 * i + 1) = - *(ssndChunk->m_waveData + ssndChunk->m_offset + 3 * i + 1); + *(ssndChunk->m_waveData.get() + ssndChunk->m_offset + 3 * i + 1); *(begin + 4 * i + 2) = - *(ssndChunk->m_waveData + ssndChunk->m_offset + 3 * i); + *(ssndChunk->m_waveData.get() + ssndChunk->m_offset + 3 * i); *(begin + 4 * i + 3) = 0; /* @@ -551,7 +545,7 @@ bool TSoundTrackWriterAiff::save(const TSoundTrackP &st) ssndChunk.m_offset = DEFAULT_OFFSET; ssndChunk.m_blockSize = DEFAULT_BLOCKSIZE; - UCHAR *waveData = new UCHAR[soundDataCount]; + std::unique_ptr waveData(new UCHAR[soundDataCount]); if (TNZ_LITTLE_ENDIAN) { postHeadData = swapTINT32(postHeadData); @@ -559,14 +553,14 @@ bool TSoundTrackWriterAiff::save(const TSoundTrackP &st) if (commChunk.m_bitPerSample == 16) { swapAndCopySamples( (short *)sndtrack->getRawData(), - (short *)waveData, + (short *)waveData.get(), (TINT32)(commChunk.m_frames * commChunk.m_chans)); } else if (commChunk.m_bitPerSample == 24) { UCHAR *begin = (UCHAR *)sndtrack->getRawData(); for (int i = 0; i < (int)commChunk.m_frames * commChunk.m_chans; ++i) { - *(waveData + 3 * i) = *(begin + 4 * i + 2); - *(waveData + 3 * i + 1) = *(begin + 4 * i + 1); - *(waveData + 3 * i + 2) = *(begin + 4 * i); + *(waveData.get() + 3 * i) = *(begin + 4 * i + 2); + *(waveData.get() + 3 * i + 1) = *(begin + 4 * i + 1); + *(waveData.get() + 3 * i + 2) = *(begin + 4 * i); /* *(waveData + 3*i + 2) = *(begin + 4*i + 3); @@ -578,26 +572,26 @@ bool TSoundTrackWriterAiff::save(const TSoundTrackP &st) } } else memcpy( - (void *)waveData, + (void *)waveData.get(), (void *)sndtrack->getRawData(), soundDataCount); } else { if (commChunk.m_bitPerSample != 24) memcpy( - (void *)waveData, + (void *)waveData.get(), (void *)sndtrack->getRawData(), soundDataCount); else { UCHAR *begin = (UCHAR *)sndtrack->getRawData(); for (int i = 0; i < (int)commChunk.m_frames * commChunk.m_chans; ++i) { - *(waveData + 3 * i) = *(begin + 4 * i + 1); - *(waveData + 3 * i + 1) = *(begin + 4 * i + 2); - *(waveData + 3 * i + 2) = *(begin + 4 * i + 3); + *(waveData.get() + 3 * i) = *(begin + 4 * i + 1); + *(waveData.get() + 3 * i + 1) = *(begin + 4 * i + 2); + *(waveData.get() + 3 * i + 2) = *(begin + 4 * i + 3); } } } - ssndChunk.m_waveData = waveData; + ssndChunk.m_waveData = std::move(waveData); os.write("FORM", 4); os.write((char *)&postHeadData, sizeof(TINT32)); diff --git a/toonz/sources/sound/wav/tsio_wav.cpp b/toonz/sources/sound/wav/tsio_wav.cpp index e4afb57..28814a8 100644 --- a/toonz/sources/sound/wav/tsio_wav.cpp +++ b/toonz/sources/sound/wav/tsio_wav.cpp @@ -1,4 +1,4 @@ - +#include #include "tmachine.h" #include "tsio_wav.h" @@ -163,25 +163,19 @@ class TDATAChunk : public TWAVChunk { public: - UCHAR *m_samples; + std::unique_ptr m_samples; TDATAChunk(TINT32 length) : TWAVChunk("data", length) {} - ~TDATAChunk() - { - if (m_samples) - delete[] m_samples; - } - bool read(Tifstream &is) { // alloca il buffer dei campioni - m_samples = new UCHAR[m_length]; + m_samples.reset(new UCHAR[m_length]); if (!m_samples) return false; - is.read((char *)m_samples, m_length); + is.read((char *)m_samples.get(), m_length); return true; } @@ -196,7 +190,7 @@ public: os.write((char *)"data", 4); os.write((char *)&length, sizeof(length)); - os.write((char *)m_samples, m_length); + os.write((char *)m_samples.get(), m_length); return true; } }; @@ -300,19 +294,19 @@ TSoundTrackP TSoundTrackReaderWav::load() case 8: memcpy( (void *)track->getRawData(), - (void *)(dataChunk->m_samples), + (void *)(dataChunk->m_samples.get()), sampleCount * fmtChunk->m_bytesPerSample); break; case 16: if (!TNZ_LITTLE_ENDIAN) swapAndCopySamples( - (short *)dataChunk->m_samples, + (short *)dataChunk->m_samples.get(), (short *)track->getRawData(), sampleCount * fmtChunk->m_chans); else memcpy( (void *)track->getRawData(), - (void *)(dataChunk->m_samples), + (void *)(dataChunk->m_samples.get()), sampleCount * fmtChunk->m_bytesPerSample); //#endif break; @@ -322,18 +316,18 @@ TSoundTrackP TSoundTrackReaderWav::load() for (int i = 0; i < (int)(sampleCount * fmtChunk->m_chans); ++i) { *(begin + 4 * i) = 0; *(begin + 4 * i + 1) = - *(dataChunk->m_samples + 3 * i + 2); + *(dataChunk->m_samples.get() + 3 * i + 2); *(begin + 4 * i + 2) = - *(dataChunk->m_samples + 3 * i + 1); + *(dataChunk->m_samples.get() + 3 * i + 1); *(begin + 4 * i + 3) = - *(dataChunk->m_samples + 3 * i); + *(dataChunk->m_samples.get() + 3 * i); } } else { UCHAR *begin = (UCHAR *)track->getRawData(); for (int i = 0; i < (int)(sampleCount * fmtChunk->m_chans); ++i) { memcpy( (void *)(begin + 4 * i), - (void *)(dataChunk->m_samples + 3 * i), 3); + (void *)(dataChunk->m_samples.get() + 3 * i), 3); *(begin + 4 * i + 3) = 0; } } @@ -413,7 +407,7 @@ bool TSoundTrackWriterWav::save(const TSoundTrackP &sndtrack) TDATAChunk dataChunk(soundDataLenght); - UCHAR *waveData = new UCHAR[soundDataLenght]; + std::unique_ptr waveData(new UCHAR[soundDataLenght]); if (!TNZ_LITTLE_ENDIAN) RIFFChunkLength = swapTINT32(RIFFChunkLength); @@ -444,20 +438,20 @@ bool TSoundTrackWriterWav::save(const TSoundTrackP &sndtrack) { if (fmtChunk.m_bitPerSample != 24) memcpy( - (void *)waveData, + (void *)waveData.get(), (void *)sndtrack->getRawData(), soundDataLenght); else { //togliere quarto byte UCHAR *begin = (UCHAR *)sndtrack->getRawData(); for (int i = 0; i < (int)sndtrack->getSampleCount() * fmtChunk.m_chans; ++i) { - *(waveData + 3 * i) = *(begin + 4 * i); - *(waveData + 3 * i + 1) = *(begin + 4 * i + 1); - *(waveData + 3 * i + 2) = *(begin + 4 * i + 2); + *(waveData.get() + 3 * i) = *(begin + 4 * i); + *(waveData.get() + 3 * i + 1) = *(begin + 4 * i + 1); + *(waveData.get() + 3 * i + 2) = *(begin + 4 * i + 2); } } } #endif - dataChunk.m_samples = waveData; + dataChunk.m_samples = std::move(waveData); os.write("RIFF", 4); os.write((char *)&RIFFChunkLength, sizeof(TINT32)); diff --git a/toonz/sources/stdfx/artcontourfx.cpp b/toonz/sources/stdfx/artcontourfx.cpp index 7c0cae2..5ab992a 100644 --- a/toonz/sources/stdfx/artcontourfx.cpp +++ b/toonz/sources/stdfx/artcontourfx.cpp @@ -1,8 +1,5 @@ - - -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) -#define NOMINMAX #endif #include "ttzpimagefx.h" diff --git a/toonz/sources/stdfx/blendtzfx.cpp b/toonz/sources/stdfx/blendtzfx.cpp index c7b9e72..186e04a 100644 --- a/toonz/sources/stdfx/blendtzfx.cpp +++ b/toonz/sources/stdfx/blendtzfx.cpp @@ -1,8 +1,5 @@ - - -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) -#define NOMINMAX #endif #include "ttzpimagefx.h" diff --git a/toonz/sources/stdfx/blurfx.cpp b/toonz/sources/stdfx/blurfx.cpp index 514f5b1..bc26110 100644 --- a/toonz/sources/stdfx/blurfx.cpp +++ b/toonz/sources/stdfx/blurfx.cpp @@ -1,9 +1,3 @@ - - -#ifdef WIN32 -#define NOMINMAX -#endif - #include "texception.h" #include "tfxparam.h" #include "trop.h" diff --git a/toonz/sources/stdfx/bodyhighlightfx.cpp b/toonz/sources/stdfx/bodyhighlightfx.cpp index 766ea63..8a90bfe 100644 --- a/toonz/sources/stdfx/bodyhighlightfx.cpp +++ b/toonz/sources/stdfx/bodyhighlightfx.cpp @@ -60,16 +60,16 @@ void doBlur(CHANNEL_TYPE *greymap, const TRasterPT &rin, int blur) //First, blur each column independently //We'll need a temporary col for storing sums - unsigned long *tempCol = new unsigned long[rin->getLy()]; + std::unique_ptr tempCol(new unsigned long[rin->getLy()]); int edge = tmin(blur + 1, rin->getLy()); for (i = 0; i < rin->getLx(); ++i) { PIXEL *lineSrcPix = rin->pixels(0) + i; CHANNEL_TYPE *lineOutPix = greymap + i; PIXEL *pixin = lineSrcPix; - unsigned long *pixsum = tempCol; + unsigned long *pixsum = tempCol.get(); - memset(tempCol, 0, rin->getLy() * sizeof(unsigned long)); + memset(tempCol.get(), 0, rin->getLy() * sizeof(unsigned long)); //Build up to blur with retro-sums sum = 0; @@ -88,7 +88,7 @@ void doBlur(CHANNEL_TYPE *greymap, const TRasterPT &rin, int blur) //Now, the same in reverse lineSrcPix = lineSrcPix + (rin->getLy() - 1) * wrapSrc; pixin = lineSrcPix; - pixsum = tempCol + rin->getLy() - 1; + pixsum = tempCol.get() + rin->getLy() - 1; sum = 0; for (j = 0; j < edge; ++j, pixin -= wrapSrc, --pixsum) { @@ -104,27 +104,25 @@ void doBlur(CHANNEL_TYPE *greymap, const TRasterPT &rin, int blur) } //Finally, transfer sums to the output greymap, divided by the blur. - pixsum = tempCol; + pixsum = tempCol.get(); CHANNEL_TYPE *pixout = lineOutPix; for (j = 0; j < rin->getLy(); ++j, pixout += wrapOut, ++pixsum) *pixout = (*pixsum) / blurDiameter; } - delete[] tempCol; - //Then, the same for all greymap rows //We'll need a temporary row for sums - unsigned long *tempRow = new unsigned long[rin->getLx()]; + std::unique_ptr tempRow(new unsigned long[rin->getLx()]); edge = tmin(blur + 1, rin->getLx()); for (j = 0; j < rin->getLy(); ++j) { CHANNEL_TYPE *lineSrcPix = greymap + j * wrapOut; CHANNEL_TYPE *lineOutPix = lineSrcPix; - unsigned long *pixsum = tempRow; + unsigned long *pixsum = tempRow.get(); CHANNEL_TYPE *pixin = lineSrcPix; - memset(tempRow, 0, rin->getLx() * sizeof(unsigned long)); + memset(tempRow.get(), 0, rin->getLx() * sizeof(unsigned long)); //Build up to blur with retro-sums sum = 0; @@ -144,7 +142,7 @@ void doBlur(CHANNEL_TYPE *greymap, const TRasterPT &rin, int blur) //Now, the same in reverse lineSrcPix = lineSrcPix + rin->getLx() - 1; pixin = lineSrcPix; - pixsum = tempRow + rin->getLx() - 1; + pixsum = tempRow.get() + rin->getLx() - 1; sum = 0; for (i = 0; i < edge; ++i, --pixin, --pixsum) { @@ -161,12 +159,10 @@ void doBlur(CHANNEL_TYPE *greymap, const TRasterPT &rin, int blur) //Finally, transfer sums to the output greymap, divided by the blur. CHANNEL_TYPE *pixout = lineOutPix; - pixsum = tempRow; + pixsum = tempRow.get(); for (i = 0; i < rin->getLx(); ++i, ++pixout, ++pixsum) *pixout = (*pixsum) / blurDiameter; } - - delete[] tempRow; } //------------------------------------------------------------------------------ diff --git a/toonz/sources/stdfx/calligraphicfx.cpp b/toonz/sources/stdfx/calligraphicfx.cpp index ab9c900..c7166b0 100644 --- a/toonz/sources/stdfx/calligraphicfx.cpp +++ b/toonz/sources/stdfx/calligraphicfx.cpp @@ -2,7 +2,7 @@ #include "stdfx.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include "windows.h" #endif diff --git a/toonz/sources/stdfx/igs_fog.cpp b/toonz/sources/stdfx/igs_fog.cpp index 663e5f4..000432c 100644 --- a/toonz/sources/stdfx/igs_fog.cpp +++ b/toonz/sources/stdfx/igs_fog.cpp @@ -3,9 +3,6 @@ #include // std::numeric_limits #include // std::domain_error() #include // std::max(),std::rotate() -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX // cancel max(-) -#endif #include "igs_resource_multithread.h" #include "igs_ifx_common.h" #include "igs_fog.h" diff --git a/toonz/sources/stdfx/ino_blend_add.cpp b/toonz/sources/stdfx/ino_blend_add.cpp index c783825..1a596b1 100644 --- a/toonz/sources/stdfx/ino_blend_add.cpp +++ b/toonz/sources/stdfx/ino_blend_add.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_color_burn.cpp b/toonz/sources/stdfx/ino_blend_color_burn.cpp index 8a3a90e..88631d3 100644 --- a/toonz/sources/stdfx/ino_blend_color_burn.cpp +++ b/toonz/sources/stdfx/ino_blend_color_burn.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_color_dodge.cpp b/toonz/sources/stdfx/ino_blend_color_dodge.cpp index 55236a5..d612e6a 100644 --- a/toonz/sources/stdfx/ino_blend_color_dodge.cpp +++ b/toonz/sources/stdfx/ino_blend_color_dodge.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_cross_dissolve.cpp b/toonz/sources/stdfx/ino_blend_cross_dissolve.cpp index 58f7b2f..5c89d5d 100644 --- a/toonz/sources/stdfx/ino_blend_cross_dissolve.cpp +++ b/toonz/sources/stdfx/ino_blend_cross_dissolve.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_darken.cpp b/toonz/sources/stdfx/ino_blend_darken.cpp index 96c09b5..0fd040b 100644 --- a/toonz/sources/stdfx/ino_blend_darken.cpp +++ b/toonz/sources/stdfx/ino_blend_darken.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_darker_color.cpp b/toonz/sources/stdfx/ino_blend_darker_color.cpp index f4b5a2b..28e1b07 100644 --- a/toonz/sources/stdfx/ino_blend_darker_color.cpp +++ b/toonz/sources/stdfx/ino_blend_darker_color.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_divide.cpp b/toonz/sources/stdfx/ino_blend_divide.cpp index 7c08507..0f132c4 100644 --- a/toonz/sources/stdfx/ino_blend_divide.cpp +++ b/toonz/sources/stdfx/ino_blend_divide.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_hard_light.cpp b/toonz/sources/stdfx/ino_blend_hard_light.cpp index 0ab01e0..b739841 100644 --- a/toonz/sources/stdfx/ino_blend_hard_light.cpp +++ b/toonz/sources/stdfx/ino_blend_hard_light.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_hard_mix.cpp b/toonz/sources/stdfx/ino_blend_hard_mix.cpp index 8c51311..d9b9a32 100644 --- a/toonz/sources/stdfx/ino_blend_hard_mix.cpp +++ b/toonz/sources/stdfx/ino_blend_hard_mix.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_lighten.cpp b/toonz/sources/stdfx/ino_blend_lighten.cpp index 3c8a7a0..449a9b3 100644 --- a/toonz/sources/stdfx/ino_blend_lighten.cpp +++ b/toonz/sources/stdfx/ino_blend_lighten.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_lighter_color.cpp b/toonz/sources/stdfx/ino_blend_lighter_color.cpp index cc74fe4..ed6a3e4 100644 --- a/toonz/sources/stdfx/ino_blend_lighter_color.cpp +++ b/toonz/sources/stdfx/ino_blend_lighter_color.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_linear_burn.cpp b/toonz/sources/stdfx/ino_blend_linear_burn.cpp index 793f87e..60d8011 100644 --- a/toonz/sources/stdfx/ino_blend_linear_burn.cpp +++ b/toonz/sources/stdfx/ino_blend_linear_burn.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_linear_dodge.cpp b/toonz/sources/stdfx/ino_blend_linear_dodge.cpp index 5f95d6a..053f635 100644 --- a/toonz/sources/stdfx/ino_blend_linear_dodge.cpp +++ b/toonz/sources/stdfx/ino_blend_linear_dodge.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_linear_light.cpp b/toonz/sources/stdfx/ino_blend_linear_light.cpp index b3225a5..548ba22 100644 --- a/toonz/sources/stdfx/ino_blend_linear_light.cpp +++ b/toonz/sources/stdfx/ino_blend_linear_light.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_multiply.cpp b/toonz/sources/stdfx/ino_blend_multiply.cpp index 738fc8c..ab49b10 100644 --- a/toonz/sources/stdfx/ino_blend_multiply.cpp +++ b/toonz/sources/stdfx/ino_blend_multiply.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_over.cpp b/toonz/sources/stdfx/ino_blend_over.cpp index 9e78579..6c469d2 100644 --- a/toonz/sources/stdfx/ino_blend_over.cpp +++ b/toonz/sources/stdfx/ino_blend_over.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_overlay.cpp b/toonz/sources/stdfx/ino_blend_overlay.cpp index 9fdf5d9..c2b1181 100644 --- a/toonz/sources/stdfx/ino_blend_overlay.cpp +++ b/toonz/sources/stdfx/ino_blend_overlay.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_pin_light.cpp b/toonz/sources/stdfx/ino_blend_pin_light.cpp index 9c4c1dc..bf3b74b 100644 --- a/toonz/sources/stdfx/ino_blend_pin_light.cpp +++ b/toonz/sources/stdfx/ino_blend_pin_light.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_screen.cpp b/toonz/sources/stdfx/ino_blend_screen.cpp index bf7c502..95d46fd 100644 --- a/toonz/sources/stdfx/ino_blend_screen.cpp +++ b/toonz/sources/stdfx/ino_blend_screen.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_soft_light.cpp b/toonz/sources/stdfx/ino_blend_soft_light.cpp index 007e5c7..85a5dc6 100644 --- a/toonz/sources/stdfx/ino_blend_soft_light.cpp +++ b/toonz/sources/stdfx/ino_blend_soft_light.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_subtract.cpp b/toonz/sources/stdfx/ino_blend_subtract.cpp index dff322d..9bec520 100644 --- a/toonz/sources/stdfx/ino_blend_subtract.cpp +++ b/toonz/sources/stdfx/ino_blend_subtract.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blend_vivid_light.cpp b/toonz/sources/stdfx/ino_blend_vivid_light.cpp index 0bcc1f5..1cbdead 100644 --- a/toonz/sources/stdfx/ino_blend_vivid_light.cpp +++ b/toonz/sources/stdfx/ino_blend_vivid_light.cpp @@ -1,7 +1,4 @@ //------------------------------------------------------------ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_blur.cpp b/toonz/sources/stdfx/ino_blur.cpp index d327bf3..6d8a1ea 100644 --- a/toonz/sources/stdfx/ino_blur.cpp +++ b/toonz/sources/stdfx/ino_blur.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_channel_selector.cpp b/toonz/sources/stdfx/ino_channel_selector.cpp index 5937a56..7b132bd 100644 --- a/toonz/sources/stdfx/ino_channel_selector.cpp +++ b/toonz/sources/stdfx/ino_channel_selector.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ /* Not use boost at toonz-6.1 */ // #include /* boost::shared_array<> */ diff --git a/toonz/sources/stdfx/ino_density.cpp b/toonz/sources/stdfx/ino_density.cpp index 9eb701a..efd553b 100644 --- a/toonz/sources/stdfx/ino_density.cpp +++ b/toonz/sources/stdfx/ino_density.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_fog.cpp b/toonz/sources/stdfx/ino_fog.cpp index 8ee88b4..e84524b 100644 --- a/toonz/sources/stdfx/ino_fog.cpp +++ b/toonz/sources/stdfx/ino_fog.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_hls_add.cpp b/toonz/sources/stdfx/ino_hls_add.cpp index 479e632..400d6b2 100644 --- a/toonz/sources/stdfx/ino_hls_add.cpp +++ b/toonz/sources/stdfx/ino_hls_add.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_hls_adjust.cpp b/toonz/sources/stdfx/ino_hls_adjust.cpp index f87bb6d..7c78595 100644 --- a/toonz/sources/stdfx/ino_hls_adjust.cpp +++ b/toonz/sources/stdfx/ino_hls_adjust.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_hls_noise.cpp b/toonz/sources/stdfx/ino_hls_noise.cpp index e45ecbc..68bec1c 100644 --- a/toonz/sources/stdfx/ino_hls_noise.cpp +++ b/toonz/sources/stdfx/ino_hls_noise.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_hsv_add.cpp b/toonz/sources/stdfx/ino_hsv_add.cpp index b8bc128..4e6e0d6 100644 --- a/toonz/sources/stdfx/ino_hsv_add.cpp +++ b/toonz/sources/stdfx/ino_hsv_add.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_hsv_adjust.cpp b/toonz/sources/stdfx/ino_hsv_adjust.cpp index 453cebc..6bd929e 100644 --- a/toonz/sources/stdfx/ino_hsv_adjust.cpp +++ b/toonz/sources/stdfx/ino_hsv_adjust.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_hsv_noise.cpp b/toonz/sources/stdfx/ino_hsv_noise.cpp index c133e6a..638b7e6 100644 --- a/toonz/sources/stdfx/ino_hsv_noise.cpp +++ b/toonz/sources/stdfx/ino_hsv_noise.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_level_auto.cpp b/toonz/sources/stdfx/ino_level_auto.cpp index 331ce07..fdd85bc 100644 --- a/toonz/sources/stdfx/ino_level_auto.cpp +++ b/toonz/sources/stdfx/ino_level_auto.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_level_master.cpp b/toonz/sources/stdfx/ino_level_master.cpp index b75a962..01ea78e 100644 --- a/toonz/sources/stdfx/ino_level_master.cpp +++ b/toonz/sources/stdfx/ino_level_master.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_level_rgba.cpp b/toonz/sources/stdfx/ino_level_rgba.cpp index 5e9341b..0a67724 100644 --- a/toonz/sources/stdfx/ino_level_rgba.cpp +++ b/toonz/sources/stdfx/ino_level_rgba.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_line_blur.cpp b/toonz/sources/stdfx/ino_line_blur.cpp index ac47bba..b7929ec 100644 --- a/toonz/sources/stdfx/ino_line_blur.cpp +++ b/toonz/sources/stdfx/ino_line_blur.cpp @@ -6818,10 +6818,6 @@ void igs::line_blur::convert( //===================== -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_maxmin.cpp b/toonz/sources/stdfx/ino_maxmin.cpp index 9222541..057d429 100644 --- a/toonz/sources/stdfx/ino_maxmin.cpp +++ b/toonz/sources/stdfx/ino_maxmin.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_median.cpp b/toonz/sources/stdfx/ino_median.cpp index ab50eb5..9ac1395 100644 --- a/toonz/sources/stdfx/ino_median.cpp +++ b/toonz/sources/stdfx/ino_median.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_median_filter.cpp b/toonz/sources/stdfx/ino_median_filter.cpp index 3ba0b8f..c6b9cb3 100644 --- a/toonz/sources/stdfx/ino_median_filter.cpp +++ b/toonz/sources/stdfx/ino_median_filter.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_motion_blur.cpp b/toonz/sources/stdfx/ino_motion_blur.cpp index 71f6199..462295b 100644 --- a/toonz/sources/stdfx/ino_motion_blur.cpp +++ b/toonz/sources/stdfx/ino_motion_blur.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_motion_wind.cpp b/toonz/sources/stdfx/ino_motion_wind.cpp index caa1a3f..5e5a693 100644 --- a/toonz/sources/stdfx/ino_motion_wind.cpp +++ b/toonz/sources/stdfx/ino_motion_wind.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_negate.cpp b/toonz/sources/stdfx/ino_negate.cpp index b5617e5..c210c25 100644 --- a/toonz/sources/stdfx/ino_negate.cpp +++ b/toonz/sources/stdfx/ino_negate.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_pn_clouds.cpp b/toonz/sources/stdfx/ino_pn_clouds.cpp index 9534c50..890dd06 100644 --- a/toonz/sources/stdfx/ino_pn_clouds.cpp +++ b/toonz/sources/stdfx/ino_pn_clouds.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/ino_radial_blur.cpp b/toonz/sources/stdfx/ino_radial_blur.cpp index d26350a..17ae5fa 100644 --- a/toonz/sources/stdfx/ino_radial_blur.cpp +++ b/toonz/sources/stdfx/ino_radial_blur.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "tparamset.h" // TPointParamP diff --git a/toonz/sources/stdfx/ino_spin_blur.cpp b/toonz/sources/stdfx/ino_spin_blur.cpp index 6489a21..d3efebf 100644 --- a/toonz/sources/stdfx/ino_spin_blur.cpp +++ b/toonz/sources/stdfx/ino_spin_blur.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "tparamset.h" // TPointParamP diff --git a/toonz/sources/stdfx/ino_warp_hv.cpp b/toonz/sources/stdfx/ino_warp_hv.cpp index e741708..b3cd9fa 100644 --- a/toonz/sources/stdfx/ino_warp_hv.cpp +++ b/toonz/sources/stdfx/ino_warp_hv.cpp @@ -1,7 +1,3 @@ -#if defined _WIN32 && !defined NOMINMAX -#define NOMINMAX -#endif - #include /* std::ostringstream */ #include "tfxparam.h" #include "stdfx.h" diff --git a/toonz/sources/stdfx/iwa_particlesengine.cpp b/toonz/sources/stdfx/iwa_particlesengine.cpp index 1ebbf3d..ad8ecc9 100644 --- a/toonz/sources/stdfx/iwa_particlesengine.cpp +++ b/toonz/sources/stdfx/iwa_particlesengine.cpp @@ -2,8 +2,6 @@ // Iwa_Particles_Engine for Marnie // based on Particles_Engine by Digital Video //------------------------------------------------------------------ -#define NOMINMAX - #include "trop.h" #include "tfxparam.h" #include "tofflinegl.h" diff --git a/toonz/sources/stdfx/localblurfx.cpp b/toonz/sources/stdfx/localblurfx.cpp index 5a3d599..78040dc 100644 --- a/toonz/sources/stdfx/localblurfx.cpp +++ b/toonz/sources/stdfx/localblurfx.cpp @@ -32,40 +32,25 @@ namespace { struct Sums { - TUINT64 *m_sumsIX_r; //!< m_sumsIX1[i+1] = m_sumsIX1[i] + i * pix.r - TUINT64 *m_sumsIX_g; - TUINT64 *m_sumsIX_b; - TUINT64 *m_sumsIX_m; - TUINT64 *m_sumsX_r; //!< m_sumsX[i+1] = m_sumsX[i] + pix.r - TUINT64 *m_sumsX_g; - TUINT64 *m_sumsX_b; - TUINT64 *m_sumsX_m; + std::unique_ptr m_sumsIX_r; //!< m_sumsIX1[i+1] = m_sumsIX1[i] + i * pix.r + std::unique_ptr m_sumsIX_g; + std::unique_ptr m_sumsIX_b; + std::unique_ptr m_sumsIX_m; + std::unique_ptr m_sumsX_r; //!< m_sumsX[i+1] = m_sumsX[i] + pix.r + std::unique_ptr m_sumsX_g; + std::unique_ptr m_sumsX_b; + std::unique_ptr m_sumsX_m; Sums(int length) + : m_sumsIX_r(new TUINT64[length + 1]) + , m_sumsIX_g(new TUINT64[length + 1]) + , m_sumsIX_b(new TUINT64[length + 1]) + , m_sumsIX_m(new TUINT64[length + 1]) + , m_sumsX_r(new TUINT64[length + 1]) + , m_sumsX_g(new TUINT64[length + 1]) + , m_sumsX_b(new TUINT64[length + 1]) + , m_sumsX_m(new TUINT64[length + 1]) { - ++length; - m_sumsIX_r = new TUINT64[length]; - m_sumsIX_g = new TUINT64[length]; - m_sumsIX_b = new TUINT64[length]; - m_sumsIX_m = new TUINT64[length]; - - m_sumsX_r = new TUINT64[length]; - m_sumsX_g = new TUINT64[length]; - m_sumsX_b = new TUINT64[length]; - m_sumsX_m = new TUINT64[length]; - } - - ~Sums() - { - delete[] m_sumsIX_r; - delete[] m_sumsIX_g; - delete[] m_sumsIX_b; - delete[] m_sumsIX_m; - - delete[] m_sumsX_r; - delete[] m_sumsX_g; - delete[] m_sumsX_b; - delete[] m_sumsX_m; } template diff --git a/toonz/sources/stdfx/offscreengl.h b/toonz/sources/stdfx/offscreengl.h index 8164f29..5a72170 100644 --- a/toonz/sources/stdfx/offscreengl.h +++ b/toonz/sources/stdfx/offscreengl.h @@ -14,7 +14,7 @@ public: // ----------------------------------------------------------------------------------- // // creo il contesto openGL // // ----------------------------------------------------------------------------------- // -#ifdef WIN32 +#ifdef _WIN32 initBITMAPINFO(m_info, width, height, bpp); m_offData = 0; // a pointer to buffer @@ -80,7 +80,7 @@ public: // ----------------------------------------------------------------------------------- // // cancello il contesto openGL // // ----------------------------------------------------------------------------------- // -#ifdef WIN32 +#ifdef _WIN32 wglDeleteContext(m_hglRC); // release object @@ -99,7 +99,7 @@ public: public: // init a BITMAPINFO structure -#ifdef WIN32 +#ifdef _WIN32 void initBITMAPINFO(BITMAPINFO &info, int width, int height, int bpp) { memset(&info, 0, sizeof(BITMAPINFOHEADER)); diff --git a/toonz/sources/stdfx/perlinnoise.cpp b/toonz/sources/stdfx/perlinnoise.cpp index 3fb9f7b..3656e7b 100644 --- a/toonz/sources/stdfx/perlinnoise.cpp +++ b/toonz/sources/stdfx/perlinnoise.cpp @@ -146,9 +146,9 @@ double PerlinNoise::Marble(double u, double v, double k, double grain, double mi } PerlinNoise::PerlinNoise() + : Noise(new float[Size * Size * TimeSize]) { TRandom random(1); - Noise = new float[Size * Size * TimeSize]; for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { for (int k = 0; k < TimeSize; k++) { diff --git a/toonz/sources/stdfx/perlinnoise.h b/toonz/sources/stdfx/perlinnoise.h index 9b51d75..b50f1c9 100644 --- a/toonz/sources/stdfx/perlinnoise.h +++ b/toonz/sources/stdfx/perlinnoise.h @@ -1,7 +1,8 @@ - - #ifndef PERLINNOISE_H #define PERLINOISE_H + +#include + #include "tfxparam.h" #include "tspectrumparam.h" @@ -17,12 +18,11 @@ class PerlinNoise static int TimeSize; static int Offset; static double Pixel_size; - float *Noise; + std::unique_ptr Noise; double LinearNoise(double x, double y, double t); public: PerlinNoise(); - ~PerlinNoise() { delete[] Noise; }; double Turbolence(double u, double v, double k, double grain); double Turbolence(double u, double v, double k, double grain, double min, double max); double Marble(double u, double v, double k, double grain); diff --git a/toonz/sources/stdfx/pins.cpp b/toonz/sources/stdfx/pins.cpp index d4d6fba..e0e7944 100644 --- a/toonz/sources/stdfx/pins.cpp +++ b/toonz/sources/stdfx/pins.cpp @@ -7,7 +7,7 @@ #include "tofflinegl.h" //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 #define ISNAN _isnan #else extern "C" int isnan(double); @@ -141,7 +141,7 @@ void subCompute(TRasterFxPort &m_input, TTile &tile, double frame, const TRender assert(ret == TRUE); #else TOfflineGL offScreenRendering(TDimension(rasterWidth, rasterHeight)); - //#ifdef WIN32 + //#ifdef _WIN32 offScreenRendering.makeCurrent(); //#else //#if defined(LINUX) || defined(MACOSX) diff --git a/toonz/sources/stdfx/pins.h b/toonz/sources/stdfx/pins.h index ffda932..7e52c0f 100644 --- a/toonz/sources/stdfx/pins.h +++ b/toonz/sources/stdfx/pins.h @@ -13,7 +13,7 @@ //#include "tparamset.h" #include "tgl.h" -#ifdef WIN32 +#ifdef _WIN32 #include #include #endif diff --git a/toonz/sources/stdfx/stdfx.cpp b/toonz/sources/stdfx/stdfx.cpp index 8743fe9..4f46264 100644 --- a/toonz/sources/stdfx/stdfx.cpp +++ b/toonz/sources/stdfx/stdfx.cpp @@ -13,7 +13,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif #undef max diff --git a/toonz/sources/stdfx/stdfx.h b/toonz/sources/stdfx/stdfx.h index 3aba595..2a4e1cf 100644 --- a/toonz/sources/stdfx/stdfx.h +++ b/toonz/sources/stdfx/stdfx.h @@ -18,7 +18,7 @@ static const string PLUGIN_PREFIX("STD"); public: \ const TPersistDeclaration *getDeclaration() const; -#ifdef WIN32 +#ifdef _WIN32 #ifdef TNZSTDFX_EXPORTS diff --git a/toonz/sources/tcleanupper/tcleanupper.cpp b/toonz/sources/tcleanupper/tcleanupper.cpp index 9cbe93e..6239076 100644 --- a/toonz/sources/tcleanupper/tcleanupper.cpp +++ b/toonz/sources/tcleanupper/tcleanupper.cpp @@ -127,9 +127,9 @@ void restoreGlobalSettings(CleanupParameters *cp) void fatalError(string msg) { -#ifdef WIN32 +#ifdef _WIN32 msg = "Application can't start:\n" + msg; - DVGui::MsgBox(CRITICAL, QString::fromStdString(msg)); + DVGui::error(QString::fromStdString(msg)); //MessageBox(0,msg.c_str(),"Fatal error",MB_ICONERROR); exit(1); #else @@ -411,7 +411,7 @@ void cleanupLevel(TXshSimpleLevel *xl, std::set fidsInXsheet, string info = "cleanupping " + toString(xl->getPath()); LevelUpdater updater(xl); m_userLog.info(info); - DVGui::MsgBox(INFORMATION, QString::fromStdString(info)); + DVGui::info(QString::fromStdString(info)); bool firstImage = true; std::set::iterator it = fidsInXsheet.begin(); for (it; it != fidsInXsheet.end(); it++) { @@ -425,7 +425,7 @@ void cleanupLevel(TXshSimpleLevel *xl, std::set fidsInXsheet, if (0 != (status & TXshSimpleLevel::Cleanupped) && !overwrite) { cout << " skipped" << endl; m_userLog.info(" skipped"); - DVGui::MsgBox(INFORMATION, QString("--skipped frame ") + QString::fromStdString(fid.expand())); + DVGui::info(QString("--skipped frame ") + QString::fromStdString(fid.expand())); continue; } TRasterImageP original = xl->getFrameToCleanup(fid); @@ -831,7 +831,7 @@ int main(int argc, char *argv[]) TImageCache::instance()->clear(true); } - DVGui::MsgBox(INFORMATION, "Cleanup Done."); + DVGui::info("Cleanup Done."); return 0; } //------------------------------------------------------------------------ diff --git a/toonz/sources/tcomposer/tcomposer.cpp b/toonz/sources/tcomposer/tcomposer.cpp index 1cd3a5b..81a5c86 100644 --- a/toonz/sources/tcomposer/tcomposer.cpp +++ b/toonz/sources/tcomposer/tcomposer.cpp @@ -38,7 +38,7 @@ #include "tnzimage.h" #include "tflash.h" -#ifdef WIN32 +#ifdef _WIN32 #include "avicodecrestrictions.h" #endif @@ -153,7 +153,7 @@ const char *systemVarPrefix = "TOONZ"; void fatalError(string msg) { -#ifdef WIN32 +#ifdef _WIN32 std::cout << msg << std::endl; //MessageBox(0,msg.c_str(),"Fatal error",MB_ICONERROR); exit(1); @@ -310,7 +310,7 @@ bool MyMovieRenderListener::onFrameCompleted(int frame) msg = toString(fp.getWideString()) + " computed"; cout << msg << endl; m_userLog->info(msg); - DVGui::MsgBox(INFORMATION, QString::fromStdString(msg)); + DVGui::info(QString::fromStdString(msg)); if (FarmController) { try { FarmController->taskProgress(TaskId, m_frameCompletedCount + m_frameFailedCount, m_frameCount, frame + 1, FrameDone); @@ -462,7 +462,7 @@ std::pair generateMovie(ToonzScene *scene, string ext = fp.getType(); -#ifdef WIN32 +#ifdef _WIN32 if (ext == "avi") { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); @@ -600,7 +600,7 @@ int main(int argc, char *argv[]) std::auto_ptr mainScope(new QObject(&app)); mainScope->setObjectName("mainScope"); -#ifdef WIN32 +#ifdef _WIN32 #ifndef x64 //Store the floating point control word. It will be re-set before Toonz initialization //has ended. @@ -616,7 +616,7 @@ int main(int argc, char *argv[]) // Install run out of contiguous memory callback TBigMemoryManager::instance()->setRunOutOfContiguousMemoryHandler(&tcomposerRunOutOfContMemHandler); -#ifdef WIN32 +#ifdef _WIN32 //Define 64-bit precision for floating-point arithmetic. Please observe that the //initImageIo() call below would already impose this precision. This just wants to be //explicit. @@ -1003,7 +1003,7 @@ int main(int argc, char *argv[]) //TCacheResourcePool::instance(); //Needs to be instanced before TPassiveCacheManager... TPassiveCacheManager::instance()->setEnabled(false); -#ifdef WIN32 +#ifdef _WIN32 #ifndef x64 //On 32-bit architecture, there could be cases in which initialization could alter the //FPU floating point control word. I've seen this happen when loading some AVI coded (VFAPI), @@ -1029,7 +1029,7 @@ int main(int argc, char *argv[]) toString(TStopWatch::global(8).getTotalTime() / 1000.0, 2) + " seconds spent on rendering" + "\n"; cout << msg + msg2; m_userLog->info(msg + msg2); - DVGui::MsgBox(INFORMATION, QString::fromStdString(msg)); + DVGui::info(QString::fromStdString(msg)); TImageCache::instance()->clear(true); /* cout << "Compositing completed in " + toString(Sw1.getTotalTime()/1000.0, 2) + " seconds"; diff --git a/toonz/sources/tnzbase/texternfx.cpp b/toonz/sources/tnzbase/texternfx.cpp index 55ceaf7..1524b08 100644 --- a/toonz/sources/tnzbase/texternfx.cpp +++ b/toonz/sources/tnzbase/texternfx.cpp @@ -293,7 +293,7 @@ void TExternalProgramFx::doCompute(TTile &tile, double frame, const TRenderSetti // poi cancellare tutto string expandedargs; char buffer[1024]; -#ifdef WIN32 +#ifdef _WIN32 ExpandEnvironmentStrings(args.c_str(), buffer, 1024); STARTUPINFO si; @@ -486,7 +486,7 @@ void ExternalProgramFx::doCompute(TTile &tile, double frame, const TRenderSettin arglist += " " + outname; string cmdline = program + arglist; -#ifdef WIN32 +#ifdef _WIN32 STARTUPINFO si; PROCESS_INFORMATION pinfo; diff --git a/toonz/sources/tnzbase/tscanner/tscannerepson.cpp b/toonz/sources/tnzbase/tscanner/tscannerepson.cpp index e566d33..bb2dda1 100644 --- a/toonz/sources/tnzbase/tscanner/tscannerepson.cpp +++ b/toonz/sources/tnzbase/tscanner/tscannerepson.cpp @@ -24,7 +24,7 @@ int scsi_maxlen() #define BW_USES_GRAYTONES -#ifndef WIN32 +#ifndef _WIN32 #define SWAPIT #endif @@ -327,7 +327,7 @@ void TScannerEpson::acquire(const TScannerParameters ¶ms, int paperCount) throw TException(os.str()); } unsigned long reqBytes = bytes_to_read; - unsigned char *readBuffer = ESCI_read_data2(reqBytes); + std::unique_ptr readBuffer = ESCI_read_data2(reqBytes); if (!readBuffer) throw TException("Error reading image data"); @@ -339,8 +339,7 @@ void TScannerEpson::acquire(const TScannerParameters ¶ms, int paperCount) readBuffer[i] = ~readBuffer[i]; } */ - memcpy(buffer + bytes_read, readBuffer, reqBytes); - delete[] readBuffer; + memcpy(buffer + bytes_read, readBuffer.get(), reqBytes); bytes_read += reqBytes; nTimes++; if (bytes_read == bytes) @@ -625,7 +624,6 @@ void TScannerEpson::collectInformation(char *lev0, char *lev1, unsigned short *l { log("collectInformation"); unsigned char stx; - unsigned char *buffer; int pos = 0; unsigned short counter; unsigned char status; @@ -638,11 +636,11 @@ if (!resetScanner()) throw TException("Unable to get scanner info. Is it off ?"); unsigned long s = 4; // 4 bytes cfr Identity Data Block on ESCI Manual!!! - unsigned char *buffer2 = ESCI_read_data2(s); + std::unique_ptr buffer2 = ESCI_read_data2(s); if (!buffer2 || (s != 4)) throw TException("Error reading scanner info"); - memcpy(&stx, buffer2, 1); + memcpy(&stx, buffer2.get(), 1); memcpy(&counter, &(buffer2[2]), 2); #ifdef SWAPIT @@ -656,12 +654,9 @@ if (!resetScanner()) os << "stx = " << stx << " status = " << status << " counter=" << counter << '\n' << '\0'; #endif - delete[] buffer2; - buffer2 = 0; - s = counter; - buffer = ESCI_read_data2(s); - int len = strlen((const char *)buffer); + std::unique_ptr buffer = ESCI_read_data2(s); + int len = strlen((const char *)buffer.get()); /*printf("Level %c%c", buffer[0], buffer[1]);*/ if (len > 1) { @@ -677,7 +672,6 @@ if (!resetScanner()) *hiRes = 0; *vMax = 0; *hMax = 0; - delete[] buffer; throw TException("unable to get information from scanner"); } @@ -697,15 +691,12 @@ if (!resetScanner()) *hiRes = 0; *vMax = 0; *hMax = 0; - delete[] buffer; throw TException("unable to get information from scanner"); } *hMax = (buffer[pos + 2] * 256) + buffer[pos + 1]; *vMax = (buffer[pos + 4] * 256) + buffer[pos + 3]; - delete[] buffer; - ESCI_command('f', false); ESCI_readLineData2(stx, status, counter); @@ -715,7 +706,7 @@ if (!resetScanner()) s = counter; buffer = ESCI_read_data2(s); //name buffer+1A - const char *name = (const char *)(buffer + 0x1A); + const char *name = (const char *)(buffer.get() + 0x1A); if (strncmp(name, "Perfection1640", strlen("Perfection1640"))) { m_settingsMode = NEW_STYLE; } else { @@ -738,7 +729,6 @@ scsi_b77(1, "adf_installed",0); /**/ #endif m_hasADF = !!(buffer[1] & 0x80); - delete[] buffer; log("collectInformation:OK"); } @@ -883,12 +873,12 @@ bool TScannerEpson::ESCI_command_4w(char cmd, unsigned short p0, unsigned short return status; } -unsigned char *TScannerEpson::ESCI_read_data2(unsigned long &size) +std::unique_ptr TScannerEpson::ESCI_read_data2(unsigned long &size) { - unsigned char *buffer = new unsigned char[size]; - memset(buffer, 0, size); + std::unique_ptr buffer(new unsigned char[size]); + memset(buffer.get(), 0, size); unsigned long bytesToRead = size; - size = receive(buffer, bytesToRead); + size = receive(buffer.get(), bytesToRead); return buffer; } @@ -929,27 +919,27 @@ void TScannerEpson::scanArea2pix(const TScannerParameters ¶ms, unsigned shor void TScannerEpson::ESCI_readLineData(unsigned char &stx, unsigned char &status, unsigned short &counter, unsigned short &lines, bool &areaEnd) { unsigned long s = 6; - unsigned char *buffer = ESCI_read_data2(s); + std::unique_ptr buffer = ESCI_read_data2(s); if (!buffer) throw TException("Error reading scanner info"); /* PACKET DATA LEN = 6 - type offs descr - byte 0 STX - b77 1 fatal_error - b66 1 not_ready - b55 1 area_end - b44 1 option_unit - b33 1 col_attrib_bit_3 - b22 1 col_attrib_bit_2 - b11 1 extended_commands - drow 2, counter - drow 4 lines -*/ + type offs descr + byte 0 STX + b77 1 fatal_error + b66 1 not_ready + b55 1 area_end + b44 1 option_unit + b33 1 col_attrib_bit_3 + b22 1 col_attrib_bit_2 + b11 1 extended_commands + drow 2, counter + drow 4 lines + */ bool fatalError = !!(buffer[1] & 0x80); bool notReady = !!(buffer[1] & 0x40); areaEnd = !!(buffer[1] & 0x20); - memcpy(&stx, buffer, 1); + memcpy(&stx, buffer.get(), 1); memcpy(&counter, &(buffer[2]), 2); #ifdef SWAPIT @@ -977,20 +967,18 @@ void TScannerEpson::ESCI_readLineData(unsigned char &stx, unsigned char &status, TSystem::outputDebug(os.str()); #endif - - delete[] buffer; } void TScannerEpson::ESCI_readLineData2(unsigned char &stx, unsigned char &status, unsigned short &counter) { unsigned long s = 4; - unsigned char *buffer = ESCI_read_data2(s); + std::unique_ptr buffer = ESCI_read_data2(s); if (!buffer) throw TException("Error reading scanner info"); bool fatalError = !!(buffer[1] & 0x80); bool notReady = !!(buffer[1] & 0x40); - memcpy(&stx, buffer, 1); + memcpy(&stx, buffer.get(), 1); memcpy(&counter, &(buffer[2]), 2); #ifdef SWAPIT counter = swapUshort(counter); @@ -1011,6 +999,5 @@ void TScannerEpson::ESCI_readLineData2(unsigned char &stx, unsigned char &status TSystem::outputDebug(os.str()); #endif - - delete[] buffer; } + diff --git a/toonz/sources/tnzbase/tscanner/tscannerepson.h b/toonz/sources/tnzbase/tscanner/tscannerepson.h index 6721db6..dce9e55 100644 --- a/toonz/sources/tnzbase/tscanner/tscannerepson.h +++ b/toonz/sources/tnzbase/tscanner/tscannerepson.h @@ -49,7 +49,7 @@ private: bool ESCI_command_2w(char cmd, unsigned short p0, unsigned short p1, bool checkACK); bool ESCI_command_4w(char cmd, unsigned short p0, unsigned short p1, unsigned short p2, unsigned short p3, bool checkACK); - unsigned char *ESCI_read_data2(unsigned long &size); + std::unique_ptr ESCI_read_data2(unsigned long &size); void ESCI_readLineData(unsigned char &stx, unsigned char &status, unsigned short &counter, unsigned short &lines, bool &areaEnd); void ESCI_readLineData2(unsigned char &stx, unsigned char &status, unsigned short &counter); diff --git a/toonz/sources/tnzext/NotSimmetricBezierPotential.cpp b/toonz/sources/tnzext/NotSimmetricBezierPotential.cpp index 9e1ce6b..b4a6101 100644 --- a/toonz/sources/tnzext/NotSimmetricBezierPotential.cpp +++ b/toonz/sources/tnzext/NotSimmetricBezierPotential.cpp @@ -1,9 +1,3 @@ - - -#ifdef WIN32 -#define NOMINMAX -#endif - #include "ext/NotSimmetricBezierPotential.h" #include "tstroke.h" diff --git a/toonz/sources/tnzext/OverallDesigner.cpp b/toonz/sources/tnzext/OverallDesigner.cpp index 8b286c7..41175f3 100644 --- a/toonz/sources/tnzext/OverallDesigner.cpp +++ b/toonz/sources/tnzext/OverallDesigner.cpp @@ -1,9 +1,3 @@ - - -#ifdef WIN32 -#define NOMINMAX -#endif - #include "ext/OverallDesigner.h" //#include "ext/StrokeParametricDeformer.h" #include "ext/StrokeDeformation.h" diff --git a/toonz/sources/tnzext/Potential.cpp b/toonz/sources/tnzext/Potential.cpp index 1516270..7a39e63 100644 --- a/toonz/sources/tnzext/Potential.cpp +++ b/toonz/sources/tnzext/Potential.cpp @@ -3,7 +3,7 @@ #include "ext/Potential.h" #include -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) #pragma warning(push) #pragma warning(disable : 4290) #endif @@ -67,6 +67,6 @@ ToonzExt::Potential::value(double at) const // End Of File //----------------------------------------------------------------------------- -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) #pragma warning(pop) #endif diff --git a/toonz/sources/tnzext/Selector.cpp b/toonz/sources/tnzext/Selector.cpp index 2b7f3c7..3d8c554 100644 --- a/toonz/sources/tnzext/Selector.cpp +++ b/toonz/sources/tnzext/Selector.cpp @@ -1,9 +1,3 @@ - - -#ifdef WIN32 -#define NOMINMAX -#endif - #include "ext/Selector.h" #include "tgl.h" //#include "drawutil.h" diff --git a/toonz/sources/tnzext/StrokeDeformationImpl.cpp b/toonz/sources/tnzext/StrokeDeformationImpl.cpp index 614b9ab..38d51f0 100644 --- a/toonz/sources/tnzext/StrokeDeformationImpl.cpp +++ b/toonz/sources/tnzext/StrokeDeformationImpl.cpp @@ -6,9 +6,6 @@ #ifdef _DEBUG #define _STLP_DEBUG 1 #endif -#ifdef WIN32 -#define NOMINMAX -#endif #include "ext/StrokeDeformationImpl.h" #include "ext/StrokeDeformation.h" diff --git a/toonz/sources/tnzext/Types.cpp b/toonz/sources/tnzext/Types.cpp index 7ba9e57..2d6aa28 100644 --- a/toonz/sources/tnzext/Types.cpp +++ b/toonz/sources/tnzext/Types.cpp @@ -5,7 +5,7 @@ #endif #include "ext/Types.h" -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) // to avoid annoying warning #pragma warning(push) #pragma warning(disable : 4290) @@ -85,7 +85,7 @@ bool ToonzExt::EvenInt::isEven() const //----------------------------------------------------------------------------- -#if defined(WIN32) && (_MSC_VER <= 1200) +#if defined(_WIN32) && (_MSC_VER <= 1200) #pragma warning(pop) #endif diff --git a/toonz/sources/tnzext/meshutils.cpp b/toonz/sources/tnzext/meshutils.cpp index daf82f0..4580bf2 100644 --- a/toonz/sources/tnzext/meshutils.cpp +++ b/toonz/sources/tnzext/meshutils.cpp @@ -119,7 +119,7 @@ inline void tglDrawFaces(const TMeshImage &meshImage, const PlasticDeformerDataG m = m_; mesh = meshes[m].getPointer(); - dstCoords = group->m_datas[m].m_output; + dstCoords = group->m_datas[m].m_output.get(); } mesh->faceVertices(f, v0, v1, v2); @@ -168,7 +168,7 @@ void tglDrawEdges(const TMeshImage &mi, const PlasticDeformerDataGroup *group) if (group) { for (m = 0; m != mCount; ++m) tglDrawEdges( - *meshes[m], (const TPointD *)group->m_datas[m].m_output, NoColorFunction()); + *meshes[m], (const TPointD *)group->m_datas[m].m_output.get(), NoColorFunction()); } else { for (m = 0; m != mCount; ++m) { const TTextureMesh &mesh = *meshes[m]; @@ -374,7 +374,7 @@ void tglDraw(const TMeshImage &meshImage, m = m_; mesh = meshes[m].getPointer(); - dstCoords = group.m_datas[m].m_output; + dstCoords = group.m_datas[m].m_output.get(); } // Draw each face diff --git a/toonz/sources/tnzext/plasticdeformerstorage.cpp b/toonz/sources/tnzext/plasticdeformerstorage.cpp index 572b266..0bd8981 100644 --- a/toonz/sources/tnzext/plasticdeformerstorage.cpp +++ b/toonz/sources/tnzext/plasticdeformerstorage.cpp @@ -80,7 +80,7 @@ namespace void initializeSO(PlasticDeformerData &data, const TTextureMeshP &mesh) { - data.m_so = new double[mesh->facesCount()]; + data.m_so.reset(new double[mesh->facesCount()]); } //---------------------------------------------------------------------------------- @@ -90,14 +90,14 @@ void initializeDeformerData(PlasticDeformerData &data, const TTextureMeshP &mesh initializeSO(data, mesh); // Allocates SO data // Also, allocate suitable input-output arrays for the deformation - data.m_output = new double[2 * mesh->verticesCount()]; + data.m_output.reset(new double[2 * mesh->verticesCount()]); } //---------------------------------------------------------------------------------- void initializeDeformersData(DataGroup *group, const TMeshImage *meshImage) { - group->m_datas = new PlasticDeformerData[meshImage->meshes().size()]; + group->m_datas.reset(new PlasticDeformerData[meshImage->meshes().size()]); // Push a PlasticDeformer for each mesh in the image const std::vector &meshes = meshImage->meshes(); @@ -269,7 +269,7 @@ void interpolateSO(DataGroup *group, const TMeshImage *meshImage) const TTextureMesh &mesh = *meshImage->meshes()[m]; PlasticDeformerData &data = group->m_datas[m]; - std::fill(data.m_so, data.m_so + mesh.facesCount(), 0.0); + std::fill(data.m_so.get(), data.m_so.get() + mesh.facesCount(), 0.0); } return; @@ -281,9 +281,9 @@ void interpolateSO(DataGroup *group, const TMeshImage *meshImage) PlasticDeformerData &data = group->m_datas[m]; // Interpolate so values - double *verticesSO = new double[mesh.verticesCount()]; + std::unique_ptr verticesSO(new double[mesh.verticesCount()]); - ::buildSO(verticesSO, mesh, group->m_handles, &data.m_faceHints.front()); + ::buildSO(verticesSO.get(), mesh, group->m_handles, &data.m_faceHints.front()); // Make the mean of each face's vertex values and store that int f, fCount = mesh.facesCount(); @@ -293,8 +293,6 @@ void interpolateSO(DataGroup *group, const TMeshImage *meshImage) data.m_so[f] = (verticesSO[v0] + verticesSO[v1] + verticesSO[v2]) / 3.0; } - - delete[] verticesSO; } } @@ -376,7 +374,7 @@ void processMesh(DataGroup *group, double frame, const TMeshImage *meshImage, for (m = 0; m != mCount; ++m) { PlasticDeformerData &data = group->m_datas[m]; - data.m_deformer.deform(dstHandlePos, data.m_output); + data.m_deformer.deform(dstHandlePos, data.m_output.get()); } group->m_upToDate |= PlasticDeformerStorage::MESH; @@ -390,7 +388,6 @@ void processMesh(DataGroup *group, double frame, const TMeshImage *meshImage, //*********************************************************************************************** PlasticDeformerData::PlasticDeformerData() - : m_so(), m_output() { } @@ -398,8 +395,6 @@ PlasticDeformerData::PlasticDeformerData() PlasticDeformerData::~PlasticDeformerData() { - delete[] m_so; - delete[] m_output; } //*********************************************************************************************** @@ -407,7 +402,12 @@ PlasticDeformerData::~PlasticDeformerData() //*********************************************************************************************** PlasticDeformerDataGroup::PlasticDeformerDataGroup() - : m_datas(), m_compiled(PlasticDeformerStorage::NONE), m_upToDate(PlasticDeformerStorage::NONE), m_outputFrame((std::numeric_limits::max)()), m_soMin(), m_soMax() + : m_datas() + , m_compiled(PlasticDeformerStorage::NONE) + , m_upToDate(PlasticDeformerStorage::NONE) + , m_outputFrame((std::numeric_limits::max)()) + , m_soMin() + , m_soMax() { } @@ -415,7 +415,6 @@ PlasticDeformerDataGroup::PlasticDeformerDataGroup() PlasticDeformerDataGroup::~PlasticDeformerDataGroup() { - delete[] m_datas; } //*********************************************************************************************** diff --git a/toonz/sources/tnztools/cuttertool.cpp b/toonz/sources/tnztools/cuttertool.cpp index 336ed44..7402d29 100644 --- a/toonz/sources/tnztools/cuttertool.cpp +++ b/toonz/sources/tnztools/cuttertool.cpp @@ -253,21 +253,21 @@ public: w = strokeRef->getParameterAtLength(len); } - vector *sortedWRanges = new vector; + std::vector *sortedWRanges = new std::vector; if (strokeRef->isSelfLoop()) { - sortedWRanges->push_back(make_pair(0, w)); - sortedWRanges->push_back(make_pair(w, 1)); + sortedWRanges->push_back(std::make_pair(0, w)); + sortedWRanges->push_back(std::make_pair(w, 1)); } else { if (w == 0 || w == 1) - sortedWRanges->push_back(make_pair(0, 1)); + sortedWRanges->push_back(std::make_pair(0, 1)); else { - sortedWRanges->push_back(make_pair(0, w)); - sortedWRanges->push_back(make_pair(w, 1)); + sortedWRanges->push_back(std::make_pair(0, w)); + sortedWRanges->push_back(std::make_pair(w, 1)); } } - vector *fillInformation = new vector; + std::vector *fillInformation = new std::vector; ImageUtils::getFillingInformationOverlappingArea(vi, *fillInformation, strokeRef->getBBox()); VIStroke *oldStroke = cloneVIStroke(vi->getVIStroke(strokeIndex)); diff --git a/toonz/sources/tnztools/pinchtool.cpp b/toonz/sources/tnztools/pinchtool.cpp index 2866bf5..8504f4b 100644 --- a/toonz/sources/tnztools/pinchtool.cpp +++ b/toonz/sources/tnztools/pinchtool.cpp @@ -48,6 +48,7 @@ #include "ext/StrokeDeformation.h" #include +#include using namespace ToolUtils; using namespace ToonzExt; @@ -273,7 +274,7 @@ void PinchTool::leftButtonDrag(const TPointD &pos, val_in_range = m_selector.getLength(); // set value in range - val_in_range = max(min(val_in_range, prop_range.second), prop_range.first); + val_in_range = std::max(std::min(val_in_range, prop_range.second), prop_range.first); try { m_toolRange.setValue(val_in_range); TTool::getApplication()->getCurrentTool()->notifyToolChanged(); @@ -347,7 +348,7 @@ void PinchTool::leftButtonUp(const TPointD &pos, m_undo = 0; // to avoid red line tool on stroke -#ifdef WIN32 +#ifdef _WIN32 invalidate(status->stroke2change_->getBBox().enlarge(status->pixelSize_ * 13)); #else invalidate(); diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index 08abfd7..28b37c2 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -1016,7 +1016,7 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool, T hLayout()->addWidget(m_scaleYField); ret = ret && connect(m_scaleYField, SIGNAL(valueChange()), SLOT(onScaleYValueChanged())); hLayout()->addSpacing(4); - m_scaleLink = new CheckBox(tr("Link"), this); + m_scaleLink = new DVGui::CheckBox(tr("Link"), this); hLayout()->addWidget(m_scaleLink); addSeparator(); @@ -1494,7 +1494,7 @@ public: : Dialog(0, true) { setWindowTitle(tr("Preset Name")); - m_nameFld = new LineEdit(); + m_nameFld = new DVGui::LineEdit(); addWidget(m_nameFld); QPushButton *okBtn = new QPushButton(tr("OK"), this); diff --git a/toonz/sources/tnztools/tooloptionscontrols.h b/toonz/sources/tnztools/tooloptionscontrols.h index af6eae8..4c60b07 100644 --- a/toonz/sources/tnztools/tooloptionscontrols.h +++ b/toonz/sources/tnztools/tooloptionscontrols.h @@ -41,8 +41,6 @@ #define DVVAR DV_IMPORT_VAR #endif -using namespace DVGui; - class TTool; class TFrameHandle; class TObjectHandle; @@ -84,7 +82,7 @@ public: // ToolOptionControl derivative declarations //*********************************************************************************** -class ToolOptionCheckbox : public CheckBox, public ToolOptionControl +class ToolOptionCheckbox : public DVGui::CheckBox, public ToolOptionControl { Q_OBJECT @@ -105,7 +103,7 @@ protected: //----------------------------------------------------------------------------- -class ToolOptionSlider : public DoubleField, public ToolOptionControl +class ToolOptionSlider : public DVGui::DoubleField, public ToolOptionControl { Q_OBJECT @@ -126,7 +124,7 @@ protected slots: //----------------------------------------------------------------------------- -class ToolOptionPairSlider : public DoublePairField, public ToolOptionControl +class ToolOptionPairSlider : public DVGui::DoublePairField, public ToolOptionControl { Q_OBJECT @@ -150,7 +148,7 @@ protected slots: //----------------------------------------------------------------------------- -class ToolOptionIntPairSlider : public IntPairField, public ToolOptionControl +class ToolOptionIntPairSlider : public DVGui::IntPairField, public ToolOptionControl { Q_OBJECT @@ -174,7 +172,7 @@ protected slots: //----------------------------------------------------------------------------- -class ToolOptionIntSlider : public IntField, public ToolOptionControl +class ToolOptionIntSlider : public DVGui::IntField, public ToolOptionControl { Q_OBJECT @@ -239,7 +237,7 @@ public slots: //----------------------------------------------------------------------------- -class ToolOptionTextField : public LineEdit, public ToolOptionControl +class ToolOptionTextField : public DVGui::LineEdit, public ToolOptionControl { Q_OBJECT @@ -257,7 +255,7 @@ public slots: //----------------------------------------------------------------------------- -class StyleIndexFieldAndChip : public StyleIndexLineEdit, public ToolOptionControl +class StyleIndexFieldAndChip : public DVGui::StyleIndexLineEdit, public ToolOptionControl { Q_OBJECT @@ -288,7 +286,7 @@ public slots: \li Editing with global keyframes (ie affecting multiple parameters other than the edited one) \li Undo/Redo of user interactions. */ -class ToolOptionParamRelayField : public MeasuredDoubleLineEdit, public ToolOptionControl +class ToolOptionParamRelayField : public DVGui::MeasuredDoubleLineEdit, public ToolOptionControl { Q_OBJECT @@ -319,7 +317,7 @@ protected slots: // //============================================================================= -class DVAPI MeasuredValueField : public LineEdit +class DVAPI MeasuredValueField : public DVGui::LineEdit { Q_OBJECT diff --git a/toonz/sources/tnztools/vectorerasertool.cpp b/toonz/sources/tnztools/vectorerasertool.cpp index 3d790e3..03025e2 100644 --- a/toonz/sources/tnztools/vectorerasertool.cpp +++ b/toonz/sources/tnztools/vectorerasertool.cpp @@ -709,7 +709,7 @@ void EraserTool::erase(TVectorImageP vi, const TPointD &pos) sortedWRanges.reserve(intersections.size() / 2); for (UINT j = 0; j < intersections.size() - 1; j += 2) - sortedWRanges.push_back(make_pair(intersections[j], intersections[j + 1])); + sortedWRanges.push_back(std::make_pair(intersections[j], intersections[j + 1])); #ifdef _DEBUG diff --git a/toonz/sources/tnztools/vectorselectiontool.cpp b/toonz/sources/tnztools/vectorselectiontool.cpp index fdecbd7..140d233 100644 --- a/toonz/sources/tnztools/vectorselectiontool.cpp +++ b/toonz/sources/tnztools/vectorselectiontool.cpp @@ -128,12 +128,12 @@ inline void notifySelectionChanged() // VectorFreeDeformer implementation //******************************************************************************** -VectorFreeDeformer::VectorFreeDeformer(TVectorImageP vi, set strokeIndexes) +VectorFreeDeformer::VectorFreeDeformer(TVectorImageP vi, std::set strokeIndexes) : FreeDeformer(), m_vi(vi), m_strokeIndexes(strokeIndexes), m_preserveThickness(false), m_computeRegion(false), m_flip(false) { TRectD r; - set::iterator it, iEnd = m_strokeIndexes.end(); + std::set::iterator it, iEnd = m_strokeIndexes.end(); for (it = m_strokeIndexes.begin(); it != iEnd; ++it) { TStroke *stroke = m_vi->getStroke(*it); r += stroke->getBBox(); diff --git a/toonz/sources/tnztools/vectorselectiontool.h b/toonz/sources/tnztools/vectorselectiontool.h index 32a93ea..7f40c24 100644 --- a/toonz/sources/tnztools/vectorselectiontool.h +++ b/toonz/sources/tnztools/vectorselectiontool.h @@ -68,15 +68,15 @@ enum SelectionTarget //! Possible selection targets in a SelectionTool. class VectorFreeDeformer : public FreeDeformer { TVectorImageP m_vi; - set m_strokeIndexes; - vector m_originalStrokes; + std::set m_strokeIndexes; + std::vector m_originalStrokes; bool m_preserveThickness, m_computeRegion, m_flip; TThickPoint deform(TThickPoint point); public: - VectorFreeDeformer(TVectorImageP vi, set strokeIndexes); + VectorFreeDeformer(TVectorImageP vi, std::set strokeIndexes); ~VectorFreeDeformer(); void setPreserveThickness(bool preserveThickness); diff --git a/toonz/sources/toonz/ObjectTracker.cpp b/toonz/sources/toonz/ObjectTracker.cpp index 2f0d2f8..3363549 100644 --- a/toonz/sources/toonz/ObjectTracker.cpp +++ b/toonz/sources/toonz/ObjectTracker.cpp @@ -10,6 +10,8 @@ Compiler: Microsoft Visual Studio.net Luigi Sgaglione **********************************************************************/ +#include + #include "ObjectTracker.h" #include #include @@ -17,12 +19,10 @@ Luigi Sgaglione #include #include #include +#include using namespace std; -#define min(a, b) (((a) < (b)) ? (a) : (b)) - -#define max(a, b) (((a) > (b)) ? (a) : (b)) #define MEANSHIFT_ITERATION_NO 15 #define ALPHA 0.98 @@ -56,11 +56,11 @@ CObjectTracker::CObjectTracker(int imW, int imH, bool _colorimage, bool _att_bac else HISTOGRAM_LENGTH = 8192; - m_sTrackingObject.initHistogram = new float[HISTOGRAM_LENGTH]; + m_sTrackingObject.initHistogram.reset(new float[HISTOGRAM_LENGTH]); if (att_background) - m_sTrackingObject.weights_background = new float[HISTOGRAM_LENGTH]; + m_sTrackingObject.weights_background.reset(new float[HISTOGRAM_LENGTH]); else - m_sTrackingObject.weights_background = 0; + m_sTrackingObject.weights_background.reset(); m_sTrackingObject.Status = false; for (short j = 0; j < HISTOGRAM_LENGTH; j++) @@ -71,8 +71,6 @@ CObjectTracker::CObjectTracker(int imW, int imH, bool _colorimage, bool _att_bac //Distructor CObjectTracker::~CObjectTracker() { - delete[] m_sTrackingObject.initHistogram; - delete[] m_sTrackingObject.weights_background; } //-------------------------------------------------------------------------------------------------------- @@ -158,7 +156,7 @@ void CObjectTracker::ObjeckTrackerHandlerByUser(TRaster32P *frame) if (m_sTrackingObject.Status) { if (!m_sTrackingObject.assignedAnObject) { - FindHistogram(frame, m_sTrackingObject.initHistogram, 1); + FindHistogram(frame, m_sTrackingObject.initHistogram.get(), 1); m_sTrackingObject.assignedAnObject = true; /* ofstream output; @@ -218,10 +216,10 @@ void CObjectTracker::FindHistogram(TRaster32P *frame, float(*histogram), float h normx = short(m_sTrackingObject.X + m_sTrackingObject.W / 2); normy = short(m_sTrackingObject.Y + m_sTrackingObject.H / 2); - for (y = max(m_sTrackingObject.Y - m_sTrackingObject.H / 2, 0); - y <= min(m_sTrackingObject.Y + m_sTrackingObject.H / 2, m_nImageHeight - 1); y++) - for (x = max(m_sTrackingObject.X - m_sTrackingObject.W / 2, 0); - x <= min(m_sTrackingObject.X + m_sTrackingObject.W / 2, m_nImageWidth - 1); x++) { + for (y = std::max(m_sTrackingObject.Y - m_sTrackingObject.H / 2, 0); + y <= std::min(m_sTrackingObject.Y + m_sTrackingObject.H / 2, m_nImageHeight - 1); y++) + for (x = std::max(m_sTrackingObject.X - m_sTrackingObject.W / 2, 0); + x <= std::min(m_sTrackingObject.X + m_sTrackingObject.W / 2, m_nImageWidth - 1); x++) { E = CheckEdgeExistance(frame, x, y); pixelValues = GetPixelValues(frame, x, y); @@ -278,10 +276,10 @@ void CObjectTracker::FindHistogramBackground(TRaster32P *frame, float(*backgroun for (i = 0; i < HISTOGRAM_LENGTH; i++) background[i] = 0.0; - for (y = max(m_sTrackingObject.Y - (m_sTrackingObject.H * 1.73) / 2, 0); - y <= min(m_sTrackingObject.Y + (m_sTrackingObject.H * 1.73) / 2, m_nImageHeight - 1); y++) - for (x = max(m_sTrackingObject.X - (m_sTrackingObject.W * 1.73) / 2, 0); - x <= min(m_sTrackingObject.X + (m_sTrackingObject.W * 1.73) / 2, m_nImageWidth - 1); x++) { + for (y = std::max(m_sTrackingObject.Y - (m_sTrackingObject.H * 1.73) / 2, 0.0); + y <= std::min(m_sTrackingObject.Y + (m_sTrackingObject.H * 1.73) / 2, m_nImageHeight - 1.0); y++) + for (x = std::max(m_sTrackingObject.X - (m_sTrackingObject.W * 1.73) / 2, 0.0); + x <= std::min(m_sTrackingObject.X + (m_sTrackingObject.W * 1.73) / 2, m_nImageWidth - 1.0); x++) { if (((m_sTrackingObject.Y - m_sTrackingObject.H / 2) <= y) && (y <= (m_sTrackingObject.Y + m_sTrackingObject.H / 2)) && ((m_sTrackingObject.X - m_sTrackingObject.W / 2) <= x) && (x <= (m_sTrackingObject.X + m_sTrackingObject.W / 2))) continue; @@ -307,13 +305,13 @@ void CObjectTracker::FindHistogramBackground(TRaster32P *frame, float(*backgroun void CObjectTracker::FindWeightsBackground(TRaster32P *frame) { float small1; - float *background = new float[HISTOGRAM_LENGTH]; + std::unique_ptr background(new float[HISTOGRAM_LENGTH]); short i; for (i = 0; i < HISTOGRAM_LENGTH; i++) m_sTrackingObject.weights_background[i] = 0.0; //Histogram background - FindHistogramBackground(frame, background); + FindHistogramBackground(frame, background.get()); //searce min != 0.0 for (i = 0; background[i] == 0.0; i++) @@ -330,8 +328,6 @@ void CObjectTracker::FindWeightsBackground(TRaster32P *frame) else m_sTrackingObject.weights_background[i] = small1 / background[i]; } - - delete[] background; } //-------------------------------------------------------------------------------------------------------- @@ -349,7 +345,7 @@ void CObjectTracker::FindWightsAndCOM(TRaster32P *frame, float(*histogram)) float newY = 0.0; ValuePixel pixelValues; - float *weights = new float[HISTOGRAM_LENGTH]; + std::unique_ptr weights(new float[HISTOGRAM_LENGTH]); //weigths for (i = 0; i < HISTOGRAM_LENGTH; i++) { @@ -360,10 +356,10 @@ void CObjectTracker::FindWightsAndCOM(TRaster32P *frame, float(*histogram)) } //new location - for (y = max(m_sTrackingObject.Y - m_sTrackingObject.H / 2, 0); - y <= min(m_sTrackingObject.Y + m_sTrackingObject.H / 2, m_nImageHeight - 1); y++) - for (x = max(m_sTrackingObject.X - m_sTrackingObject.W / 2, 0); - x <= min(m_sTrackingObject.X + m_sTrackingObject.W / 2, m_nImageWidth - 1); x++) { + for (y = std::max(m_sTrackingObject.Y - m_sTrackingObject.H / 2, 0); + y <= std::min(m_sTrackingObject.Y + m_sTrackingObject.H / 2, m_nImageHeight - 1); y++) + for (x = std::max(m_sTrackingObject.X - m_sTrackingObject.W / 2, 0); + x <= std::min(m_sTrackingObject.X + m_sTrackingObject.W / 2, m_nImageWidth - 1); x++) { E = CheckEdgeExistance(frame, x, y); pixelValues = GetPixelValues(frame, x, y); @@ -388,8 +384,6 @@ void CObjectTracker::FindWightsAndCOM(TRaster32P *frame, float(*histogram)) m_sTrackingObject.X = short((newX / sumOfWeights) + 0.5); m_sTrackingObject.Y = short((newY / sumOfWeights) + 0.5); } - - delete[] weights, weights = 0; } //-------------------------------------------------------------------------------------------------------- @@ -461,7 +455,7 @@ void CObjectTracker::FindNextLocation(TRaster32P *frame) float DELTA; double rho, rho1, rho2; - float *currentHistogram = new float[HISTOGRAM_LENGTH]; + std::unique_ptr currentHistogram(new float[HISTOGRAM_LENGTH]); Height = m_sTrackingObject.H; Width = m_sTrackingObject.W; @@ -485,13 +479,13 @@ void CObjectTracker::FindNextLocation(TRaster32P *frame) yold = m_sTrackingObject.Y; //Histogram with bandwidth h - FindHistogram(frame, currentHistogram, h); + FindHistogram(frame, currentHistogram.get(), h); //New location - FindWightsAndCOM(frame, currentHistogram); + FindWightsAndCOM(frame, currentHistogram.get()); //Histogram with new location - FindHistogram(frame, currentHistogram, h); + FindHistogram(frame, currentHistogram.get(), h); //Battacharyya coefficient for (i = 0; i < HISTOGRAM_LENGTH; i++) @@ -504,13 +498,13 @@ void CObjectTracker::FindNextLocation(TRaster32P *frame) //Histogram with bandwidth h-DELTA m_sTrackingObject.H = Height - m_sTrackingObject.var_dim; m_sTrackingObject.W = Width - m_sTrackingObject.var_dim; - FindHistogram(frame, currentHistogram, h - DELTA); + FindHistogram(frame, currentHistogram.get(), h - DELTA); //New location - FindWightsAndCOM(frame, currentHistogram); + FindWightsAndCOM(frame, currentHistogram.get()); //Histogram with new location - FindHistogram(frame, currentHistogram, h - DELTA); + FindHistogram(frame, currentHistogram.get(), h - DELTA); //Battacharyya coefficient for (i = 0; i < HISTOGRAM_LENGTH; i++) @@ -523,13 +517,13 @@ void CObjectTracker::FindNextLocation(TRaster32P *frame) //Histogram with bandwidth h+DELTA m_sTrackingObject.H = Height + m_sTrackingObject.var_dim; m_sTrackingObject.W = Width + m_sTrackingObject.var_dim; - FindHistogram(frame, currentHistogram, h + DELTA); + FindHistogram(frame, currentHistogram.get(), h + DELTA); //New location - FindWightsAndCOM(frame, currentHistogram); + FindWightsAndCOM(frame, currentHistogram.get()); //Histogram with new location - FindHistogram(frame, currentHistogram, h + DELTA); + FindHistogram(frame, currentHistogram.get(), h + DELTA); //Battacharyya coefficient for (i = 0; i < HISTOGRAM_LENGTH; i++) @@ -561,10 +555,10 @@ void CObjectTracker::FindNextLocation(TRaster32P *frame) m_sTrackingObject.Y = yold; //Current Histogram - FindHistogram(frame, currentHistogram, h); + FindHistogram(frame, currentHistogram.get(), h); //Definitive new location - FindWightsAndCOM(frame, currentHistogram); + FindWightsAndCOM(frame, currentHistogram.get()); //threshold distanza = sqrt(float((xold - m_sTrackingObject.X) * (xold - m_sTrackingObject.X) + (yold - m_sTrackingObject.Y) * (yold - m_sTrackingObject.Y))); @@ -573,11 +567,9 @@ void CObjectTracker::FindNextLocation(TRaster32P *frame) break; } //New Histogram - FindHistogram(frame, currentHistogram, h); + FindHistogram(frame, currentHistogram.get(), h); //Update - UpdateInitialHistogram(currentHistogram); - - delete[] currentHistogram, currentHistogram = 0; + UpdateInitialHistogram(currentHistogram.get()); } //-------------------------------------------------------------------------------------------------------- @@ -598,17 +590,12 @@ float CObjectTracker::Matching(TRaster32P *frame, TRaster32P *frame_temp) float dist = 0.0; float min_dist = MAX_FLOAT; - ValuePixel *pixel_temp; - ValuePixel *area_ricerca; - short u, v, x, y; short u_sup, v_sup; short x_min, y_min; short x_max, y_max; short dimx, dimy; short dimx_int, dimy_int; - short *u_att; - short *v_att; short ok_u = 0; short ok_v = 0; @@ -622,14 +609,14 @@ float CObjectTracker::Matching(TRaster32P *frame, TRaster32P *frame_temp) } } - u_att = new short[2 * m_sTrackingObject.dim_temp + 1]; - v_att = new short[2 * m_sTrackingObject.dim_temp + 1]; + std::unique_ptr u_att(new short[2 * m_sTrackingObject.dim_temp + 1]); + std::unique_ptr v_att(new short[2 * m_sTrackingObject.dim_temp + 1]); - x_min = max(m_sTrackingObject.X_temp - m_sTrackingObject.W_temp / 2, 0); - y_min = max(m_sTrackingObject.Y_temp - m_sTrackingObject.H_temp / 2, 0); + x_min = std::max(m_sTrackingObject.X_temp - m_sTrackingObject.W_temp / 2, 0); + y_min = std::max(m_sTrackingObject.Y_temp - m_sTrackingObject.H_temp / 2, 0); - x_max = min(m_sTrackingObject.X_temp + m_sTrackingObject.W_temp / 2, m_nImageWidth - 1); - y_max = min(m_sTrackingObject.Y_temp + m_sTrackingObject.H_temp / 2, m_nImageHeight - 1); + x_max = std::min(m_sTrackingObject.X_temp + m_sTrackingObject.W_temp / 2, m_nImageWidth - 1); + y_max = std::min(m_sTrackingObject.Y_temp + m_sTrackingObject.H_temp / 2, m_nImageHeight - 1); //dimension template dimx = x_max - x_min + 1; @@ -667,7 +654,7 @@ float CObjectTracker::Matching(TRaster32P *frame, TRaster32P *frame_temp) if ((ok_u > 0) && (ok_v > 0)) { //Interpolate template - pixel_temp = new ValuePixel[dimx_int * dimy_int]; + std::unique_ptr pixel_temp(new ValuePixel[dimx_int * dimy_int]); //original value for (int i = 0; i <= (dimx - 1); i++) @@ -737,7 +724,7 @@ float CObjectTracker::Matching(TRaster32P *frame, TRaster32P *frame_temp) dimx_int_ric = ((dimx + ok_u - 1) * 2 - 1); dimy_int_ric = ((dimy + ok_v - 1) * 2 - 1); - area_ricerca = new ValuePixel[dimx_int_ric * dimy_int_ric]; + std::unique_ptr area_ricerca(new ValuePixel[dimx_int_ric * dimy_int_ric]); //Original value for (int i = 0; i <= ((dimx + ok_u - 1) - 1); i++) @@ -797,7 +784,7 @@ float CObjectTracker::Matching(TRaster32P *frame, TRaster32P *frame_temp) unsigned long indt, indc; - float *mat_dist = new float[(2 * ok_u - 1) * (2 * ok_v - 1)]; + std::unique_ptr mat_dist(new float[(2 * ok_u - 1) * (2 * ok_v - 1)]); float att_dist_cent = MAX_FLOAT; float dist_cent; @@ -953,12 +940,6 @@ float CObjectTracker::Matching(TRaster32P *frame, TRaster32P *frame_temp) m_sTrackingObject.X += u_sup / 2; m_sTrackingObject.Y += v_sup / 2; } - - delete[] area_ricerca; - delete[] mat_dist; - delete[] pixel_temp; - delete[] u_att; - delete[] v_att; } return min_dist; diff --git a/toonz/sources/toonz/ObjectTracker.h b/toonz/sources/toonz/ObjectTracker.h index 640c5c0..b9adb41 100644 --- a/toonz/sources/toonz/ObjectTracker.h +++ b/toonz/sources/toonz/ObjectTracker.h @@ -1,8 +1,8 @@ - - #if !defined(OBEJCTTRACKER_H_INCLUDED_) #define OBEJCTTRACKER_H_INCLUDED_ +#include + #include "traster.h" #include "predict3d.h" @@ -55,8 +55,8 @@ private: short H_old; //histogram - float *initHistogram; - float *weights_background; + std::unique_ptr initHistogram; + std::unique_ptr weights_background; //template characterize short X_temp; diff --git a/toonz/sources/toonz/addfilmstripframespopup.cpp b/toonz/sources/toonz/addfilmstripframespopup.cpp index 555c247..6a6f423 100644 --- a/toonz/sources/toonz/addfilmstripframespopup.cpp +++ b/toonz/sources/toonz/addfilmstripframespopup.cpp @@ -24,9 +24,9 @@ AddFilmstripFramesPopup::AddFilmstripFramesPopup() { setWindowTitle(tr("Add Frames")); - m_startFld = new IntLineEdit(this); - m_endFld = new IntLineEdit(this); - m_stepFld = new IntLineEdit(this); + m_startFld = new DVGui::IntLineEdit(this); + m_endFld = new DVGui::IntLineEdit(this); + m_stepFld = new DVGui::IntLineEdit(this); m_okBtn = new QPushButton(tr("Add"), this); m_cancelBtn = new QPushButton(tr("Cancel"), this); diff --git a/toonz/sources/toonz/addfilmstripframespopup.h b/toonz/sources/toonz/addfilmstripframespopup.h index 2b09085..f4df9a2 100644 --- a/toonz/sources/toonz/addfilmstripframespopup.h +++ b/toonz/sources/toonz/addfilmstripframespopup.h @@ -10,20 +10,18 @@ class QPushButton; class QLineEdit; -using namespace DVGui; - //============================================================================= // AddFilmstripFramesPopup //----------------------------------------------------------------------------- -class AddFilmstripFramesPopup : public Dialog +class AddFilmstripFramesPopup : public DVGui::Dialog { Q_OBJECT QPushButton *m_okBtn; QPushButton *m_cancelBtn; - IntLineEdit *m_startFld, *m_endFld, *m_stepFld; + DVGui::IntLineEdit *m_startFld, *m_endFld, *m_stepFld; public slots: void onOk(); diff --git a/toonz/sources/toonz/batches.cpp b/toonz/sources/toonz/batches.cpp index 4a9c5e6..7d6c855 100644 --- a/toonz/sources/toonz/batches.cpp +++ b/toonz/sources/toonz/batches.cpp @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #define _WIN32_WINNT 0x0500 // per CreateJobObject e affini #endif @@ -114,10 +114,10 @@ bool LoadTaskPopup::execute() DVGui::error(toQString(fp) + tr(" does not exist.")); return false; } else if (m_isRenderTask && fp.getType() != "tnz") { - error(toQString(fp) + tr(" you can load only TNZ files for render task.")); + DVGui::error(toQString(fp) + tr(" you can load only TNZ files for render task.")); return false; } else if (!m_isRenderTask && fp.getType() != "tnz" && fp.getType() != "cln") { - error(toQString(fp) + tr(" you can load only TNZ or CLN files for cleanup task.")); + DVGui::error(toQString(fp) + tr(" you can load only TNZ or CLN files for cleanup task.")); return false; } @@ -478,7 +478,7 @@ void BatchesController::removeTask(const QString &id) TFarmTask *task = it->second; if (task->m_status == Running || task->m_status == Waiting) { - MsgBox(WARNING, taskBusyStr().arg(task->m_name)); + DVGui::warning(taskBusyStr().arg(task->m_name)); return; } @@ -531,7 +531,7 @@ void BatchesController::removeAllTasks() for (tt = m_tasks.begin(); tt != tEnd; ++tt) { TFarmTask *task = tt->second; if (task->m_status == Running || task->m_status == Waiting) { - MsgBox(WARNING, taskBusyStr().arg(task->m_name)); + DVGui::warning(taskBusyStr().arg(task->m_name)); return; } } @@ -826,7 +826,7 @@ void BatchesController::onExit(bool &ret) int answer = 0; if (m_dirtyFlag) - answer = MsgBox(QString(tr("The current task list has been modified.\nDo you want to save your changes?")), tr("Save"), tr("Discard"), tr("Cancel"), 1); + answer = DVGui::MsgBox(QString(tr("The current task list has been modified.\nDo you want to save your changes?")), tr("Save"), tr("Discard"), tr("Cancel"), 1); ret = true; if (answer == 3) @@ -858,7 +858,7 @@ void BatchesController::loadTask(bool isRenderTask) void BatchesController::doLoad(const TFilePath &fp) { if (m_dirtyFlag) { - int ret = MsgBox(QString(tr("The current task list has been modified.\nDo you want to save your changes?")), tr("Save"), tr("Discard"), tr("Cancel")); + int ret = DVGui::MsgBox(QString(tr("The current task list has been modified.\nDo you want to save your changes?")), tr("Save"), tr("Discard"), tr("Cancel")); if (ret == 1) save(); else if (ret == 3 || ret == 0) @@ -930,7 +930,7 @@ QString BatchesController::getListName() const void BatchesController::saveas() { if (getTaskCount() == 0) { - MsgBox(WARNING, tr("The Task List is empty!")); + DVGui::warning(tr("The Task List is empty!")); return; } diff --git a/toonz/sources/toonz/batches.h b/toonz/sources/toonz/batches.h index 1b67d24..6ff544e 100644 --- a/toonz/sources/toonz/batches.h +++ b/toonz/sources/toonz/batches.h @@ -20,7 +20,7 @@ class TFarmController; //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4786) #endif @@ -147,7 +147,7 @@ public: //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(pop) #endif diff --git a/toonz/sources/toonz/batchserversviewer.cpp b/toonz/sources/toonz/batchserversviewer.cpp index a71e146..2d6ac1a 100644 --- a/toonz/sources/toonz/batchserversviewer.cpp +++ b/toonz/sources/toonz/batchserversviewer.cpp @@ -32,7 +32,7 @@ public: //----------------------------------------------------------------------------- FarmServerListView::FarmServerListView(QWidget *parent) - : QListWidget(parent), m_menu(0) + : QListWidget(parent) { setFrameStyle(QFrame::StyledPanel); } @@ -55,7 +55,7 @@ void FarmServerListView::update() new MyListItem(sid.m_id, sid.m_name, this); } } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); } } @@ -73,7 +73,7 @@ void FarmServerListView::activate() BatchesController::instance()->update(); static_cast(parentWidget())->updateSelected(); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); } } @@ -91,7 +91,7 @@ void FarmServerListView::deactivate() BatchesController::instance()->update(); static_cast(parentWidget())->updateSelected(); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); } } //----------------------------------------------------------------------------- @@ -102,17 +102,14 @@ void FarmServerListView::openContextMenu(const QPoint &p) if (!item) return; - if (m_menu) - delete m_menu; - - m_menu = new QMenu(this); + m_menu.reset(new QMenu(this)); TFarmController *controller = getTFarmController(); ServerState state; try { state = controller->queryServerState2(item->m_id); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); return; } @@ -162,7 +159,7 @@ void BatchServersViewer::updateServerInfo(const QString &id) m_tasks->setText(""); m_cpu->setText(QString::number(TSystem::getProcessorCount())); -#ifdef WIN32 +#ifdef _WIN32 //Please observe that the commented value is NOT the same reported by tfarmserver... MEMORYSTATUSEX buff; buff.dwLength = sizeof(MEMORYSTATUSEX); @@ -184,7 +181,7 @@ void BatchServersViewer::updateServerInfo(const QString &id) try { controller->queryServerInfo(id, info); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); } switch (info.m_state) { @@ -226,7 +223,7 @@ void BatchServersViewer::updateServerInfo(const QString &id) m_tasks->setText("<" + task.m_id + "> " + task.m_name); } catch (TException &e) { m_tasks->setText(""); - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); } } @@ -356,15 +353,15 @@ void BatchServersViewer::onProcessWith(int index) try { connected = TFarmStuff::testConnectionToController(); } catch (TMissingGRootEnvironmentVariable &) { - MsgBox(WARNING, QString(tr("In order to use the render farm you have to define the Farm Global Root first."))); + DVGui::warning(QString(tr("In order to use the render farm you have to define the Farm Global Root first."))); m_processWith->setCurrentIndex(0); return; } catch (TMissingGRootFolder &) { - MsgBox(WARNING, tr("The Farm Global Root folder doesn't exist\nPlease create this folder before using the render farm.")); + DVGui::warning(tr("The Farm Global Root folder doesn't exist\nPlease create this folder before using the render farm.")); m_processWith->setCurrentIndex(0); return; } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); m_processWith->setCurrentIndex(0); return; } @@ -380,7 +377,7 @@ void BatchServersViewer::onProcessWith(int index) .arg(hostName) .arg(QString::number(port))); - MsgBox(WARNING, msg); + DVGui::warning(msg); m_processWith->setCurrentIndex(0); return; } diff --git a/toonz/sources/toonz/batchserversviewer.h b/toonz/sources/toonz/batchserversviewer.h index 139e077..a8c85b6 100644 --- a/toonz/sources/toonz/batchserversviewer.h +++ b/toonz/sources/toonz/batchserversviewer.h @@ -1,19 +1,19 @@ - - #ifndef BATCHSERVERSVIEWER_H #define BATCHSERVERSVIEWER_H +#include + #include "toonzqt/dvdialog.h" #include "toonzqt/doublefield.h" #include "toonzqt/lineedit.h" #include #include +#include class QComboBox; class FarmServerListView; class QListWidgetItem; -using namespace DVGui; //============================================================================= // BatchServersViewer @@ -36,7 +36,7 @@ protected slots: private: void openContextMenu(const QPoint &p); void mousePressEvent(QMouseEvent *event); - QMenu *m_menu; + std::unique_ptr m_menu; }; class BatchServersViewer : public QFrame @@ -60,17 +60,17 @@ protected slots: private: QString m_serverId; - LineEdit *m_farmRootField; + DVGui::LineEdit *m_farmRootField; QComboBox *m_processWith; FarmServerListView *m_serverList; - LineEdit *m_name; - LineEdit *m_ip; - LineEdit *m_port; - LineEdit *m_tasks; - LineEdit *m_state; - LineEdit *m_cpu; - LineEdit *m_mem; + DVGui::LineEdit *m_name; + DVGui::LineEdit *m_ip; + DVGui::LineEdit *m_port; + DVGui::LineEdit *m_tasks; + DVGui::LineEdit *m_state; + DVGui::LineEdit *m_cpu; + DVGui::LineEdit *m_mem; void updateServerInfo(const QString &id); }; diff --git a/toonz/sources/toonz/castselection.cpp b/toonz/sources/toonz/castselection.cpp index 8bbe91b..d21c3b5 100644 --- a/toonz/sources/toonz/castselection.cpp +++ b/toonz/sources/toonz/castselection.cpp @@ -41,16 +41,15 @@ CastSelection::~CastSelection() void CastSelection::getSelectedLevels(std::vector &levels) { assert(m_browser); - CastItems *castItems = m_browser->getCastItems(); - int i; - for (i = 0; i < castItems->getItemCount(); i++) { + CastItems const& castItems = m_browser->getCastItems(); + for (int i = 0; i < castItems.getItemCount(); i++) { if (!isSelected(i)) continue; - TXshLevel *level = castItems->getItem(i)->getSimpleLevel(); + TXshLevel *level = castItems.getItem(i)->getSimpleLevel(); if (!level) - level = castItems->getItem(i)->getPaletteLevel(); + level = castItems.getItem(i)->getPaletteLevel(); if (!level) - level = castItems->getItem(i)->getSoundLevel(); + level = castItems.getItem(i)->getSoundLevel(); if (level) levels.push_back(level); } diff --git a/toonz/sources/toonz/castviewer.cpp b/toonz/sources/toonz/castviewer.cpp index 3c55286..6718800 100644 --- a/toonz/sources/toonz/castviewer.cpp +++ b/toonz/sources/toonz/castviewer.cpp @@ -458,7 +458,7 @@ void CastTreeViewer::deleteFolder() QString itemName = item->data(0, Qt::DisplayRole).toString(); if (itemName == AudioFolderName) return; - int ret = MsgBox(tr("Delete folder ") + item->text(0) + "?", tr("Yes"), tr("No"), 1); + int ret = DVGui::MsgBox(tr("Delete folder ") + item->text(0) + "?", tr("Yes"), tr("No"), 1); if (ret == 2 || ret == 0) return; QTreeWidgetItem *parentItem = item->parent(); @@ -483,7 +483,11 @@ CastBrowser::CastBrowser(QWidget *parent, Qt::WindowFlags flags) #else CastBrowser::CastBrowser(QWidget *parent, Qt::WFlags flags) #endif - : QSplitter(parent), m_treeViewer(0), m_folderName(0), m_itemViewer(0), m_castItems(new CastItems()) + : QSplitter(parent) + , m_treeViewer(0) + , m_folderName(0) + , m_itemViewer(0) + , m_castItems(new CastItems()) { // style sheet setObjectName("CastBrowser"); @@ -555,7 +559,6 @@ CastBrowser::CastBrowser(QWidget *parent, Qt::WFlags flags) CastBrowser::~CastBrowser() { - delete m_castItems; } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/castviewer.h b/toonz/sources/toonz/castviewer.h index e8a713f..719d91c 100644 --- a/toonz/sources/toonz/castviewer.h +++ b/toonz/sources/toonz/castviewer.h @@ -1,8 +1,8 @@ - - #ifndef CAST_VIEWER_INCLUDED #define CAST_VIEWER_INCLUDED +#include + #include #include @@ -74,7 +74,7 @@ class CastBrowser : public QSplitter, public DvItemListModel QLabel *m_folderName; DvItemViewer *m_itemViewer; - CastItems *m_castItems; + std::unique_ptr m_castItems; public: #if QT_VERSION >= 0x050500 @@ -84,7 +84,7 @@ public: #endif ~CastBrowser(); - CastItems *getCastItems() const { return m_castItems; } + CastItems const& getCastItems() const { return *m_castItems; } void sortByDataModel(DataType dataType, bool isDiscendent); diff --git a/toonz/sources/toonz/cellkeyframeselection.cpp b/toonz/sources/toonz/cellkeyframeselection.cpp index fae7b24..859f985 100644 --- a/toonz/sources/toonz/cellkeyframeselection.cpp +++ b/toonz/sources/toonz/cellkeyframeselection.cpp @@ -23,7 +23,9 @@ //----------------------------------------------------------------------------- TCellKeyframeSelection::TCellKeyframeSelection(TCellSelection *cellSelection, TKeyframeSelection *keyframeSelection) - : m_cellSelection(cellSelection), m_keyframeSelection(keyframeSelection), m_xsheetHandle(0) + : m_cellSelection(cellSelection) + , m_keyframeSelection(keyframeSelection) + , m_xsheetHandle(0) { } diff --git a/toonz/sources/toonz/cellselectioncommand.cpp b/toonz/sources/toonz/cellselectioncommand.cpp index 9444448..21b5642 100644 --- a/toonz/sources/toonz/cellselectioncommand.cpp +++ b/toonz/sources/toonz/cellselectioncommand.cpp @@ -1,4 +1,4 @@ - +#include #include "cellselection.h" @@ -598,7 +598,7 @@ class ReframeUndo : public TUndo int m_r0, m_r1; int m_type; int m_nr; - TXshCell *m_cells; + std::unique_ptr m_cells; public: std::vector m_newRows; @@ -629,11 +629,11 @@ public: //----------------------------------------------------------------------------- ReframeUndo::ReframeUndo(int r0, int r1, std::vector columnIndeces, int type) - : m_r0(r0), m_r1(r1), m_type(type), m_nr(0), m_cells(0), m_columnIndeces(columnIndeces) + : m_r0(r0), m_r1(r1), m_type(type), m_nr(0), m_columnIndeces(columnIndeces) { m_nr = m_r1 - m_r0 + 1; assert(m_nr > 0); - m_cells = new TXshCell[m_nr * (int)m_columnIndeces.size()]; + m_cells.reset(new TXshCell[m_nr * (int)m_columnIndeces.size()]); assert(m_cells); int k = 0; for (int r = r0; r <= r1; r++) @@ -647,8 +647,6 @@ ReframeUndo::ReframeUndo(int r0, int r1, std::vector columnIndeces, int typ ReframeUndo::~ReframeUndo() { - delete[] m_cells; - m_cells = 0; } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/cleanuppaletteviewer.cpp b/toonz/sources/toonz/cleanuppaletteviewer.cpp index 9512d3f..21cfab1 100644 --- a/toonz/sources/toonz/cleanuppaletteviewer.cpp +++ b/toonz/sources/toonz/cleanuppaletteviewer.cpp @@ -217,7 +217,7 @@ void CleanupPaletteViewer::onRemoveClicked(bool) QString question; question = QObject::tr("Are you sure you want to delete the selected cleanup color?"); - int ret = MsgBox(question, QObject::tr("Delete"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Delete"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return; diff --git a/toonz/sources/toonz/cleanuppaletteviewer.h b/toonz/sources/toonz/cleanuppaletteviewer.h index 52dd3b7..32296c0 100644 --- a/toonz/sources/toonz/cleanuppaletteviewer.h +++ b/toonz/sources/toonz/cleanuppaletteviewer.h @@ -22,8 +22,6 @@ namespace DVGui class CleanupColorField; } -using namespace DVGui; - //------------------------------------------------------------------ //******************************************************************************** @@ -38,7 +36,7 @@ class CleanupPaletteViewer : public QWidget QFrame *m_scrollWidget; QScrollArea *m_scrollArea; - std::vector m_colorFields; + std::vector m_colorFields; QPushButton *m_remove, *m_add; bool m_greyMode; diff --git a/toonz/sources/toonz/cleanuppopup.cpp b/toonz/sources/toonz/cleanuppopup.cpp index d19135d..121c922 100644 --- a/toonz/sources/toonz/cleanuppopup.cpp +++ b/toonz/sources/toonz/cleanuppopup.cpp @@ -204,19 +204,19 @@ void addCleanupDefaultPalette(TXshSimpleLevelP sl) TFileStatus pfs(palettePath); if (!pfs.doesExist() || !pfs.isReadable()) { - MsgBox(WARNING, QString("CleanupDefaultPalette file: %1 is not found!").arg(QString::fromStdWString(palettePath.getWideString()))); + DVGui::warning(QString("CleanupDefaultPalette file: %1 is not found!").arg(QString::fromStdWString(palettePath.getWideString()))); return; } TIStream is(palettePath); if (!is) { - MsgBox(WARNING, QString("CleanupDefaultPalette file: failed to get TIStream")); + DVGui::warning(QString("CleanupDefaultPalette file: failed to get TIStream")); return; } string tagName; if (!is.matchTag(tagName) || tagName != "palette") { - MsgBox(WARNING, QString("CleanupDefaultPalette file: This is not palette file")); + DVGui::warning(QString("CleanupDefaultPalette file: This is not palette file")); return; } @@ -607,7 +607,7 @@ bool CleanupPopup::analyzeCleanupList() // Thus, the conservative approach is not feasible. // Inform the user and abort cleanup - DVGui::MsgBox(DVGui::WARNING, tr("There were errors opening the existing level \"%1\".\n\nPlease choose to delete the existing level and create a new one\nwhen running the cleanup process.").arg(QString::fromStdWString(outputPath.getLevelNameW()))); + DVGui::warning(tr("There were errors opening the existing level \"%1\".\n\nPlease choose to delete the existing level and create a new one\nwhen running the cleanup process.").arg(QString::fromStdWString(outputPath.getLevelNameW()))); return false; } @@ -618,7 +618,7 @@ bool CleanupPopup::analyzeCleanupList() m_params->getOutputImageInfo(outRes, outDpi.x, outDpi.y); if (oldRes != outRes) { - DVGui::MsgBox(DVGui::WARNING, tr("The resulting resolution of level \"%1\"\ndoes not match with that of previously cleaned up level drawings.\n\nPlease set the right camera resolution and closest field, or choose to delete\nthe existing level and create a new one when running the cleanup process.").arg(QString::fromStdWString(outputPath.getLevelNameW()))); + DVGui::warning(tr("The resulting resolution of level \"%1\"\ndoes not match with that of previously cleaned up level drawings.\n\nPlease set the right camera resolution and closest field, or choose to delete\nthe existing level and create a new one when running the cleanup process.").arg(QString::fromStdWString(outputPath.getLevelNameW()))); return false; } @@ -662,7 +662,7 @@ bool CleanupPopup::analyzeCleanupList() } question += QObject::tr("\nAre you sure ?"); - int ret = MsgBox(question, QObject::tr("Delete"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Delete"), QObject::tr("Cancel"), 0); if (ret == 0 || ret == 2) { return false; } else if (ret == 1) { @@ -788,7 +788,7 @@ void CleanupPopup::execute() // If there are no (more) frames to cleanup, warn and quit int framesCount = m_completion.second; if (!framesCount) { - DVGui::MsgBox(DVGui::INFORMATION, tr("It is not possible to cleanup: the cleanup list is empty.")); + DVGui::info(tr("It is not possible to cleanup: the cleanup list is empty.")); reset(); return; @@ -946,7 +946,7 @@ QString CleanupPopup::setupLevel() TIStream is(targetPalettePath); string tagName; if (!is.matchTag(tagName) || tagName != "palette") { - MsgBox(WARNING, QString("CleanupDefaultPalette file: This is not palette file")); + DVGui::warning(QString("CleanupDefaultPalette file: This is not palette file")); return NULL; } m_originalPalette = new TPalette(); @@ -1150,7 +1150,7 @@ void CleanupPopup::cleanupFrame() bool autocentered; ri = cl->autocenterOnly(original, false, autocentered); if (!autocentered) - DVGui::MsgBox(DVGui::WARNING, QObject::tr("The autocentering failed on the current drawing.")); + DVGui::warning(QObject::tr("The autocentering failed on the current drawing.")); } sl->setFrame(fid, ri); @@ -1205,7 +1205,7 @@ void CleanupPopup::cleanupFrame() int autocenterType = params->m_autocenterType; if (autocenterType == CleanupTypes::AUTOCENTER_FDG && !cpi->m_autocentered) - DVGui::MsgBox(DVGui::WARNING, QObject::tr("The autocentering failed on the current drawing.")); + DVGui::warning(QObject::tr("The autocentering failed on the current drawing.")); delete cpi; @@ -1294,7 +1294,7 @@ void CleanupPopup::onCleanupFrame() const QString &err = setupLevel(); if (!err.isEmpty()) { - MsgBox(DVGui::CRITICAL, err); + DVGui::error(err); return; } } @@ -1331,7 +1331,7 @@ void CleanupPopup::onCleanupAllFrame() const QString &err = setupLevel(); if (!err.isEmpty()) { - MsgBox(DVGui::CRITICAL, err); + DVGui::error(err); return; } } diff --git a/toonz/sources/toonz/cleanupsettingsmodel.cpp b/toonz/sources/toonz/cleanupsettingsmodel.cpp index 9871041..7860297 100644 --- a/toonz/sources/toonz/cleanupsettingsmodel.cpp +++ b/toonz/sources/toonz/cleanupsettingsmodel.cpp @@ -100,7 +100,7 @@ public: savePath = savePath.withNoFrame().withType("cln"); //Just to be sure if (TFileStatus(savePath).doesExist()) { - int ret = MsgBox(QObject::tr("The cleanup settings file for the %1 level already exists.\n Do you want to overwrite it?") + int ret = DVGui::MsgBox(QObject::tr("The cleanup settings file for the %1 level already exists.\n Do you want to overwrite it?") .arg(toQString(savePath.withoutParentDir())), QObject::tr("Overwrite"), QObject::tr("Don't Overwrite"), 0); @@ -135,7 +135,7 @@ public: return false; if (!TSystem::doesExistFileOrLevel(loadPath)) { - error(tr("%1 does not exist.").arg(toQString(loadPath))); + DVGui::error(tr("%1 does not exist.").arg(toQString(loadPath))); return false; } @@ -452,7 +452,7 @@ void CleanupSettingsModel::processFrame(TXshSimpleLevel *sl, TFrameId fid) m_cameraTestTransformed = cl->autocenterOnly(m_original.getPointer(), true, autocentered); if (params->m_autocenterType != CleanupTypes::AUTOCENTER_NONE && !autocentered) - MsgBox(DVGui::WARNING, QObject::tr("The autocentering failed on the current drawing.")); + DVGui::warning(QObject::tr("The autocentering failed on the current drawing.")); } } } diff --git a/toonz/sources/toonz/cleanupsettingspane.cpp b/toonz/sources/toonz/cleanupsettingspane.cpp index 72c34f6..6a63c90 100644 --- a/toonz/sources/toonz/cleanupsettingspane.cpp +++ b/toonz/sources/toonz/cleanupsettingspane.cpp @@ -499,7 +499,7 @@ void CleanupSettingsPane::onSaveSettings() { /*--- Clueaup保存先を指定していないとエラーを返す ---*/ if (m_pathField->getPath().isEmpty()) { - MsgBox(WARNING, "Please fill the Save In field."); + DVGui::warning("Please fill the Save In field."); return; } CleanupSettingsModel::instance()->promptSave(); diff --git a/toonz/sources/toonz/cleanupsettingspopup.cpp b/toonz/sources/toonz/cleanupsettingspopup.cpp index 9d735b4..a89ae7b 100644 --- a/toonz/sources/toonz/cleanupsettingspopup.cpp +++ b/toonz/sources/toonz/cleanupsettingspopup.cpp @@ -68,10 +68,10 @@ CleanupTab::CleanupTab() int row = 0; // AutoCenter - m_autoCenter = new CheckBox(tr("Autocenter"), this); + m_autoCenter = new DVGui::CheckBox(tr("Autocenter"), this); settingsLayout->addWidget(m_autoCenter, row++, 1, Qt::AlignLeft); - m_autoCenter->setFixedSize(150, WidgetHeight); + m_autoCenter->setFixedSize(150, DVGui::WidgetHeight); // Pegbar Holes settingsLayout->addWidget(new QLabel(tr("Pegbar Holes:")), row, 0, Qt::AlignRight); @@ -79,7 +79,7 @@ CleanupTab::CleanupTab() m_pegHolesOm = new QComboBox(this); settingsLayout->addWidget(m_pegHolesOm, row++, 1, Qt::AlignLeft); - m_pegHolesOm->setFixedHeight(WidgetHeight); + m_pegHolesOm->setFixedHeight(DVGui::WidgetHeight); m_pegHolesOm->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); QStringList pegbarHoles; @@ -95,7 +95,7 @@ CleanupTab::CleanupTab() m_fieldGuideOm = new QComboBox(this); settingsLayout->addWidget(m_fieldGuideOm, row++, 1, Qt::AlignLeft); - m_fieldGuideOm->setFixedHeight(WidgetHeight); + m_fieldGuideOm->setFixedHeight(DVGui::WidgetHeight); m_fieldGuideOm->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); std::vector fdgNames; @@ -104,7 +104,7 @@ CleanupTab::CleanupTab() for (int i = 0; i < (int)fdgNames.size(); i++) m_fieldGuideOm->addItem(QString(fdgNames[i].c_str())); - settingsLayout->addWidget(new Separator(), row++, 0, 1, 2); + settingsLayout->addWidget(new DVGui::Separator(), row++, 0, 1, 2); // Rotate settingsLayout->addWidget(new QLabel(tr("Rotate:")), row, 0, Qt::AlignRight); @@ -112,7 +112,7 @@ CleanupTab::CleanupTab() m_rotateOm = new QComboBox(this); settingsLayout->addWidget(m_rotateOm, row++, 1, Qt::AlignLeft); - m_rotateOm->setFixedHeight(WidgetHeight); + m_rotateOm->setFixedHeight(DVGui::WidgetHeight); m_rotateOm->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); QStringList rotate; @@ -134,25 +134,25 @@ CleanupTab::CleanupTab() flipLayout->setSizeConstraint(QLayout::SetFixedSize); flipLayout->setMargin(0); - m_flipX = new CheckBox(tr("Horizontal"), flipWidget); + m_flipX = new DVGui::CheckBox(tr("Horizontal"), flipWidget); flipLayout->addWidget(m_flipX, 0, Qt::AlignLeft); - m_flipX->setFixedHeight(WidgetHeight); + m_flipX->setFixedHeight(DVGui::WidgetHeight); - m_flipY = new CheckBox(tr("Vertical"), flipWidget); + m_flipY = new DVGui::CheckBox(tr("Vertical"), flipWidget); flipLayout->addWidget(m_flipY, 0, Qt::AlignLeft); - m_flipY->setFixedHeight(WidgetHeight); + m_flipY->setFixedHeight(DVGui::WidgetHeight); flipLayout->addStretch(1); // Save In settingsLayout->addWidget(new QLabel(tr("Save in:")), row, 0, Qt::AlignRight); - m_pathField = new FileField(this, QString("")); + m_pathField = new DVGui::FileField(this, QString("")); settingsLayout->addWidget(m_pathField, row++, 1); - m_pathField->setFixedHeight(WidgetHeight); + m_pathField->setFixedHeight(DVGui::WidgetHeight); // Connections bool ret = true; @@ -256,7 +256,7 @@ ProcessingTab::ProcessingTab() settingsLayout->addWidget(new QLabel(tr("Line Processing:")), row, 0, Qt::AlignRight); m_lineProcessing = new QComboBox(this); - m_lineProcessing->setFixedHeight(WidgetHeight); + m_lineProcessing->setFixedHeight(DVGui::WidgetHeight); m_lineProcessing->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); QStringList items; @@ -270,7 +270,7 @@ ProcessingTab::ProcessingTab() settingsLayout->addWidget(m_antialiasLabel, row, 0, Qt::AlignRight); m_antialias = new QComboBox(this); - m_antialias->setFixedHeight(WidgetHeight); + m_antialias->setFixedHeight(DVGui::WidgetHeight); m_antialias->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); items.clear(); @@ -284,7 +284,7 @@ ProcessingTab::ProcessingTab() settingsLayout->addWidget(m_autoadjustLabel, row, 0, Qt::AlignRight); m_autoadjustOm = new QComboBox(this); - m_autoadjustOm->setFixedHeight(WidgetHeight); + m_autoadjustOm->setFixedHeight(DVGui::WidgetHeight); m_autoadjustOm->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); items.clear(); @@ -299,30 +299,30 @@ ProcessingTab::ProcessingTab() // Sharpness m_sharpLabel = new QLabel(tr("Sharpness:")); settingsLayout->addWidget(m_sharpLabel, row, 0, Qt::AlignRight); - m_sharpness = new DoubleField(this); - m_sharpness->setFixedHeight(WidgetHeight); + m_sharpness = new DVGui::DoubleField(this); + m_sharpness->setFixedHeight(DVGui::WidgetHeight); m_sharpness->setValues(90, 0, 100); settingsLayout->addWidget(m_sharpness, row++, 1); // Despeckling m_despeckLabel = new QLabel(tr("Despeckling:")); settingsLayout->addWidget(m_despeckLabel, row, 0, Qt::AlignRight); - m_despeckling = new IntField(this); - m_despeckling->setFixedHeight(WidgetHeight); + m_despeckling = new DVGui::IntField(this); + m_despeckling->setFixedHeight(DVGui::WidgetHeight); m_despeckling->setValues(2, 0, 20); settingsLayout->addWidget(m_despeckling, row++, 1); // MLAA Value m_aaValueLabel = new QLabel(tr("MLAA Intensity:")); settingsLayout->addWidget(m_aaValueLabel, row, 0, Qt::AlignRight); - m_aaValue = new IntField(this); - m_aaValue->setFixedHeight(WidgetHeight); + m_aaValue = new DVGui::IntField(this); + m_aaValue->setFixedHeight(DVGui::WidgetHeight); m_aaValue->setValues(70, 0, 100); settingsLayout->addWidget(m_aaValue, row++, 1); //---------------------- Palette ---------------------------- - m_paletteSep = new Separator(); + m_paletteSep = new DVGui::Separator(); mainLayout->addWidget(m_paletteSep); m_paletteViewer = new CleanupPaletteViewer(this); mainLayout->addWidget(m_paletteViewer, 1); // The palette viewer dominates on the stretch below diff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cpp index d9be0b5..5acd0ea 100644 --- a/toonz/sources/toonz/colormodelviewer.cpp +++ b/toonz/sources/toonz/colormodelviewer.cpp @@ -156,7 +156,7 @@ void ColorModelViewer::loadImage(const TFilePath &fp) QList list; list.append(QObject::tr("Overwrite the destination palette.")); list.append(QObject::tr("Keep the destination palette and apply it to the color model.")); - int ret = RadioButtonMsgBox(DVGui::WARNING, question, list); + int ret = DVGui::RadioButtonMsgBox(DVGui::WARNING, question, list); if (ret == 0) return; bool replace = false; @@ -558,7 +558,7 @@ void ColorModelViewer::removeColorModel() void ColorModelViewer::onRefImageNotFound() { - MsgBox(DVGui::INFORMATION, tr("It is not possible to retrieve the color model set for the current level.")); + DVGui::info(tr("It is not possible to retrieve the color model set for the current level.")); } //============================================================================= diff --git a/toonz/sources/toonz/comboviewerpane.h b/toonz/sources/toonz/comboviewerpane.h index 7dee56e..f4b4277 100644 --- a/toonz/sources/toonz/comboviewerpane.h +++ b/toonz/sources/toonz/comboviewerpane.h @@ -24,8 +24,6 @@ class FlipConsole; class TXshLevel; class ToolOptions; -using namespace DVGui; - //============================================================================= // ComboViewerPanel //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/convertpopup.cpp b/toonz/sources/toonz/convertpopup.cpp index c055192..0653a40 100644 --- a/toonz/sources/toonz/convertpopup.cpp +++ b/toonz/sources/toonz/convertpopup.cpp @@ -117,7 +117,7 @@ void ConvertPopup::Converter::run() if (TSystem::doesExistFileOrLevel(dstFilePath)) { if (m_parent->m_skip->isChecked()) { - DVGui::MsgBox(INFORMATION, tr("Level %1 already exists; skipped.").arg(levelName)); + DVGui::info(tr("Level %1 already exists; skipped.").arg(levelName)); m_skippedCount++; continue; } else { @@ -168,7 +168,7 @@ void ConvertPopup::Converter::convertLevel(const TFilePath &sourceFileFullPath) popup->getFrameRange(sourceFileFullPath, from, to); if (from == TFrameId() || to == TFrameId()) { - DVGui::MsgBox(WARNING, tr("Level %1 has no frame; skipped.").arg(levelName)); + DVGui::warning(tr("Level %1 has no frame; skipped.").arg(levelName)); popup->m_notifier->notifyError(); return; @@ -212,7 +212,7 @@ void ConvertPopup::Converter::convertLevelWithConvert2Tlv(const TFilePath &sourc string errorMessage; if (!tlvConverter->init(errorMessage)) { - DVGui::MsgBox(WARNING, QString::fromStdString(errorMessage)); + DVGui::warning(QString::fromStdString(errorMessage)); tlvConverter->abort(); } else { int count = tlvConverter->getFramesToConvertCount(); @@ -220,7 +220,7 @@ void ConvertPopup::Converter::convertLevelWithConvert2Tlv(const TFilePath &sourc for (int j = 0; j < count && !stop; j++) { if (!tlvConverter->convertNext(errorMessage)) { stop = true; - DVGui::MsgBox(WARNING, QString::fromStdString(errorMessage)); + DVGui::warning(QString::fromStdString(errorMessage)); } if (popup->m_progressDialog->wasCanceled()) stop = true; @@ -287,10 +287,10 @@ ConvertPopup::ConvertPopup(bool specifyInput) SameAsPainted = tr("Same as Painted"); CreateNewPalette = tr("Create new palette"); - m_fromFld = new IntLineEdit(this); - m_toFld = new IntLineEdit(this); - m_saveInFileFld = new FileField(0, QString("")); - m_fileNameFld = new LineEdit(QString("")); + m_fromFld = new DVGui::IntLineEdit(this); + m_toFld = new DVGui::IntLineEdit(this); + m_saveInFileFld = new DVGui::FileField(0, QString("")); + m_fileNameFld = new DVGui::LineEdit(QString("")); m_fileFormat = new QComboBox(); m_formatOptions = new QPushButton(tr("Options"), this); m_bgColorField = new DVGui::ColorField(this, true, TPixel32::Transparent, 35, false); @@ -303,12 +303,12 @@ ConvertPopup::ConvertPopup(bool specifyInput) m_notifier = new ImageUtils::FrameTaskNotifier(); m_progressDialog = new DVGui::ProgressDialog("", tr("Cancel"), 0, 0); - m_skip = new CheckBox(tr("Skip Existing Files"), this); + m_skip = new DVGui::CheckBox(tr("Skip Existing Files"), this); m_removeDotBeforeFrameNumber = new QCheckBox(tr("Remove dot before frame number"), this); if (specifyInput) - m_convertFileFld = new FileField(0, QString(""), true); + m_convertFileFld = new DVGui::FileField(0, QString(""), true); else m_convertFileFld = 0; @@ -486,15 +486,15 @@ QFrame *ConvertPopup::createTlvSettings() m_tlvMode = new QComboBox(); m_unpaintedFolderLabel = new QLabel(tr("Unpainted File Folder:")); - m_unpaintedFolder = new FileField(0, QString(tr("Same as Painted")), true); + m_unpaintedFolder = new DVGui::FileField(0, QString(tr("Same as Painted")), true); m_suffixLabel = new QLabel(tr(" Unpainted File Suffix:")); - m_unpaintedSuffix = new LineEdit("_np"); + m_unpaintedSuffix = new DVGui::LineEdit("_np"); m_applyAutoclose = new QCheckBox(tr("Apply Autoclose")); m_saveBackupToNopaint = new QCheckBox(tr("Save Backup to \"nopaint\" Folder")); m_antialias = new QComboBox(); - m_antialiasIntensity = new IntLineEdit(0, 50, 0, 100); - m_palettePath = new FileField(0, QString(CreateNewPalette), true); - m_tolerance = new IntLineEdit(0, 0, 0, 255); + m_antialiasIntensity = new DVGui::IntLineEdit(0, 50, 0, 100); + m_palettePath = new DVGui::FileField(0, QString(CreateNewPalette), true); + m_tolerance = new DVGui::IntLineEdit(0, 0, 0, 255); m_unpaintedFolder->setFileMode(QFileDialog::DirectoryOnly); m_unpaintedSuffix->setMaximumWidth(40); @@ -795,7 +795,7 @@ void ConvertPopup::convertToTlv(bool toPainted) Convert2Tlv *converter = makeTlvConverter(m_srcFilePaths[i]); if (TSystem::doesExistFileOrLevel(converter->m_levelOut)) { if (m_skip->isChecked()) { - MsgBox(INFORMATION, QString(tr("Level ")) + QString::fromStdWString(converter->m_levelOut.withoutParentDir().getWideString()) + QString(tr(" already exists; skipped"))); + DVGui::info(QString(tr("Level ")) + QString::fromStdWString(converter->m_levelOut.withoutParentDir().getWideString()) + QString(tr(" already exists; skipped"))); delete converter; skipped++; continue; @@ -818,7 +818,7 @@ void ConvertPopup::convertToTlv(bool toPainted) string errorMessage; if (!converters[i]->init(errorMessage)) { converters[i]->abort(); - MsgBox(CRITICAL, QString::fromStdString(errorMessage)); + DVGui::error(QString::fromStdString(errorMessage)); delete converters[i]; converters[i] = 0; skipped++; @@ -839,14 +839,14 @@ void ConvertPopup::convertToTlv(bool toPainted) converters[i] = 0; } if (errorMessage != "") - MsgBox(CRITICAL, QString::fromStdString(errorMessage)); + DVGui::error(QString::fromStdString(errorMessage)); QApplication::restoreOverrideCursor(); FileBrowser::refreshFolder(m_srcFilePaths[0].getParentDir()); TFilePath::setUnderscoreFormatAllowed(false); return; } pb.setValue(++k); - MsgBox(INFORMATION, QString(tr("Level ")) + QString::fromStdWString(m_srcFilePaths[i].withoutParentDir().getWideString()) + QString(tr(" converted to tlv."))); + DVGui::info(QString(tr("Level ")) + QString::fromStdWString(m_srcFilePaths[i].withoutParentDir().getWideString()) + QString(tr(" converted to tlv."))); } TFilePath levelOut(converters[i]->m_levelOut); delete converters[i]; @@ -860,11 +860,11 @@ void ConvertPopup::convertToTlv(bool toPainted) if (m_srcFilePaths.size() == 1) { if (skipped == 0) - MsgBox(INFORMATION, tr("Level %1 converted to TLV Format").arg(QString::fromStdWString(m_srcFilePaths[0].withoutParentDir().getWideString()))); + DVGui::info(tr("Level %1 converted to TLV Format").arg(QString::fromStdWString(m_srcFilePaths[0].withoutParentDir().getWideString()))); else - MsgBox(WARNING, tr("Warning: Level %1 NOT converted to TLV Format").arg(QString::fromStdWString(m_srcFilePaths[0].withoutParentDir().getWideString()))); + DVGui::warning(tr("Warning: Level %1 NOT converted to TLV Format").arg(QString::fromStdWString(m_srcFilePaths[0].withoutParentDir().getWideString()))); } else - MsgBox(skipped == 0 ? INFORMATION : WARNING, tr("Converted %1 out of %2 Levels to TLV Format").arg(QString::number(m_srcFilePaths.size() - skipped)).arg(QString::number(m_srcFilePaths.size()))); + DVGui::MsgBox(skipped == 0 ? DVGui::INFORMATION : DVGui::WARNING, tr("Converted %1 out of %2 Levels to TLV Format").arg(QString::number(m_srcFilePaths.size() - skipped)).arg(QString::number(m_srcFilePaths.size()))); FileBrowser::refreshFolder(m_srcFilePaths[0].getParentDir()); TFilePath::setUnderscoreFormatAllowed(false); @@ -914,7 +914,7 @@ TPalette *ConvertPopup::readUserProvidedPalette() const is >> palette; // note! refCount==0 } catch (...) { - MsgBox(WARNING, tr("Warning: Can't read palette '%1' ").arg(m_palettePath->getPath())); + DVGui::warning(tr("Warning: Can't read palette '%1' ").arg(m_palettePath->getPath())); if (palette) { delete palette; palette = 0; @@ -964,14 +964,14 @@ void ConvertPopup::getFrameRange(const TFilePath &sourceFilePath, bool ConvertPopup::checkParameters() const { if (m_srcFilePaths.size() == 1 && m_fileNameFld->text().isEmpty()) { - MsgBox(WARNING, tr("No output filename specified: please choose a valid level name.")); + DVGui::warning(tr("No output filename specified: please choose a valid level name.")); return false; } if (m_fileFormat->currentText() == TlvExtension) { if (m_tlvMode->currentText() == TlvMode_PaintedFromTwoImages) { if (m_unpaintedSuffix->text() == "") { - MsgBox(WARNING, tr("No unpainted suffix specified: cannot convert.")); + DVGui::warning(tr("No unpainted suffix specified: cannot convert.")); return false; } } @@ -1046,22 +1046,22 @@ void ConvertPopup::onConvertFinished() int skippedCount = m_converter->getSkippedCount(); if (errorCount > 0) { if (skippedCount > 0) - MsgBox(CRITICAL, tr("Convert completed with %1 error(s) and %2 level(s) skipped").arg(errorCount).arg(skippedCount)); + DVGui::error(tr("Convert completed with %1 error(s) and %2 level(s) skipped").arg(errorCount).arg(skippedCount)); else - MsgBox(CRITICAL, tr("Convert completed with %1 error(s) ").arg(errorCount)); + DVGui::error(tr("Convert completed with %1 error(s) ").arg(errorCount)); } else if (skippedCount > 0) { - MsgBox(WARNING, tr("%1 level(s) skipped").arg(skippedCount)); + DVGui::warning(tr("%1 level(s) skipped").arg(skippedCount)); } /* if (m_srcFilePaths.size()==1) { if (skipped==0) - MsgBox(INFORMATION, tr("Level %1 converted to TLV Format").arg(QString::fromStdWString(m_srcFilePaths[0].withoutParentDir().getWideString()))); + DVGui::info(tr("Level %1 converted to TLV Format").arg(QString::fromStdWString(m_srcFilePaths[0].withoutParentDir().getWideString()))); else - MsgBox(WARNING, tr("Warning: Level %1 NOT converted to TLV Format").arg(QString::fromStdWString(m_srcFilePaths[0].withoutParentDir().getWideString()))); + DVGui::warning(tr("Warning: Level %1 NOT converted to TLV Format").arg(QString::fromStdWString(m_srcFilePaths[0].withoutParentDir().getWideString()))); } else - MsgBox(skipped==0?INFORMATION:WARNING, tr("Converted %1 out of %2 Levels to TLV Format").arg( QString::number(m_srcFilePaths.size()-skipped)).arg(QString::number(m_srcFilePaths.size()))); + DVGui::MsgBox(skipped==0?DVGui::INFORMATION:DVGui::WARNING, tr("Converted %1 out of %2 Levels to TLV Format").arg( QString::number(m_srcFilePaths.size()-skipped)).arg(QString::number(m_srcFilePaths.size()))); */ //TFilePath parentDir = m_srcFilePaths[0].getParentDir(); diff --git a/toonz/sources/toonz/curveio.cpp b/toonz/sources/toonz/curveio.cpp index b30b945..8aee7b6 100644 --- a/toonz/sources/toonz/curveio.cpp +++ b/toonz/sources/toonz/curveio.cpp @@ -115,7 +115,7 @@ bool SaveCurvePopup::execute() getCurve()->saveData(os); return true; } catch (...) { - DVGui::MsgBox(DVGui::WARNING, QObject::tr("It is not possible to save the curve.")); + DVGui::warning(QObject::tr("It is not possible to save the curve.")); return false; } } @@ -160,7 +160,7 @@ bool LoadCurvePopup::execute() curve->setDefaultValue(defaultValue); TUndoManager::manager()->add(undo); } catch (...) { - DVGui::MsgBox(DVGui::WARNING, QObject::tr("It is not possible to load the curve.")); + DVGui::warning(QObject::tr("It is not possible to load the curve.")); return false; } @@ -227,7 +227,7 @@ bool ExportCurvePopup::execute() os << curve->getValue(i) << std::endl; } } catch (...) { - DVGui::MsgBox(DVGui::WARNING, QObject::tr("It is not possible to export data.")); + DVGui::warning(QObject::tr("It is not possible to export data.")); return false; } diff --git a/toonz/sources/toonz/drawingdata.cpp b/toonz/sources/toonz/drawingdata.cpp index ec42f79..d5c4022 100644 --- a/toonz/sources/toonz/drawingdata.cpp +++ b/toonz/sources/toonz/drawingdata.cpp @@ -351,7 +351,7 @@ bool DrawingData::getLevelFrames(TXshSimpleLevel *sl, message = "NOTICE: Some styles were added from copied palette."; else message = "NOTICE: Some styles were added from original palette."; - DVGui::MsgBox(DVGui::INFORMATION, message); + DVGui::info(message); } QApplication::restoreOverrideCursor(); diff --git a/toonz/sources/toonz/duplicatepopup.cpp b/toonz/sources/toonz/duplicatepopup.cpp index 8f5f8cd..d6c1d0f 100644 --- a/toonz/sources/toonz/duplicatepopup.cpp +++ b/toonz/sources/toonz/duplicatepopup.cpp @@ -109,8 +109,8 @@ DuplicatePopup::DuplicatePopup() { setWindowTitle(tr("Repeat")); - m_countFld = new IntLineEdit(this); - m_upToFld = new IntLineEdit(this); + m_countFld = new DVGui::IntLineEdit(this); + m_upToFld = new DVGui::IntLineEdit(this); m_okBtn = new QPushButton(tr("Repeat"), this); m_cancelBtn = new QPushButton(tr("Close"), this); @@ -182,7 +182,7 @@ void DuplicatePopup::onApplyPressed() TApp::instance()->getCurrentScene()->setDirtyFlag(true); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); } catch (...) { - error(("Cannot duplicate")); + DVGui::error(("Cannot duplicate")); } } diff --git a/toonz/sources/toonz/duplicatepopup.h b/toonz/sources/toonz/duplicatepopup.h index d735231..0426cbb 100644 --- a/toonz/sources/toonz/duplicatepopup.h +++ b/toonz/sources/toonz/duplicatepopup.h @@ -11,8 +11,6 @@ // forward declaration class QPushButton; -using namespace DVGui; - //============================================================================= // DuplicatePopup //----------------------------------------------------------------------------- @@ -25,7 +23,7 @@ class DuplicatePopup : public QDialog QPushButton *m_cancelBtn; QPushButton *m_applyBtn; - IntLineEdit *m_countFld, *m_upToFld; + DVGui::IntLineEdit *m_countFld, *m_upToFld; int m_count, m_upTo; diff --git a/toonz/sources/toonz/dvdirtreeview.cpp b/toonz/sources/toonz/dvdirtreeview.cpp index b2db6c7..794edd3 100644 --- a/toonz/sources/toonz/dvdirtreeview.cpp +++ b/toonz/sources/toonz/dvdirtreeview.cpp @@ -392,7 +392,7 @@ void DvDirTreeView::dropEvent(QDropEvent *e) TSystem::removeFileOrLevel(srcFp); FileBrowser::refreshFolder(srcFp.getParentDir()); } else - MsgBox(CRITICAL, tr("There was an error copying %1 to %2").arg(toQString(srcFp)).arg(toQString(dstFp))); + DVGui::error(tr("There was an error copying %1 to %2").arg(toQString(srcFp)).arg(toQString(dstFp))); } } } @@ -567,7 +567,7 @@ void DvDirTreeView::deleteFolder() if (!node->isRenameEnabled()) return; TFilePath fp = node->getPath(); - int ret = MsgBox(tr("Delete folder ") + toQString(fp) + "?", tr("Yes"), tr("No"), 1); + int ret = DVGui::MsgBox(tr("Delete folder ") + toQString(fp) + "?", tr("Yes"), tr("No"), 1); if (ret == 2 || ret == 0) return; @@ -575,7 +575,7 @@ void DvDirTreeView::deleteFolder() TSystem::rmDir(fp); IconGenerator::instance()->remove(fp); } catch (...) { - MsgBox(CRITICAL, tr("It is not possible to delete the folder.") + toQString(fp)); + DVGui::error(tr("It is not possible to delete the folder.") + toQString(fp)); return; } @@ -617,7 +617,7 @@ void DvDirTreeView::updateVersionControl(DvDirVersionControlNode *node) if (rootNode) { QString localPath = QString::fromStdWString(rootNode->getLocalPath()); if (!QFile::exists(localPath)) { - MsgBox(WARNING, tr("The local path does not exist:") + " " + localPath); + DVGui::warning(tr("The local path does not exist:") + " " + localPath); return; } @@ -1164,7 +1164,7 @@ void DvDirTreeView::onCheckOutError(const QString &text) setRefreshVersionControlEnabled(true); - MsgBox(CRITICAL, tr("Refresh operation failed:\n") + text); + DVGui::error(tr("Refresh operation failed:\n") + text); } //----------------------------------------------------------------------------- @@ -1297,7 +1297,7 @@ void DvDirTreeView::onRefreshStatusError(const QString &text) return; m_currentRefreshedNode->restoreName(); setRefreshVersionControlEnabled(true); - MsgBox(CRITICAL, tr("Refresh operation failed:\n") + text); + DVGui::error(tr("Refresh operation failed:\n") + text); } //----------------------------------------------------------------------------- @@ -1327,7 +1327,7 @@ void DvDirTreeView::onCheckPartialLockError(const QString &text) m_thread.disconnect(SIGNAL(done(const QString &))); m_thread.disconnect(SIGNAL(error(const QString &))); setRefreshVersionControlEnabled(true); - MsgBox(CRITICAL, tr("Refresh operation failed:\n") + text); + DVGui::error(tr("Refresh operation failed:\n") + text); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/exportlevelcommand.cpp b/toonz/sources/toonz/exportlevelcommand.cpp index 06faa25..841c4ee 100644 --- a/toonz/sources/toonz/exportlevelcommand.cpp +++ b/toonz/sources/toonz/exportlevelcommand.cpp @@ -65,7 +65,7 @@ struct BusyCursorOverride { struct ExportOverwriteCB : public IoCmd::OverwriteCallbacks { bool overwriteRequest(const TFilePath &fp) { - int ret = MsgBox(QObject::tr("Warning: file %1 already exists.").arg(toQString(fp)), + int ret = DVGui::MsgBox(QObject::tr("Warning: file %1 already exists.").arg(toQString(fp)), QObject::tr("Continue Exporting"), QObject::tr("Stop Exporting"), 1); return (ret == 1); } @@ -530,7 +530,7 @@ bool IoCmd::exportLevel(const TFilePath &path, TXshSimpleLevel *sl, sl = TApp::instance()->getCurrentLevel()->getSimpleLevel(); if (!sl) { - MsgBox(CRITICAL, QObject::tr("No level selected!")); + DVGui::error(QObject::tr("No level selected!")); return false; } } diff --git a/toonz/sources/toonz/exportlevelpopup.cpp b/toonz/sources/toonz/exportlevelpopup.cpp index d7c2fe8..71a7706 100644 --- a/toonz/sources/toonz/exportlevelpopup.cpp +++ b/toonz/sources/toonz/exportlevelpopup.cpp @@ -72,7 +72,7 @@ struct MultiExportOverwriteCB : public IoCmd::OverwriteCallbacks { if (m_stopped) return false; - int ret = MsgBox(QObject::tr("Warning: file %1 already exists.").arg(toQString(fp)), QObject::tr("Continue Exporting"), QObject::tr("Continue to All"), QObject::tr("Stop Exporting"), 1); + int ret = DVGui::MsgBox(QObject::tr("Warning: file %1 already exists.").arg(toQString(fp)), QObject::tr("Continue Exporting"), QObject::tr("Continue to All"), QObject::tr("Stop Exporting"), 1); m_yesToAll = (ret == 2); m_stopped = (ret == 0) || (ret == 3); @@ -84,7 +84,7 @@ struct MultiExportOverwriteCB : public IoCmd::OverwriteCallbacks { struct MultiExportProgressCB : public IoCmd::ProgressCallbacks { QString m_processedName; - ProgressDialog m_pb; + DVGui::ProgressDialog m_pb; public: MultiExportProgressCB() : m_pb("", QObject::tr("Cancel"), 0, 0) { m_pb.show(); } @@ -235,7 +235,7 @@ ExportLevelPopup::ExportLevelPopup() QLabel *formatLabel = new QLabel(tr("Format:")); m_format = new QComboBox(this); // Retas compliant checkbox - m_retas = new CheckBox(tr("Retas Compliant")); + m_retas = new DVGui::CheckBox(tr("Retas Compliant")); // Format options button m_formatOptions = new QPushButton(tr("Options")); //----- @@ -260,8 +260,8 @@ ExportLevelPopup::ExportLevelPopup() m_levelFrameIndexHandle.setFrame(0); // Due to TFrameHandle's initialization, the initial frame frameNavigator->setFrameHandle(&m_levelFrameIndexHandle); // is -1. Don't ask me why. Patching to 0. - formatLabel->setFixedHeight(WidgetHeight); - m_format->setFixedHeight(WidgetHeight); + formatLabel->setFixedHeight(DVGui::WidgetHeight); + m_format->setFixedHeight(DVGui::WidgetHeight); m_format->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); QStringList formats; @@ -273,7 +273,7 @@ ExportLevelPopup::ExportLevelPopup() formats.sort(); m_format->addItems(formats); - m_retas->setMinimumHeight(WidgetHeight); + m_retas->setMinimumHeight(DVGui::WidgetHeight); m_formatOptions->setMinimumSize(60, 25); //layout @@ -647,7 +647,7 @@ bool ExportLevelPopup::execute() return ret; } else { if (!isValidFileName(QString::fromStdString(fp.getName()))) { - MsgBox(CRITICAL, tr("The file name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); + DVGui::error(tr("The file name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); return false; } diff --git a/toonz/sources/toonz/exportpanel.cpp b/toonz/sources/toonz/exportpanel.cpp index c145908..670e8b6 100644 --- a/toonz/sources/toonz/exportpanel.cpp +++ b/toonz/sources/toonz/exportpanel.cpp @@ -246,12 +246,12 @@ void RenderController::generateMovie(TFilePath outPath, bool emitSignal) else msg = QObject::tr("There were problems loading the scene %1.\n Some files may be missing.").arg(QString::fromStdWString(fp.getWideString())); - MsgBox(WARNING, msg); + DVGui::warning(msg); return; } catch (...) { QString msg = QObject::tr("There were problems loading the scene %1.\n Some files may be missing.").arg(QString::fromStdWString(fp.getWideString())); - MsgBox(WARNING, msg); + DVGui::warning(msg); return; } @@ -292,7 +292,7 @@ void RenderController::generateMovie(TFilePath outPath, bool emitSignal) movieGenerator.addSoundtrack(scene, frameOffset, sceneFrames); } catch (const TException&) { QString text = tr("The %1 scene contains an audio file with different characteristics from the one used in the first exported scene.\nThe audio file will not be included in the rendered clip.").arg(QString::fromStdWString(fp.getLevelNameW())); - DVGui::MsgBox(DVGui::WARNING, text); + DVGui::warning(text); } } @@ -315,7 +315,7 @@ void RenderController::generateMovie(TFilePath outPath, bool emitSignal) if (!TSystem::showDocument(outPath)) { QString msg(QObject::tr("It is not possible to display the file %1: no player associated with its format").arg(QString::fromStdWString(outPath.withoutParentDir().getWideString()))); - MsgBox(WARNING, msg); + DVGui::warning(msg); } } else { int r0 = 1, r1 = totalFrameCount, step = 1; diff --git a/toonz/sources/toonz/exportscenepopup.cpp b/toonz/sources/toonz/exportscenepopup.cpp index f241e49..936b981 100644 --- a/toonz/sources/toonz/exportscenepopup.cpp +++ b/toonz/sources/toonz/exportscenepopup.cpp @@ -43,16 +43,16 @@ TFilePath importScene(TFilePath scenePath) try { ret = IoCmd::loadScene(scene, scenePath, true); } catch (TException &e) { - MsgBox(CRITICAL, QObject::tr("Error loading scene %1 :%2").arg(toQString(scenePath)).arg(QString::fromStdWString(e.getMessage()))); + DVGui::error(QObject::tr("Error loading scene %1 :%2").arg(toQString(scenePath)).arg(QString::fromStdWString(e.getMessage()))); return TFilePath(); } catch (...) { - MsgBox(CRITICAL, QObject::tr("Error loading scene %1").arg(toQString(scenePath))); + DVGui::error(QObject::tr("Error loading scene %1").arg(toQString(scenePath))); return TFilePath(); } if (!ret) { - MsgBox(CRITICAL, QObject::tr("It is not possible to export the scene %1 because it does not belong to any project.").arg(toQString(scenePath))); + DVGui::error(QObject::tr("It is not possible to export the scene %1 because it does not belong to any project.").arg(toQString(scenePath))); return TFilePath(); } @@ -613,7 +613,7 @@ void ExportScenePopup::onExport() DvDirModelFileFolderNode *node = (DvDirModelFileFolderNode *)m_projectTreeView->getCurrentNode(); if (!node || !pm->isProject(node->getPath())) { QApplication::restoreOverrideCursor(); - MsgBox(WARNING, tr("The folder you selected is not a project.")); + DVGui::warning(tr("The folder you selected is not a project.")); return; } projectPath = pm->projectFolderToProjectPath(node->getPath()); @@ -639,7 +639,7 @@ void ExportScenePopup::onExport() pm->setCurrentProjectPath(oldProjectPath); if (newScenes.empty()) { QApplication::restoreOverrideCursor(); - MsgBox(WARNING, tr("There was an error exporting the scene.")); + DVGui::warning(tr("There was an error exporting the scene.")); return; } for (i = 0; i < newScenes.size(); i++) @@ -656,17 +656,17 @@ TFilePath ExportScenePopup::createNewProject() TProjectManager *pm = TProjectManager::instance(); TFilePath projectName(m_newProjectName->text().toStdWString()); if (projectName == TFilePath()) { - MsgBox(WARNING, tr("The project name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); + DVGui::warning(tr("The project name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); return TFilePath(); } if (projectName.isAbsolute()) { // bad project name - MsgBox(WARNING, tr("The project name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); + DVGui::warning(tr("The project name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); return TFilePath(); } if (pm->getProjectPathByName(projectName) != TFilePath()) { // project already exists - MsgBox(WARNING, tr("The project name you specified is already used.")); + DVGui::warning(tr("The project name you specified is already used.")); return TFilePath(); } diff --git a/toonz/sources/toonz/exportscenepopup.h b/toonz/sources/toonz/exportscenepopup.h index 82f179f..9751eb4 100644 --- a/toonz/sources/toonz/exportscenepopup.h +++ b/toonz/sources/toonz/exportscenepopup.h @@ -16,8 +16,6 @@ class QLabel; class ExportSceneTreeView; class QRadioButton; -using namespace DVGui; - //============================================================================= // ExportSceneDvDirModelFileFolderNode @@ -142,7 +140,7 @@ signals: //============================================================================= // ExportScenePopup -class ExportScenePopup : public Dialog +class ExportScenePopup : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/filebrowser.cpp b/toonz/sources/toonz/filebrowser.cpp index ff15d79..49276ed 100644 --- a/toonz/sources/toonz/filebrowser.cpp +++ b/toonz/sources/toonz/filebrowser.cpp @@ -1012,14 +1012,14 @@ bool FileBrowser::renameFile(TFilePath &fp, QString newName) TFilePath newFp(newName.toStdWString()); if (newFp.getType() != "" && newFp.getType() != fp.getType()) { - MsgBox(CRITICAL, tr("Can't change file extension")); + DVGui::error(tr("Can't change file extension")); return false; } if (newFp.getType() == "") newFp = newFp.withType(fp.getType()); if (newFp.getFrame() != TFrameId::EMPTY_FRAME && newFp.getFrame() != TFrameId::NO_FRAME) { - MsgBox(CRITICAL, tr("Can't set a drawing number")); + DVGui::error(tr("Can't set a drawing number")); return false; } if (newFp.getDots() != fp.getDots()) { @@ -1035,7 +1035,7 @@ bool FileBrowser::renameFile(TFilePath &fp, QString newName) return false; if (TSystem::doesExistFileOrLevel(newFp)) { - MsgBox(CRITICAL, tr("Can't rename. File already exists: ") + toQString(newFp)); + DVGui::error(tr("Can't rename. File already exists: ") + toQString(newFp)); return false; } @@ -1057,7 +1057,7 @@ bool FileBrowser::renameFile(TFilePath &fp, QString newName) } } catch (...) { - MsgBox(CRITICAL, tr("Couldn't rename ") + toQString(fp) + " to " + toQString(newFp)); + DVGui::error(tr("Couldn't rename ") + toQString(fp) + " to " + toQString(newFp)); return false; } @@ -1091,7 +1091,7 @@ QMenu *FileBrowser::getContextMenu(QWidget *parent, int index) menu->addAction(cm->getAction(MI_LoadScene)); } -#ifdef WIN32 +#ifdef _WIN32 else if (files.size() == 1 && files[0].getType() == "scr") { QAction *action; action = new QAction(tr("Preview Screensaver"), menu); @@ -1496,7 +1496,7 @@ bool FileBrowser::drop(const QMimeData *mimeData) folderPath += TFilePath(levelName + toWideString(sl->getPath().getDottedType())); if (TSystem::doesExistFileOrLevel(folderPath)) { QString question = "Level " + toQString(folderPath) + " already exists\nDo you want to duplicate it?"; - int ret = MsgBox(question, QObject::tr("Duplicate"), QObject::tr("Don't Duplicate"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Duplicate"), QObject::tr("Don't Duplicate"), 0); if (ret == 2 || ret == 0) return false; TFilePath path = folderPath; @@ -1529,7 +1529,7 @@ bool FileBrowser::drop(const QMimeData *mimeData) TFilePath dstFp = srcFp.withParentDir(folderPath); if (dstFp != srcFp) { if (!TSystem::copyFileOrLevel(dstFp, srcFp)) - MsgBox(CRITICAL, tr("There was an error copying %1 to %2").arg(toQString(srcFp)).arg(toQString(dstFp))); + DVGui::error(tr("There was an error copying %1 to %2").arg(toQString(srcFp)).arg(toQString(dstFp))); } } refreshFolder(folderPath); @@ -1563,7 +1563,7 @@ void FileBrowser::loadResources() void RenameAsToonzPopup::onOk() { if (!isValidFileName(m_name->text())) { - MsgBox(CRITICAL, tr("The file name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); + DVGui::error(tr("The file name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); return; } accept(); @@ -1730,7 +1730,7 @@ void renameSingleFileOrToonzLevel(const QString &fullpath) string name = popup.getName().toStdString(); if (name == fpin.getName()) { - MsgBox(CRITICAL, QString(QObject::tr("The specified name is already assigned to the %1 file.").arg(fullpath))); + DVGui::error(QString(QObject::tr("The specified name is already assigned to the %1 file.").arg(fullpath))); return; } @@ -1772,7 +1772,7 @@ void doRenameAsToonzLevel(const QString &fullpath) TFilePath levelOut(levelOutStr.toStdWString()); if (TSystem::doesExistFileOrLevel(levelOut)) { QApplication::restoreOverrideCursor(); - int ret = MsgBox(QObject::tr("Warning: level %1 already exists; overwrite?").arg(toQString(levelOut)), QObject::tr("Yes"), QObject::tr("No"), 1); + int ret = DVGui::MsgBox(QObject::tr("Warning: level %1 already exists; overwrite?").arg(toQString(levelOut)), QObject::tr("Yes"), QObject::tr("No"), 1); QApplication::setOverrideCursor(Qt::WaitCursor); if (ret == 2 || ret == 0) return; @@ -1789,12 +1789,12 @@ void doRenameAsToonzLevel(const QString &fullpath) if (popup.doOverwrite()) { if (!QFile::rename(parentPath + "/" + pathIn[i], pathOut)) { QString tmp(parentPath + "/" + pathIn[i]); - MsgBox(CRITICAL, QString(QObject::tr("It is not possible to rename the %1 file.").arg(tmp))); + DVGui::error(QString(QObject::tr("It is not possible to rename the %1 file.").arg(tmp))); return; } } else if (!QFile::copy(parentPath + "/" + pathIn[i], pathOut)) { QString tmp(parentPath + "/" + pathIn[i]); - MsgBox(CRITICAL, QString(QObject::tr("It is not possible to copy the %1 file.").arg(tmp))); + DVGui::error(QString(QObject::tr("It is not possible to copy the %1 file.").arg(tmp))); return; } @@ -1849,7 +1849,7 @@ void FileBrowser::convertToUnpaintedTlv() if (TSystem::doesExistFileOrLevel(converter->m_levelOut)) { QApplication::restoreOverrideCursor(); - int ret = MsgBox(tr("Warning: level %1 already exists; overwrite?").arg(toQString(converter->m_levelOut)), tr("Yes"), tr("No"), 1); + int ret = DVGui::MsgBox(tr("Warning: level %1 already exists; overwrite?").arg(toQString(converter->m_levelOut)), tr("Yes"), tr("No"), 1); QApplication::setOverrideCursor(Qt::WaitCursor); if (ret == 2 || ret == 0) { delete converter; @@ -1873,7 +1873,7 @@ void FileBrowser::convertToUnpaintedTlv() string errorMessage; if (!converters[i]->init(errorMessage)) { converters[i]->abort(); - MsgBox(CRITICAL, QString::fromStdString(errorMessage)); + DVGui::error(QString::fromStdString(errorMessage)); delete converters[i]; converters[i] = 0; continue; @@ -1893,7 +1893,7 @@ void FileBrowser::convertToUnpaintedTlv() converters[i] = 0; } if (errorMessage != "") - MsgBox(CRITICAL, QString::fromStdString(errorMessage)); + DVGui::error(QString::fromStdString(errorMessage)); QApplication::restoreOverrideCursor(); FileBrowser::refreshFolder(filePaths[0].getParentDir()); return; @@ -1909,7 +1909,7 @@ void FileBrowser::convertToUnpaintedTlv() QApplication::restoreOverrideCursor(); pb.hide(); - MsgBox(INFORMATION, tr("Done: All Levels converted to TLV Format")); + DVGui::info(tr("Done: All Levels converted to TLV Format")); FileBrowser::refreshFolder(filePaths[0].getParentDir()); } @@ -1941,7 +1941,7 @@ void FileBrowser::convertToPaintedTlv() if (TSystem::doesExistFileOrLevel(converter->m_levelOut)) { QApplication::restoreOverrideCursor(); - int ret = MsgBox(tr("Warning: level %1 already exists; overwrite?").arg(toQString(converter->m_levelOut)), tr("Yes"), tr("No"), 1); + int ret = DVGui::MsgBox(tr("Warning: level %1 already exists; overwrite?").arg(toQString(converter->m_levelOut)), tr("Yes"), tr("No"), 1); QApplication::setOverrideCursor(Qt::WaitCursor); if (ret == 2 || ret == 0) { QApplication::restoreOverrideCursor(); @@ -1954,7 +1954,7 @@ void FileBrowser::convertToPaintedTlv() if (!converter->init(errorMessage)) { converter->abort(); delete converter; - MsgBox(CRITICAL, QString::fromStdString(errorMessage)); + DVGui::error(QString::fromStdString(errorMessage)); QApplication::restoreOverrideCursor(); return; } @@ -1969,7 +1969,7 @@ void FileBrowser::convertToPaintedTlv() converter->abort(); delete converter; if (errorMessage != "") - MsgBox(CRITICAL, QString::fromStdString(errorMessage)); + DVGui::error(QString::fromStdString(errorMessage)); QApplication::restoreOverrideCursor(); FileBrowser::refreshFolder(filePaths[0].getParentDir()); return; @@ -1984,7 +1984,7 @@ void FileBrowser::convertToPaintedTlv() QApplication::restoreOverrideCursor(); pb.hide(); - MsgBox(INFORMATION, tr("Done: 2 Levels converted to TLV Format")); + DVGui::info(tr("Done: 2 Levels converted to TLV Format")); fs->selectNone(); FileBrowser::refreshFolder(filePaths[0].getParentDir()); @@ -2125,7 +2125,7 @@ void FileBrowser::newFolder() TSystem::mkDir(folderPath); } catch (...) { - MsgBox(CRITICAL, tr("It is not possible to create the %1 folder.").arg(toQString(folderPath))); + DVGui::error(tr("It is not possible to create the %1 folder.").arg(toQString(folderPath))); return; } diff --git a/toonz/sources/toonz/filebrowser.h b/toonz/sources/toonz/filebrowser.h index 6776211..6888b72 100644 --- a/toonz/sources/toonz/filebrowser.h +++ b/toonz/sources/toonz/filebrowser.h @@ -236,13 +236,11 @@ private: }; //-------------------------------------------------------------------- -using namespace DVGui; - -class RenameAsToonzPopup : public Dialog +class RenameAsToonzPopup : public DVGui::Dialog { Q_OBJECT QPushButton *m_okBtn, *m_cancelBtn; - LineEdit *m_name; + DVGui::LineEdit *m_name; QCheckBox *m_overwrite; public: diff --git a/toonz/sources/toonz/filebrowsermodel.cpp b/toonz/sources/toonz/filebrowsermodel.cpp index 58f32c4..e6daed9 100644 --- a/toonz/sources/toonz/filebrowsermodel.cpp +++ b/toonz/sources/toonz/filebrowsermodel.cpp @@ -16,7 +16,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #endif @@ -32,7 +32,7 @@ namespace { TFilePath getMyDocumentsPath() { -#ifdef WIN32 +#ifdef _WIN32 WCHAR szPath[MAX_PATH]; if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_PERSONAL, 0)) { return TFilePath(szPath); @@ -1101,7 +1101,7 @@ void DvDirModelNetworkNode::refreshChildren() if (!m_children.empty()) clearPointerContainer(m_children); -#ifdef WIN32 +#ifdef _WIN32 // Enumerate network nodes HANDLE enumHandle; @@ -1179,7 +1179,7 @@ void DvDirModelRootNode::refreshChildren() if (m_children.empty()) { addChild(m_myComputerNode = new DvDirModelMyComputerNode(this)); -#ifdef WIN32 +#ifdef _WIN32 addChild(m_networkNode = new DvDirModelNetworkNode(this)); #endif diff --git a/toonz/sources/toonz/filebrowserpopup.cpp b/toonz/sources/toonz/filebrowserpopup.cpp index a883e4f..54e2e33 100644 --- a/toonz/sources/toonz/filebrowserpopup.cpp +++ b/toonz/sources/toonz/filebrowserpopup.cpp @@ -75,7 +75,7 @@ FileBrowserPopup::FileBrowserPopup(const QString &title, Options options, QStrin m_browser = new FileBrowser(this, 0, false, m_multiSelectionEnabled); m_nameFieldLabel = new QLabel(tr("File name:")); - m_nameField = new LineEdit(this); + m_nameField = new DVGui::LineEdit(this); m_okButton = new QPushButton(tr("OK"), this); m_cancelButton = new QPushButton(tr("Cancel"), this); QPushButton *applyButton = 0; @@ -212,7 +212,7 @@ void FileBrowserPopup::onOkPressed() if (!m_nameField->text().isEmpty()) { const QString &str = m_nameField->text(); if (!isValidFileName(QFileInfo(str).baseName()) && !m_isDirectoryOnly) { - error(QObject::tr("A filename cannot be empty or contain any of the following characters:\n \\ / : * ? \" < > |")); + DVGui::error(QObject::tr("A filename cannot be empty or contain any of the following characters:\n \\ / : * ? \" < > |")); return; } @@ -232,7 +232,7 @@ void FileBrowserPopup::onOkPressed() // history // That means, TFilePath() represents if (*pt == TFilePath() || !pt->isAbsolute()) // the History folder? Really? That's lame... { - MsgBox(CRITICAL, tr("Invalid file")); + DVGui::error(tr("Invalid file")); return; } } else { @@ -276,7 +276,7 @@ void FileBrowserPopup::onApplyPressed() if (folder == TFilePath()) { // history if (*it == TFilePath() || !it->isAbsolute()) { - MsgBox(CRITICAL, tr("Invalid file")); + DVGui::error(tr("Invalid file")); return; } } else { @@ -429,7 +429,7 @@ bool GenericSaveFilePopup::execute() if (TFileStatus(path).doesExist()) { const QString &question = QObject::tr("File %1 already exists.\nDo you want to overwrite it?").arg(toQString(path)); - int ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel")); + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel")); if (ret == 0 || ret == 2) return false; } @@ -467,12 +467,12 @@ bool LoadScenePopup::execute() const TFilePath &fp = *m_selectedPaths.begin(); if (fp.getType() != "tnz") { - MsgBox(CRITICAL, toQString(fp) + tr(" is not a scene file.")); + DVGui::error(toQString(fp) + tr(" is not a scene file.")); return false; } if (!TFileStatus(fp).doesExist()) { - MsgBox(CRITICAL, toQString(fp) + tr(" does not exist.")); + DVGui::error(toQString(fp) + tr(" does not exist.")); return false; } @@ -523,12 +523,12 @@ bool LoadSubScenePopup::execute() const TFilePath &fp = *m_selectedPaths.begin(); if (fp.getType() != "tnz") { - MsgBox(CRITICAL, toQString(fp) + tr(" is not a scene file.")); + DVGui::error(toQString(fp) + tr(" is not a scene file.")); return false; } if (!TFileStatus(fp).doesExist()) { - MsgBox(CRITICAL, toQString(fp) + tr(" does not exist.")); + DVGui::error(toQString(fp) + tr(" does not exist.")); return false; } @@ -636,20 +636,20 @@ LoadLevelPopup::LoadLevelPopup() QPushButton *showSubsequenceButton = new QPushButton("", this); QLabel *subsequenceLabel = new QLabel(tr("Load Subsequence Level"), this); m_subsequenceFrame = new QFrame(this); - m_fromFrame = new LineEdit(this); - m_toFrame = new LineEdit(this); + m_fromFrame = new DVGui::LineEdit(this); + m_toFrame = new DVGui::LineEdit(this); //----Arrangement in Xsheet QPushButton *showArrangementButton = new QPushButton("", this); QLabel *arrangementLabel = new QLabel(tr("Arrangement in Xsheet"), this); m_arrangementFrame = new QFrame(this); - m_xFrom = new LineEdit(this); - m_xTo = new LineEdit(this); + m_xFrom = new DVGui::LineEdit(this); + m_xTo = new DVGui::LineEdit(this); m_stepCombo = new QComboBox(this); m_incCombo = new QComboBox(this); - m_levelName = new LineEdit(this); - m_posFrom = new LineEdit(this); - m_posTo = new LineEdit(this); + m_levelName = new DVGui::LineEdit(this); + m_posFrom = new DVGui::LineEdit(this); + m_posTo = new DVGui::LineEdit(this); m_notExistLabel = new QLabel(tr("(FILE DOES NOT EXIST)")); @@ -1375,7 +1375,7 @@ bool SaveLevelAsPopup::execute() doExpose = false; else if (ret && !Preferences::instance()->isReplaceAfterSaveLevelAsEnabled()) { QString question(QObject::tr("Do you want to expose the renamed level ?")); - int val = MsgBox(question, + int val = DVGui::MsgBox(question, QObject::tr("Expose"), //val = 1 QObject::tr("Don't expose"), 0); //val = 2 if (val == 0) @@ -1512,7 +1512,7 @@ void ReplaceLevelPopup::show() TCellSelection *cellSel = dynamic_cast(sel); TColumnSelection *columnSel = dynamic_cast(sel); if ((!cellSel && !columnSel) || sel->isEmpty()) { - MsgBox(CRITICAL, tr("Nothing to replace: no cells selected.")); + DVGui::error(tr("Nothing to replace: no cells selected.")); return; } @@ -1631,7 +1631,7 @@ bool SavePaletteAsPopup::execute() TPalette *palette = paletteHandle->getPalette(); if (!palette) { - MsgBox(WARNING, "No current palette exists"); + DVGui::warning("No current palette exists"); return true; } @@ -1644,7 +1644,7 @@ bool SavePaletteAsPopup::execute() if (TFileStatus(fp).doesExist()) { const QString &question = QObject::tr("The palette %1 already exists.\nDo you want to overwrite it?").arg(toQString(fp)); - int ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return false; } @@ -1684,7 +1684,7 @@ LoadColorModelPopup::LoadColorModelPopup() : FileBrowserPopup(tr("Load Color Model"), Options(), "", new QFrame(0)) { QFrame *optionFrame = (QFrame *)m_customWidget; - m_paletteFrame = new LineEdit("", this); + m_paletteFrame = new DVGui::LineEdit("", this); //layout QHBoxLayout *mainLayout = new QHBoxLayout(); @@ -1762,7 +1762,7 @@ bool LoadColorModelPopup::execute() TPalette *palette = paletteHandle->getPalette(); if (!palette || palette->isCleanupPalette()) { - error(QObject::tr("Cannot load Color Model in current palette.")); + DVGui::error(QObject::tr("Cannot load Color Model in current palette.")); return false; } @@ -1776,7 +1776,7 @@ bool LoadColorModelPopup::execute() QList list; list.append(QObject::tr("Overwrite the destination palette.")); list.append(QObject::tr("Keep the destination palette and apply it to the color model.")); - int ret = RadioButtonMsgBox(DVGui::WARNING, question, list); + int ret = DVGui::RadioButtonMsgBox(DVGui::WARNING, question, list); if (ret == 0) return false; if (ret == 2) @@ -1847,7 +1847,7 @@ void ReplaceParentDirectoryPopup::show() TCellSelection *cellSel = dynamic_cast(sel); TColumnSelection *columnSel = dynamic_cast(sel); if ((!cellSel && !columnSel) || sel->isEmpty()) { - MsgBox(CRITICAL, tr("Nothing to replace: no cells or columns selected.")); + DVGui::error(tr("Nothing to replace: no cells or columns selected.")); return; } if (cellSel) { @@ -1970,7 +1970,7 @@ bool ImportMagpieFilePopup::execute() const TFilePath &fp = *m_selectedPaths.begin(); if (!TSystem::doesExistFileOrLevel(fp)) { - MsgBox(CRITICAL, tr("%1 does not exist.").arg(toQString(fp))); + DVGui::error(tr("%1 does not exist.").arg(toQString(fp))); return false; } @@ -2015,7 +2015,7 @@ bool BrowserPopup::execute() if (!TSystem::doesExistFileOrLevel(fp)) { const QString &msg = tr("Path %1 doesn't exists.").arg(toQString(fp)); - MsgBox(DVGui::INFORMATION, msg); + DVGui::info(msg); return false; } diff --git a/toonz/sources/toonz/filebrowserpopup.h b/toonz/sources/toonz/filebrowserpopup.h index 7153c9f..8c09abf 100644 --- a/toonz/sources/toonz/filebrowserpopup.h +++ b/toonz/sources/toonz/filebrowserpopup.h @@ -89,7 +89,7 @@ protected: FileBrowser *m_browser; QLabel *m_nameFieldLabel; - LineEdit *m_nameField; + DVGui::LineEdit *m_nameField; //QLabel* m_fromFrameLabel; //LineEdit* m_fromFrame; @@ -275,17 +275,17 @@ class LoadLevelPopup : public FileBrowserPopup Q_OBJECT QFrame *m_subsequenceFrame; - LineEdit *m_fromFrame; - LineEdit *m_toFrame; + DVGui::LineEdit *m_fromFrame; + DVGui::LineEdit *m_toFrame; QFrame *m_arrangementFrame; - LineEdit *m_xFrom; - LineEdit *m_xTo; + DVGui::LineEdit *m_xFrom; + DVGui::LineEdit *m_xTo; QComboBox *m_stepCombo; QComboBox *m_incCombo; - LineEdit *m_levelName; - LineEdit *m_posFrom; - LineEdit *m_posTo; + DVGui::LineEdit *m_levelName; + DVGui::LineEdit *m_posFrom; + DVGui::LineEdit *m_posTo; QLabel *m_notExistLabel; QComboBox *m_loadTlvBehaviorComboBox; @@ -384,7 +384,7 @@ class LoadColorModelPopup : public FileBrowserPopup { Q_OBJECT - LineEdit *m_paletteFrame; + DVGui::LineEdit *m_paletteFrame; public: LoadColorModelPopup(); diff --git a/toonz/sources/toonz/filebrowserversioncontrol.cpp b/toonz/sources/toonz/filebrowserversioncontrol.cpp index 27d160c..2e4b4a6 100644 --- a/toonz/sources/toonz/filebrowserversioncontrol.cpp +++ b/toonz/sources/toonz/filebrowserversioncontrol.cpp @@ -181,7 +181,7 @@ void FileBrowser::editVersionControl() } if (hasCurrentSceneFile) { - MsgBox(WARNING, tr("Some files that you want to edit are currently opened. Close them first.")); + DVGui::warning(tr("Some files that you want to edit are currently opened. Close them first.")); return; } @@ -404,7 +404,7 @@ void FileBrowser::unlockVersionControl() } if (hasCurrentSceneFile) { - MsgBox(WARNING, tr("Some files that you want to unlock are currently opened. Close them first.")); + DVGui::warning(tr("Some files that you want to unlock are currently opened. Close them first.")); return; } vc->unlock(this, path, files, sceneIconsCount); diff --git a/toonz/sources/toonz/filedata.cpp b/toonz/sources/toonz/filedata.cpp index f5d79b7..446e63a 100644 --- a/toonz/sources/toonz/filedata.cpp +++ b/toonz/sources/toonz/filedata.cpp @@ -51,7 +51,7 @@ void FileData::getFiles(TFilePath folder, std::vector &newFiles) cons TFilePath path = folder + TFilePath(oldPath.getLevelNameW()); if (!TSystem::doesExistFileOrLevel(oldPath)) { - MsgBox(WARNING, tr("It is not possible to find the %1 level.").arg(QString::fromStdWString(oldPath.getWideString()))); + DVGui::warning(tr("It is not possible to find the %1 level.").arg(QString::fromStdWString(oldPath.getWideString()))); return; } @@ -67,7 +67,7 @@ void FileData::getFiles(TFilePath folder, std::vector &newFiles) cons newFiles.push_back(levelPathOut); else { QString msg = tr("There was an error copying %1").arg(toQString(oldPath)); - MsgBox(CRITICAL, msg); + DVGui::error(msg); return; } } diff --git a/toonz/sources/toonz/fileinfopopup.h b/toonz/sources/toonz/fileinfopopup.h index 115e582..3205728 100644 --- a/toonz/sources/toonz/fileinfopopup.h +++ b/toonz/sources/toonz/fileinfopopup.h @@ -11,13 +11,11 @@ class QPushButton; class QLabel; class TFilePath; -using namespace DVGui; - //============================================================================= // FileInfoPopup //----------------------------------------------------------------------------- -class FileInfoPopup : public Dialog +class FileInfoPopup : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/fileselection.cpp b/toonz/sources/toonz/fileselection.cpp index 68bc730..c4ee83a 100644 --- a/toonz/sources/toonz/fileselection.cpp +++ b/toonz/sources/toonz/fileselection.cpp @@ -289,7 +289,7 @@ void FileSelection::addToBatchRenderList() for (i = 0; i < files.size(); i++) BatchesController::instance()->addComposerTask(files[i]); - MsgBox(INFORMATION, QObject::tr(" Task added to the Batch Render List.")); + DVGui::info(QObject::tr(" Task added to the Batch Render List.")); #endif #endif } @@ -305,7 +305,7 @@ void FileSelection::addToBatchCleanupList() for (i = 0; i < files.size(); i++) BatchesController::instance()->addCleanupTask(files[i]); - MsgBox(INFORMATION, QObject::tr(" Task added to the Batch Cleanup List.")); + DVGui::info(QObject::tr(" Task added to the Batch Cleanup List.")); #endif } @@ -325,7 +325,7 @@ void FileSelection::deleteFiles() } else { question = QObject::tr("Deleting %n files. Are you sure?", "", (int)files.size()); } - int ret = MsgBox(question, QObject::tr("Delete"), QObject::tr("Cancel"), 1); + int ret = DVGui::MsgBox(question, QObject::tr("Delete"), QObject::tr("Cancel"), 1); if (ret == 2 || ret == 0) return; @@ -456,7 +456,7 @@ void FileSelection::convertFiles() static ConvertPopup *popup = new ConvertPopup(false); if (popup->isConverting()) { - DVGui::MsgBox(INFORMATION, QObject::tr("A convertion task is in progress! wait until it stops or cancel it")); + DVGui::info(QObject::tr("A convertion task is in progress! wait until it stops or cancel it")); return; } popup->setFiles(files); @@ -468,7 +468,7 @@ void FileSelection::convertFiles() void FileSelection::premultiplyFiles() { QString question = QObject::tr("You are going to premultiply selected files.\nThe operation cannot be undone: are you sure?"); - int ret = MsgBox(question, QObject::tr("Premultiply"), QObject::tr("Cancel"), 1); + int ret = DVGui::MsgBox(question, QObject::tr("Premultiply"), QObject::tr("Cancel"), 1); if (ret == 2 || ret == 0) return; @@ -545,11 +545,11 @@ void FileSelection::collectAssets() collectedAssets = ::collectAssets(files[0]); } if (collectedAssets == 0) - DVGui::MsgBox(INFORMATION, QObject::tr("There are no assets to collect")); + DVGui::info(QObject::tr("There are no assets to collect")); else if (collectedAssets == 1) - DVGui::MsgBox(INFORMATION, QObject::tr("One asset imported")); + DVGui::info(QObject::tr("One asset imported")); else - DVGui::MsgBox(INFORMATION, QObject::tr("%1 assets imported").arg(collectedAssets)); + DVGui::info(QObject::tr("%1 assets imported").arg(collectedAssets)); DvDirModel::instance()->refreshFolder(TProjectManager::instance()->getCurrentProjectPath().getParentDir()); } @@ -562,18 +562,18 @@ int importScene(TFilePath scenePath) try { IoCmd::loadScene(scene, scenePath, true); } catch (TException &e) { - MsgBox(CRITICAL, QObject::tr("Error loading scene %1 :%2").arg(toQString(scenePath)).arg(QString::fromStdWString(e.getMessage()))); + DVGui::error(QObject::tr("Error loading scene %1 :%2").arg(toQString(scenePath)).arg(QString::fromStdWString(e.getMessage()))); return 0; } catch (...) { // TNotifier::instance()->notify(TGlobalChange(true)); - MsgBox(CRITICAL, QObject::tr("Error loading scene %1").arg(toQString(scenePath))); + DVGui::error(QObject::tr("Error loading scene %1").arg(toQString(scenePath))); return 0; } try { scene.save(scene.getScenePath()); } catch (TException&) { - MsgBox(CRITICAL, QObject::tr("There was an error saving the %1 scene.").arg(toQString(scenePath))); + DVGui::error(QObject::tr("There was an error saving the %1 scene.").arg(toQString(scenePath))); return 0; } @@ -618,11 +618,11 @@ void FileSelection::importScenes() importedSceneCount += ret; } if (importedSceneCount == 0) - DVGui::MsgBox(INFORMATION, QObject::tr("No scene imported")); + DVGui::info(QObject::tr("No scene imported")); else if (importedSceneCount == 1) - DVGui::MsgBox(INFORMATION, QObject::tr("One scene imported")); + DVGui::info(QObject::tr("One scene imported")); else - DVGui::MsgBox(INFORMATION, QString::number(importedSceneCount) + QObject::tr("%1 scenes imported").arg(importedSceneCount)); + DVGui::info(QString::number(importedSceneCount) + QObject::tr("%1 scenes imported").arg(importedSceneCount)); #endif } //------------------------------------------------------------------------ diff --git a/toonz/sources/toonz/filmstrip.h b/toonz/sources/toonz/filmstrip.h index 4531316..55be730 100644 --- a/toonz/sources/toonz/filmstrip.h +++ b/toonz/sources/toonz/filmstrip.h @@ -24,8 +24,6 @@ class QComboBox; class InbetweenDialog; class TXshLevel; -using namespace DVGui; - const int fs_leftMargin = 2; const int fs_rightMargin = 3; const int fs_frameSpacing = 6; @@ -237,7 +235,7 @@ private: // inbetweenDialog //----------------------------------------------------------------------------- -class InbetweenDialog : public Dialog +class InbetweenDialog : public DVGui::Dialog { Q_OBJECT QComboBox *m_comboBox; diff --git a/toonz/sources/toonz/filmstripselection.cpp b/toonz/sources/toonz/filmstripselection.cpp index 90ba76c..b9f9edf 100644 --- a/toonz/sources/toonz/filmstripselection.cpp +++ b/toonz/sources/toonz/filmstripselection.cpp @@ -398,7 +398,7 @@ void TFilmstripSelection::renumberFrames() int startFrame = 0, stepFrame = 0; popup.getValues(startFrame, stepFrame); if (startFrame < 1 || stepFrame < 1) { - error(("Bad renumber values")); + DVGui::error(("Bad renumber values")); return; } FilmstripCmd::renumber(sl, m_selectedFrames, startFrame, stepFrame); diff --git a/toonz/sources/toonz/flipbook.cpp b/toonz/sources/toonz/flipbook.cpp index caa980c..0c9c5ec 100644 --- a/toonz/sources/toonz/flipbook.cpp +++ b/toonz/sources/toonz/flipbook.cpp @@ -93,7 +93,7 @@ #include // for uintptr_t -#ifdef WIN32 +#ifdef _WIN32 #include "avicodecrestrictions.h" #endif; @@ -292,7 +292,7 @@ enum { eBegin, eIncrement, eEnd }; -static ProgressDialog *Pd = 0; +static DVGui::ProgressDialog *Pd = 0; class ProgressBarMessager : public TThread::Message { @@ -306,7 +306,7 @@ public: switch (m_choice) { case eBegin: if (!Pd) - Pd = new ProgressDialog(QObject::tr("Saving previewed frames...."), QObject::tr("Cancel"), 0, m_val); + Pd = new DVGui::ProgressDialog(QObject::tr("Saving previewed frames...."), QObject::tr("Cancel"), 0, m_val); else Pd->setMaximum(m_val); Pd->show(); @@ -321,7 +321,7 @@ public: } break; case eEnd: { - MsgBox(DVGui::INFORMATION, m_str); + DVGui::info(m_str); delete Pd; Pd = 0; } break; @@ -346,10 +346,10 @@ LoadImagesPopup::LoadImagesPopup(FlipBook *flip) frameRangeFrame->setFrameStyle(QFrame::StyledPanel); //frameRangeFrame->setFixedHeight(30); - m_fromField = new LineEdit(this); - m_toField = new LineEdit(this); - m_stepField = new LineEdit("1", this); - m_shrinkField = new LineEdit("1", this); + m_fromField = new DVGui::LineEdit(this); + m_toField = new DVGui::LineEdit(this); + m_stepField = new DVGui::LineEdit("1", this); + m_shrinkField = new DVGui::LineEdit("1", this); //Define the append/load filter types m_appendFilterTypes @@ -365,7 +365,7 @@ LoadImagesPopup::LoadImagesPopup(FlipBook *flip) << "rgb" << "nol"; -#ifdef WIN32 +#ifdef _WIN32 m_appendFilterTypes << "avi"; #endif @@ -604,19 +604,19 @@ bool FlipBook::doSaveImages(TFilePath fp) // Open a notice that the previewFx is rendered in 8bpc regardless of the output settings. if (m_isPreviewFx && outputSettings->getRenderSettings().m_bpp == 64) { QString question = "Save previewed images :\nImages will be saved in 8 bit per channel with this command.\nDo you want to save images?"; - int ret = MsgBox(question, QObject::tr("Save"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Save"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return false; } -#ifdef WIN32 +#ifdef _WIN32 if (ext == "avi") { TPropertyGroup *props = outputSettings->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); - MsgBox(WARNING, msg); + DVGui::warning(msg); return false; } } @@ -627,12 +627,12 @@ bool FlipBook::doSaveImages(TFilePath fp) fp = fp.withType(ext); } if (fp.getName() == "") { - MsgBox(WARNING, tr("The file name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); + DVGui::warning(tr("The file name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); return false; } if (!formats.contains(QString::fromStdString(ext))) { - MsgBox(WARNING, tr("It is not possible to save because the selected file format is not supported.")); + DVGui::warning(tr("It is not possible to save because the selected file format is not supported.")); return false; } @@ -640,7 +640,7 @@ bool FlipBook::doSaveImages(TFilePath fp) m_flipConsole->getFrameRange(from, to, step); if (m_currentFrameToSave != 0) { - info("Already saving!"); + DVGui::info("Already saving!"); return true; } @@ -655,17 +655,17 @@ bool FlipBook::doSaveImages(TFilePath fp) TSystem::mkDir(parent); DvDirModel::instance()->refreshFolder(parent.getParentDir()); } catch (TException &e) { - error("Cannot create " + toQString(fp.getParentDir()) + " : " + QString(toString(e.getMessage()).c_str())); + DVGui::error("Cannot create " + toQString(fp.getParentDir()) + " : " + QString(toString(e.getMessage()).c_str())); return false; } catch (...) { - error("Cannot create " + toQString(fp.getParentDir())); + DVGui::error("Cannot create " + toQString(fp.getParentDir())); return false; } } if (TSystem::doesExistFileOrLevel(fp)) { QString question(tr("File %1 already exists.\nDo you want to overwrite it?").arg(toQString(fp))); - int ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel")); + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel")); if (ret == 2) return false; } @@ -673,7 +673,7 @@ bool FlipBook::doSaveImages(TFilePath fp) try { m_lw = TLevelWriterP(fp, outputSettings->getFileFormatProperties(fp.getType())); } catch (...) { - error("It is not possible to save Flipbook content."); + DVGui::error("It is not possible to save Flipbook content."); return false; } @@ -758,10 +758,10 @@ void FlipBook::onButtonPressed(FlipConsole::EGadget button) TImageP img = getCurrentImage(m_flipConsole->getCurrentFrame()); m_loadbox = loadbox; if (!img) { - MsgBox(WARNING, tr("There are no rendered images to save.")); + DVGui::warning(tr("There are no rendered images to save.")); return; } else if ((TVectorImageP)img) { - MsgBox(WARNING, tr("It is not possible to take or compare snapshots for Toonz vector levels.")); + DVGui::warning(tr("It is not possible to take or compare snapshots for Toonz vector levels.")); return; } TRasterImageP ri(img); @@ -775,7 +775,7 @@ void FlipBook::onButtonPressed(FlipConsole::EGadget button) } CASE FlipConsole::eCompare : if ((TVectorImageP)getCurrentImage(m_flipConsole->getCurrentFrame())) { - MsgBox(WARNING, tr("It is not possible to take or compare snapshots for Toonz vector levels.")); + DVGui::warning(tr("It is not possible to take or compare snapshots for Toonz vector levels.")); m_flipConsole->setChecked(FlipConsole::eCompare, false); return; } @@ -2194,7 +2194,7 @@ void viewFile(const TFilePath &path, int from, int to, int step, int shrink, path.getType() == "avi" || path.getType() == "3gp") && path.isLevelName()) { - MsgBox(WARNING, QObject::tr("%1 has an invalid extension format.") + DVGui::warning(QObject::tr("%1 has an invalid extension format.") .arg(QString::fromStdString(path.getLevelName()))); return; } diff --git a/toonz/sources/toonz/flipbook.h b/toonz/sources/toonz/flipbook.h index 5b59b90..642368b 100644 --- a/toonz/sources/toonz/flipbook.h +++ b/toonz/sources/toonz/flipbook.h @@ -41,10 +41,10 @@ class LoadImagesPopup : public FileBrowserPopup { Q_OBJECT - LineEdit *m_fromField; - LineEdit *m_toField; - LineEdit *m_stepField; - LineEdit *m_shrinkField; + DVGui::LineEdit *m_fromField; + DVGui::LineEdit *m_toField; + DVGui::LineEdit *m_stepField; + DVGui::LineEdit *m_shrinkField; int m_minFrame, m_maxFrame; int m_from, m_to, m_step, m_shrink; diff --git a/toonz/sources/toonz/formatsettingspopups.cpp b/toonz/sources/toonz/formatsettingspopups.cpp index aa0aa18..99d1ead 100644 --- a/toonz/sources/toonz/formatsettingspopups.cpp +++ b/toonz/sources/toonz/formatsettingspopups.cpp @@ -13,7 +13,7 @@ #include "toonz/tcamera.h" #include "toutputproperties.h" -#ifdef WIN32 +#ifdef _WIN32 #include "avicodecrestrictions.h" #endif; @@ -37,7 +37,7 @@ FormatSettingsPopup::FormatSettingsPopup( QWidget *parent, const std::string &format, TPropertyGroup *props) : Dialog(parent), m_format(format), m_props(props), m_levelPath(TFilePath()) -#ifdef WIN32 +#ifdef _WIN32 , m_codecRestriction(0), m_codecComboBox(0), m_configureCodec(0) #endif @@ -67,14 +67,14 @@ FormatSettingsPopup::FormatSettingsPopup( assert(false); } -#ifdef WIN32 +#ifdef _WIN32 if (format == "avi") { m_codecRestriction = new QLabel(this); m_codecRestriction->setMinimumHeight(70); m_codecRestriction->setStyleSheet("border: 1px solid rgb(200,200,200);"); m_mainLayout->addWidget(m_codecRestriction, m_mainLayout->rowCount(), 0, 1, 2); m_configureCodec = new QPushButton("Configure Codec", this); - m_configureCodec->setFixedSize(100, WidgetHeight); + m_configureCodec->setFixedSize(100, DVGui::WidgetHeight); m_mainLayout->addWidget(m_configureCodec, m_mainLayout->rowCount(), 0, 1, 2); connect(m_configureCodec, SIGNAL(released()), this, SLOT(onAviCodecConfigure())); } @@ -105,7 +105,7 @@ void FormatSettingsPopup::buildPropertyComboBox(int index, TPropertyGroup *props TEnumProperty *prop = (TEnumProperty *)(props->getProperty(index)); assert(prop); - PropertyComboBox *comboBox = new PropertyComboBox(this, prop); + DVGui::PropertyComboBox *comboBox = new DVGui::PropertyComboBox(this, prop); m_widgets[prop->getName()] = comboBox; connect(comboBox, SIGNAL(currentIndexChanged(const QString)), this, SLOT(onComboBoxIndexChanged(const QString))); TEnumProperty::Range range = prop->getRange(); @@ -131,7 +131,7 @@ void FormatSettingsPopup::buildPropertyComboBox(int index, TPropertyGroup *props m_mainLayout->addWidget(new QLabel(tr(prop->getName().c_str()) + ":", this), row, 0, Qt::AlignRight | Qt::AlignVCenter); m_mainLayout->addWidget(comboBox, row, 1); -#ifdef WIN32 +#ifdef _WIN32 if (m_format == "avi") m_codecComboBox = comboBox; #endif; @@ -144,7 +144,7 @@ void FormatSettingsPopup::buildValueField(int index, TPropertyGroup *props) TIntProperty *prop = (TIntProperty *)(props->getProperty(index)); assert(prop); - PropertyIntField *v = new PropertyIntField(this, prop); + DVGui::PropertyIntField *v = new DVGui::PropertyIntField(this, prop); m_widgets[prop->getName()] = v; int row = m_mainLayout->rowCount(); @@ -161,7 +161,7 @@ void FormatSettingsPopup::buildPropertyCheckBox(int index, TPropertyGroup *props TBoolProperty *prop = (TBoolProperty *)(props->getProperty(index)); assert(prop); - PropertyCheckBox *v = new PropertyCheckBox(tr(prop->getName().c_str()), this, prop); + DVGui::PropertyCheckBox *v = new DVGui::PropertyCheckBox(tr(prop->getName().c_str()), this, prop); m_widgets[prop->getName()] = v; m_mainLayout->addWidget(v, m_mainLayout->rowCount(), 1); @@ -176,7 +176,7 @@ void FormatSettingsPopup::buildPropertyLineEdit(int index, TPropertyGroup *props TStringProperty *prop = (TStringProperty *)(props->getProperty(index)); assert(prop); - PropertyLineEdit *lineEdit = new PropertyLineEdit(this, prop); + DVGui::PropertyLineEdit *lineEdit = new DVGui::PropertyLineEdit(this, prop); m_widgets[prop->getName()] = lineEdit; lineEdit->setText(tr(toString(prop->getValue()).c_str())); @@ -187,7 +187,7 @@ void FormatSettingsPopup::buildPropertyLineEdit(int index, TPropertyGroup *props //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 void FormatSettingsPopup::onComboBoxIndexChanged(const QString codecName) { @@ -214,7 +214,7 @@ void FormatSettingsPopup::onAviCodecConfigure() void FormatSettingsPopup::showEvent(QShowEvent *se) { -#ifdef WIN32 +#ifdef _WIN32 if (m_format == "avi") { assert(m_codecComboBox); m_codecComboBox->blockSignals(true); diff --git a/toonz/sources/toonz/formatsettingspopups.h b/toonz/sources/toonz/formatsettingspopups.h index a1a63fb..ce9c512 100644 --- a/toonz/sources/toonz/formatsettingspopups.h +++ b/toonz/sources/toonz/formatsettingspopups.h @@ -46,15 +46,15 @@ private: TPropertyGroup *m_props; TFilePath m_levelPath; - QMap m_widgets; //!< Property name -> PropertyWidget + QMap m_widgets; //!< Property name -> PropertyWidget QGridLayout *m_mainLayout; -#ifdef WIN32 +#ifdef _WIN32 // AVI codec - related members QLabel *m_codecRestriction; - PropertyComboBox *m_codecComboBox; + DVGui::PropertyComboBox *m_codecComboBox; QPushButton *m_configureCodec; #endif @@ -66,7 +66,7 @@ private: void buildPropertyLineEdit(int index, TPropertyGroup *props); void showEvent(QShowEvent *se); -#ifdef WIN32 +#ifdef _WIN32 private slots: diff --git a/toonz/sources/toonz/fxparameditorpopup.h b/toonz/sources/toonz/fxparameditorpopup.h index f4eb7a8..9af35c0 100644 --- a/toonz/sources/toonz/fxparameditorpopup.h +++ b/toonz/sources/toonz/fxparameditorpopup.h @@ -5,8 +5,6 @@ #include "toonzqt/dvdialog.h" -using namespace DVGui; - //============================================================================= // FxParamEditorPopup //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/histogrampopup.h b/toonz/sources/toonz/histogrampopup.h index 7e6235e..9486952 100644 --- a/toonz/sources/toonz/histogrampopup.h +++ b/toonz/sources/toonz/histogrampopup.h @@ -7,8 +7,6 @@ #include "timage.h" #include "tpixel.h" -using namespace DVGui; - class ComboHistogram; //============================================================================= diff --git a/toonz/sources/toonz/imageviewer.cpp b/toonz/sources/toonz/imageviewer.cpp index f3dc6c6..cde3e29 100644 --- a/toonz/sources/toonz/imageviewer.cpp +++ b/toonz/sources/toonz/imageviewer.cpp @@ -291,7 +291,7 @@ void ImageViewer::contextMenuEvent(QContextMenuEvent *event) fit->setShortcut(QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomFit))); connect(fit, SIGNAL(triggered()), SLOT(fitView())); -#ifdef WIN32 +#ifdef _WIN32 if (ImageUtils::FullScreenWidget *fsWidget = dynamic_cast(parentWidget())) { diff --git a/toonz/sources/toonz/insertfxpopup.cpp b/toonz/sources/toonz/insertfxpopup.cpp index 104d244..9ae2b44 100644 --- a/toonz/sources/toonz/insertfxpopup.cpp +++ b/toonz/sources/toonz/insertfxpopup.cpp @@ -543,7 +543,7 @@ void InsertFxPopup::removePreset() TFilePath path = TFilePath(itemRole.toStdWString()); QString question = QString(tr("Are you sure you want to delete %1?").arg(path.getName().c_str())); - int ret = MsgBox(question, tr("Yes"), tr("No"), 1); + int ret = DVGui::MsgBox(question, tr("Yes"), tr("No"), 1); if (ret == 2 || ret == 0) return; diff --git a/toonz/sources/toonz/insertfxpopup.h b/toonz/sources/toonz/insertfxpopup.h index fe79d69..dda1503 100644 --- a/toonz/sources/toonz/insertfxpopup.h +++ b/toonz/sources/toonz/insertfxpopup.h @@ -14,14 +14,11 @@ class TFx; #include -using namespace DVGui; -using namespace std; - //============================================================================= // InsertFxPopup //----------------------------------------------------------------------------- -class InsertFxPopup : public Dialog +class InsertFxPopup : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index 8ab77b4..eade44a 100644 --- a/toonz/sources/toonz/iocommand.cpp +++ b/toonz/sources/toonz/iocommand.cpp @@ -1228,7 +1228,7 @@ bool IoCmd::saveSceneIfNeeded(QString msg) question = QObject::tr("%1: the current scene has been modified.\n" "Do you want to save your changes?") .arg(msg); - int ret = MsgBox(question, QObject::tr("Save"), QObject::tr("Discard"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Save"), QObject::tr("Discard"), QObject::tr("Cancel"), 0); if (ret == 0 || ret == 3) { // cancel (or closed message box window) return false; @@ -1261,7 +1261,7 @@ bool IoCmd::saveSceneIfNeeded(QString msg) } question += QObject::tr("\nAre you sure to ") + msg + QObject::tr(" anyway ?"); - int ret = MsgBox(question, QObject::tr("OK"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("OK"), QObject::tr("Cancel"), 0); if (ret == 0 || ret == 2) { // cancel (or closed message box window) return false; @@ -1275,7 +1275,7 @@ bool IoCmd::saveSceneIfNeeded(QString msg) //--- If both the level and scene is clean, then open the quit confirmation dialog if (!isLevelOrSceneIsDirty && msg == "Quit") { QString question("Are you sure ?"); - int ret = MsgBox(question, QObject::tr("OK"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("OK"), QObject::tr("Cancel"), 0); if (ret == 0 || ret == 2) { // cancel (or closed message box window) return false; @@ -1415,7 +1415,7 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) QString question; question = QObject::tr("The scene %1 already exists.\nDo you want to overwrite it?").arg(QString::fromStdString(scenePath.getName())); - int ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return false; } @@ -1448,9 +1448,9 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) scene->save(scenePath, xsheet); TApp::instance()->getPaletteController()->getCurrentLevelPalette()->notifyPaletteChanged(); //non toglieva l'asterisco alla paletta...forse non va qua? vinz } catch (const TSystemException &se) { - MsgBox(WARNING, QString::fromStdWString(se.getMessage())); + DVGui::warning(QString::fromStdWString(se.getMessage())); } catch (...) { - MsgBox(CRITICAL, QObject::tr("Couldn't save %1").arg(toQString(scenePath))); + DVGui::error(QObject::tr("Couldn't save %1").arg(toQString(scenePath))); } cp->assign(&oldCP); @@ -1589,7 +1589,7 @@ bool IoCmd::saveLevel(const TFilePath &fp, TXshSimpleLevel *sl, bool overwrite) if (!overwrite && fileDoesExist) { QString question; question = QObject::tr("The level %1 already exists.\nDo you want to overwrite it?").arg(toQString(fp)); - int ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return false; } @@ -1608,7 +1608,7 @@ bool IoCmd::saveLevel(const TFilePath &fp, TXshSimpleLevel *sl, bool overwrite) { QString question; question = "Palette " + QString::fromStdWString(sl->getPalette()->getPaletteName()) + ".tpl has been modified. Do you want to overwrite palette as well ?"; - int ret = MsgBox(question, + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite Palette") /*ret = 1*/, QObject::tr("Don't Overwrite Palette") /*ret = 2*/, 0); if (ret == 1) overwritePalette = true; @@ -1620,11 +1620,11 @@ bool IoCmd::saveLevel(const TFilePath &fp, TXshSimpleLevel *sl, bool overwrite) sl->save(fp, TFilePath(), overwritePalette); } catch (TSystemException se) { QApplication::restoreOverrideCursor(); - MsgBox(WARNING, QString::fromStdWString(se.getMessage())); + DVGui::warning(QString::fromStdWString(se.getMessage())); return false; } catch (...) { QApplication::restoreOverrideCursor(); - MsgBox(CRITICAL, QObject::tr("Couldn't save %1").arg(toQString(fp))); + DVGui::error(QObject::tr("Couldn't save %1").arg(toQString(fp))); return false; } IconGenerator::instance()->invalidate(fp); @@ -1667,14 +1667,14 @@ bool IoCmd::saveSound(const TFilePath &fp, TXshSoundLevel *sl, bool overwrite) if (!overwrite && TSystem::doesExistFileOrLevel(fp)) { QString question; question = QObject::tr("The soundtrack %1 already exists.\nDo you want to overwrite it?").arg(toQString(fp)); - int ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return false; } try { sl->save(fp); } catch (...) { - MsgBox(CRITICAL, QObject::tr("Couldn't save %1").arg(toQString(fp))); + DVGui::error(QObject::tr("Couldn't save %1").arg(toQString(fp))); return false; } QApplication::setOverrideCursor(Qt::WaitCursor); @@ -1732,7 +1732,7 @@ bool IoCmd::loadColorModel(const TFilePath &fp, int frame) list.append(QObject::tr("Overwrite the destination palette.")); list.append(QObject::tr("Keep the destination palette and apply it to the color model.")); - int ret = RadioButtonMsgBox(DVGui::WARNING, question, list); + int ret = DVGui::RadioButtonMsgBox(DVGui::WARNING, question, list); if (ret == 0) return false; @@ -1807,7 +1807,7 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile, bool checkSa if (scenePath.getType() != "tnz") { QString msg; msg = QObject::tr("File %1 doesn't look like a TOONZ Scene").arg(QString::fromStdWString(scenePath.getWideString())); - MsgBox(CRITICAL, msg); + DVGui::error(msg); return false; } if (!TSystem::doesExistFileOrLevel(scenePath)) @@ -1818,7 +1818,7 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile, bool checkSa if (!sceneProject) { QString msg; msg = QObject::tr("It is not possible to load the scene %1 because it does not belong to any project.").arg(QString::fromStdWString(scenePath.getWideString())); - MsgBox(WARNING, msg); + DVGui::warning(msg); } if (sceneProject && !sceneProject->isCurrent()) { QString currentProjectName = @@ -1834,7 +1834,7 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile, bool checkSa QString importAnswer = QObject::tr("Import Scene"); QString switchProjectAnswer = QObject::tr("Change Project"); QString cancelAnswer = QObject::tr("Cancel"); - int ret = MsgBox(question, importAnswer, switchProjectAnswer, cancelAnswer, 0); + int ret = DVGui::MsgBox(question, importAnswer, switchProjectAnswer, cancelAnswer, 0); if (ret == 3 || ret == 0) { newScene(); return false; @@ -1886,14 +1886,14 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile, bool checkSa msg = QObject::tr("The scene %1 was created with Toonz and cannot be loaded in LineTest.").arg(QString::fromStdWString(scenePath.getWideString())); else msg = QObject::tr("There were problems loading the scene %1.\n Some files may be missing.").arg(QString::fromStdWString(scenePath.getWideString())); - MsgBox(WARNING, msg); + DVGui::warning(msg); } #endif catch (...) { printf("%s:%s Exception ...:\n", __FILE__, __FUNCTION__); QString msg; msg = QObject::tr("There were problems loading the scene %1.\n Some files may be missing.").arg(QString::fromStdWString(scenePath.getWideString())); - MsgBox(WARNING, msg); + DVGui::warning(msg); } printf("%s:%s end load:\n", __FILE__, __FUNCTION__); TProject *project = scene->getProject(); @@ -1944,7 +1944,7 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile, bool checkSa if (forbiddenLevelCount > 0) { QString msg; msg = QObject::tr("There were problems loading the scene %1.\nSome levels have not been loaded because their version is not supported").arg(QString::fromStdWString(scenePath.getWideString())); - MsgBox(WARNING, msg); + DVGui::warning(msg); } bool exist = TSystem::doesExistFileOrLevel(scene->decodeFilePath(scene->getScenePath())); @@ -2601,16 +2601,16 @@ public: #else TXshSimpleLevel *sl = TApp::instance()->getCurrentLevel()->getSimpleLevel(); if (!sl) { - MsgBox(WARNING, QObject::tr("No Current Level")); + DVGui::warning(QObject::tr("No Current Level")); return; } if (!sl->getPalette()) { - MsgBox(WARNING, QObject::tr("Toonz cannot Save this Level")); + DVGui::warning(QObject::tr("Toonz cannot Save this Level")); return; } ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); if (!scene) { - MsgBox(WARNING, QObject::tr("No Current Scene")); + DVGui::warning(QObject::tr("No Current Scene")); return; // non dovrebbe succedere mai } TFilePath levelPath = sl->getPath(); @@ -2642,14 +2642,14 @@ public: { QString question; question = QObject::tr("Are you sure you want to save the Default Settings?"); - int ret = MsgBox(question, QObject::tr("Save"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Save"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return; ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); try { TProjectManager::instance()->saveTemplate(scene); } catch (TSystemException se) { - MsgBox(WARNING, QString::fromStdWString(se.getMessage())); + DVGui::warning(QString::fromStdWString(se.getMessage())); return; } } @@ -2691,7 +2691,7 @@ public: if (args.loadedLevels.empty()) { QString msg; msg = QObject::tr("It is not possible to load the %1 level.").arg(path); - MsgBox(CRITICAL, msg); + DVGui::error(msg); } } } openRecentLevelFileCommandHandler; @@ -2734,11 +2734,11 @@ public: TFilePath path = scene->getScenePath(); TFilePath decodePath = scene->decodeFilePath(scene->getScenePath()); if (!TSystem::doesExistFileOrLevel(decodePath)) { - MsgBox(DVGui::WARNING, QObject::tr("The scene %1 doesn't exist.").arg(toQString(decodePath))); + DVGui::warning(QObject::tr("The scene %1 doesn't exist.").arg(toQString(decodePath))); return; } if (sceneHandle->getDirtyFlag()) { - int ret = MsgBox(QString(QObject::tr("Revert: the current scene has been modified.\nAre you sure you want to revert to previous version?")), + int ret = DVGui::MsgBox(QString(QObject::tr("Revert: the current scene has been modified.\nAre you sure you want to revert to previous version?")), QString(QObject::tr("Revert")), QString(QObject::tr("Cancel"))); if (ret == 2 || ret == 0) return; @@ -2760,13 +2760,13 @@ public: TXshLevel *level = TApp::instance()->getCurrentLevel()->getLevel(); if (!level) { - MsgBox(WARNING, "No current level."); + DVGui::warning("No current level."); return; } TXshSimpleLevel *sl = level->getSimpleLevel(); TXshPaletteLevel *pl = level->getPaletteLevel(); if (!sl && !pl) { - MsgBox(WARNING, "Current level has no palette."); + DVGui::warning("Current level has no palette."); return; } /*-- SimpleLevel/PaletteLevelの場合毎にパレット/パスの取得の仕方を変える --*/ @@ -2776,7 +2776,7 @@ public: if (sl) { palette = sl->getPalette(); if (!palette) { - MsgBox(WARNING, "No current palette"); + DVGui::warning("No current palette"); return; } if (sl->getPath().getType() == "pli") @@ -2788,12 +2788,12 @@ public: else if (pl) { palette = pl->getPalette(); if (!palette) { - MsgBox(WARNING, "No current palette"); + DVGui::warning("No current palette"); return; } palettePath = pl->getPath(); } else { - MsgBox(WARNING, "This level is not SimpleLevel or PaletteLevel"); + DVGui::warning("This level is not SimpleLevel or PaletteLevel"); return; } @@ -2801,10 +2801,10 @@ public: int ret; if (sl && sl->getPath().getType() == "pli") { question = "Saving " + toQString(palettePath) + "\nThis command will ovewrite the level data as well. Are you sure ?"; - ret = MsgBox(question, QObject::tr("OK"), QObject::tr("Cancel"), 0); + ret = DVGui::MsgBox(question, QObject::tr("OK"), QObject::tr("Cancel"), 0); } else { question = "Do you want to overwrite current palette to " + toQString(palettePath) + " ?"; - ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Don't Overwrite"), 0); + ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Don't Overwrite"), 0); } if (ret == 2 || ret == 0) return; diff --git a/toonz/sources/toonz/levelcreatepopup.cpp b/toonz/sources/toonz/levelcreatepopup.cpp index af4a103..4b823a4 100644 --- a/toonz/sources/toonz/levelcreatepopup.cpp +++ b/toonz/sources/toonz/levelcreatepopup.cpp @@ -178,10 +178,10 @@ LevelCreatePopup::LevelCreatePopup() setWindowTitle(tr("New Level")); m_nameFld = new LineEdit(this); - m_fromFld = new IntLineEdit(this); - m_toFld = new IntLineEdit(this); - m_stepFld = new IntLineEdit(this); - m_incFld = new IntLineEdit(this); + m_fromFld = new DVGui::IntLineEdit(this); + m_toFld = new DVGui::IntLineEdit(this); + m_stepFld = new DVGui::IntLineEdit(this); + m_incFld = new DVGui::IntLineEdit(this); m_levelTypeOm = new QComboBox(); m_pathFld = new FileField(0); @@ -445,7 +445,7 @@ bool LevelCreatePopup::apply() /*question = "Folder " +toQString(parentDir) + " doesn't exist.\nDo you want to create it?";*/ question = tr("Folder %1 doesn't exist.\nDo you want to create it?").arg(toQString(parentDir)); - int ret = MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); + int ret = DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); if (ret == 0 || ret == 2) return false; try { diff --git a/toonz/sources/toonz/levelcreatepopup.h b/toonz/sources/toonz/levelcreatepopup.h index 8d3c06d..ee75fae 100644 --- a/toonz/sources/toonz/levelcreatepopup.h +++ b/toonz/sources/toonz/levelcreatepopup.h @@ -13,29 +13,27 @@ class QLabel; class QComboBox; //class DVGui::MeasuredDoubleLineEdit; -using namespace DVGui; - //============================================================================= // LevelCreatePopup //----------------------------------------------------------------------------- -class LevelCreatePopup : public Dialog +class LevelCreatePopup : public DVGui::Dialog { Q_OBJECT - LineEdit *m_nameFld; - IntLineEdit *m_fromFld; - IntLineEdit *m_toFld; + DVGui::LineEdit *m_nameFld; + DVGui::IntLineEdit *m_fromFld; + DVGui::IntLineEdit *m_toFld; QComboBox *m_levelTypeOm; - IntLineEdit *m_stepFld; - IntLineEdit *m_incFld; - FileField *m_pathFld; + DVGui::IntLineEdit *m_stepFld; + DVGui::IntLineEdit *m_incFld; + DVGui::FileField *m_pathFld; QLabel *m_widthLabel; QLabel *m_heightLabel; QLabel *m_dpiLabel; DVGui::MeasuredDoubleLineEdit *m_widthFld; DVGui::MeasuredDoubleLineEdit *m_heightFld; - DoubleLineEdit *m_dpiFld; + DVGui::DoubleLineEdit *m_dpiFld; public: LevelCreatePopup(); diff --git a/toonz/sources/toonz/levelsettingspopup.cpp b/toonz/sources/toonz/levelsettingspopup.cpp index a336031..d265baf 100644 --- a/toonz/sources/toonz/levelsettingspopup.cpp +++ b/toonz/sources/toonz/levelsettingspopup.cpp @@ -134,7 +134,7 @@ LevelSettingsPopup::LevelSettingsPopup() //subsampling m_subsamplingLabel = new QLabel(tr("Subsampling:")); - m_subsamplingFld = new IntLineEdit(this); + m_subsamplingFld = new DVGui::IntLineEdit(this); m_doPremultiply = new CheckBox(tr("Premultiply"), this); @@ -143,7 +143,7 @@ LevelSettingsPopup::LevelSettingsPopup() #endif m_doAntialias = new CheckBox(tr("Add Antialiasing"), this); - m_antialiasSoftness = new IntLineEdit(0, 10, 0, 100); + m_antialiasSoftness = new DVGui::IntLineEdit(0, 10, 0, 100); //---- @@ -675,7 +675,7 @@ void LevelSettingsPopup::onPathChanged() question = "The path you entered for the level " + QString(toString(sl->getName()).c_str()) + "is already used: this may generate some conflicts in the file management.\nAre you sure you want to assign the same path to two different levels?"; - int ret = MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); + int ret = DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); if (ret == 0 || ret == 2) { m_pathFld->setPath(toQString(m_sl->getPath())); return; @@ -773,11 +773,11 @@ void LevelSettingsPopup::onScanPathChanged() if (cleanupLevelPath != TFilePath()) { TFilePath codedCleanupLevelPath = TApp::instance()->getCurrentScene()->getScene()->codeFilePath(cleanupLevelPath); if (m_sl->getPath().getParentDir() != cleanupLevelPath && m_sl->getPath().getParentDir() != codedCleanupLevelPath) - MsgBox(WARNING, "\"Save In\" path of the Cleanup Settings does not match."); + DVGui::warning("\"Save In\" path of the Cleanup Settings does not match."); } else - MsgBox(WARNING, "Loading Cleanup Settings failed."); + DVGui::warning("Loading Cleanup Settings failed."); } else - MsgBox(WARNING, ".cln file for the Scanned Level not found."); + DVGui::warning(".cln file for the Scanned Level not found."); m_sl->setScannedPath(newScanPath); diff --git a/toonz/sources/toonz/linesfadepopup.h b/toonz/sources/toonz/linesfadepopup.h index be2cc55..a4ad44a 100644 --- a/toonz/sources/toonz/linesfadepopup.h +++ b/toonz/sources/toonz/linesfadepopup.h @@ -7,8 +7,6 @@ #include "toonz/txshsimplelevel.h" #include "traster.h" -using namespace std; - class QSlider; class ImageViewer; class TSelection; diff --git a/toonz/sources/toonz/linetestcapturepane.cpp b/toonz/sources/toonz/linetestcapturepane.cpp index 7719ca2..cc48599 100644 --- a/toonz/sources/toonz/linetestcapturepane.cpp +++ b/toonz/sources/toonz/linetestcapturepane.cpp @@ -607,13 +607,13 @@ CaptureParameters *CaptureSettingsPopup::getCaptureParameters() void CaptureSettingsPopup::defineDevice() { if (TnzCamera::instance()->isCameraConnected()) { - DVGui::MsgBox(DVGui::WARNING, tr("A Device is Connected.")); + DVGui::warning(tr("A Device is Connected.")); return; } QList cameras; bool ret = TnzCamera::instance()->findConnectedCameras(cameras); if (!ret) { - DVGui::MsgBox(DVGui::WARNING, tr("No cameras found.")); + DVGui::warning(tr("No cameras found.")); return; } @@ -650,14 +650,14 @@ void CaptureSettingsPopup::onKeepWhiteImage() { TnzCamera *camera = TnzCamera::instance(); if (!camera->isCameraConnected()) { - DVGui::MsgBox(DVGui::WARNING, tr("Device Disconnected.")); + DVGui::warning(tr("Device Disconnected.")); return; } TFilePath whiteImagePath = TEnv::getConfigDir() + TFilePath("whiteReferenceImage.0001.tif"); if (TSystem::doesExistFileOrLevel(whiteImagePath)) { QString question; question = "The White Image already exists.\nDo you want to overwrite it?"; - int ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return; } @@ -670,7 +670,7 @@ void CaptureSettingsPopup::onImageWidthEditingFinished() { CaptureParameters *parameters = getCaptureParameters(); if (parameters->getDeviceName().empty()) { - DVGui::MsgBox(DVGui::WARNING, tr("No Device Defined.")); + DVGui::warning(tr("No Device Defined.")); m_imageWidthLineEdit->setValue(parameters->getResolution().lx); return; } @@ -691,7 +691,7 @@ void CaptureSettingsPopup::onImageHeightEditingFinished() { CaptureParameters *parameters = getCaptureParameters(); if (parameters->getDeviceName().empty()) { - DVGui::MsgBox(DVGui::WARNING, tr("No Device Defined.")); + DVGui::warning(tr("No Device Defined.")); m_imageHeightLineEdit->setValue(parameters->getResolution().ly); return; } @@ -1191,13 +1191,13 @@ void LineTestCapturePane::onConnectCheckboxStateChanged(int state) wstring deviceName = sceneProperties->getCaptureParameters()->getDeviceName(); if (deviceName.empty()) { - DVGui::MsgBox(DVGui::WARNING, tr("No Device Defined.")); + DVGui::warning(tr("No Device Defined.")); m_connectionCheckBox->setChecked(false); return; } bool ret = TnzCamera::instance()->cameraConnect(deviceName); if (!ret) { - DVGui::MsgBox(DVGui::WARNING, tr("Cannot connect Camera")); + DVGui::warning(tr("Cannot connect Camera")); m_connectionCheckBox->setChecked(false); } else TnzCamera::instance()->onViewfinder(m_imageView); @@ -1215,7 +1215,7 @@ void LineTestCapturePane::captureButton() return; if (!TnzCamera::instance()->isCameraConnected()) { - DVGui::MsgBox(DVGui::WARNING, tr("Device Disconnected.")); + DVGui::warning(tr("Device Disconnected.")); return; } QString clickPath = QString::fromStdString(TEnv::getApplicationName()) + QString(" ") + diff --git a/toonz/sources/toonz/linetestpane.h b/toonz/sources/toonz/linetestpane.h index 48894cd..2b394f3 100644 --- a/toonz/sources/toonz/linetestpane.h +++ b/toonz/sources/toonz/linetestpane.h @@ -16,8 +16,6 @@ #include #include -using namespace DVGui; - class QStackedWidget; //============================================================================= diff --git a/toonz/sources/toonz/loadfoldercommand.cpp b/toonz/sources/toonz/loadfoldercommand.cpp index a70be70..9540b36 100644 --- a/toonz/sources/toonz/loadfoldercommand.cpp +++ b/toonz/sources/toonz/loadfoldercommand.cpp @@ -429,8 +429,7 @@ struct import_Locals { boost::bind(copy, boost::cref(srcDir), boost::cref(dstDir), _1, overwrite)); } catch (const TException &e) { - DVGui::MsgBox(DVGui::CRITICAL, - QString::fromStdWString(e.getMessage())); + DVGui::error(QString::fromStdWString(e.getMessage())); } catch (...) { } } diff --git a/toonz/sources/toonz/magpiefileimportpopup.cpp b/toonz/sources/toonz/magpiefileimportpopup.cpp index b39e247..87e1b0b 100644 --- a/toonz/sources/toonz/magpiefileimportpopup.cpp +++ b/toonz/sources/toonz/magpiefileimportpopup.cpp @@ -92,11 +92,11 @@ MagpieFileImportPopup::MagpieFileImportPopup() addWidget(tr("Phoneme"), frameLabel); int i; for (i = 0; i < 9; i++) { - IntLineEdit *field = new IntLineEdit(this, 1, 1); + DVGui::IntLineEdit *field = new DVGui::IntLineEdit(this, 1, 1); QLabel *label = new QLabel("", this); label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); label->setFixedSize(getLabelWidth(), field->height()); - m_actFields.append(QPair(label, field)); + m_actFields.append(QPair(label, field)); addWidgets(label, field); } @@ -149,7 +149,7 @@ void MagpieFileImportPopup::showEvent(QShowEvent *) int i; QList actsIdentifier = m_info->getActsIdentifier(); for (i = 0; i < m_actFields.size(); i++) { - IntLineEdit *field = m_actFields.at(i).second; + DVGui::IntLineEdit *field = m_actFields.at(i).second; QLabel *label = m_actFields.at(i).first; if (i >= actsIdentifier.size()) { field->hide(); @@ -237,7 +237,7 @@ void MagpieFileImportPopup::onOkPressed() } int j; for (j = 0; j < m_actFields.size(); j++) { - IntLineEdit *field = m_actFields.at(j).second; + DVGui::IntLineEdit *field = m_actFields.at(j).second; QString act = field->property("act").toString(); if (actorAct != act) continue; diff --git a/toonz/sources/toonz/magpiefileimportpopup.h b/toonz/sources/toonz/magpiefileimportpopup.h index 7735279..ea240d2 100644 --- a/toonz/sources/toonz/magpiefileimportpopup.h +++ b/toonz/sources/toonz/magpiefileimportpopup.h @@ -15,8 +15,6 @@ class FileField; class LineEdit; } -using namespace DVGui; - class MagpieInfo { QList m_actorActs; @@ -39,17 +37,17 @@ public: // MagpieFileImportPopup //----------------------------------------------------------------------------- -class MagpieFileImportPopup : public Dialog +class MagpieFileImportPopup : public DVGui::Dialog { Q_OBJECT MagpieInfo *m_info; - FileField *m_levelField; - IntLineEdit *m_fromField; - IntLineEdit *m_toField; + DVGui::FileField *m_levelField; + DVGui::IntLineEdit *m_fromField; + DVGui::IntLineEdit *m_toField; - QList> m_actFields; + QList> m_actFields; FlipBook *m_flipbook; TFilePath m_levelPath; diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp index e34742b..ad9ecd4 100644 --- a/toonz/sources/toonz/main.cpp +++ b/toonz/sources/toonz/main.cpp @@ -132,7 +132,7 @@ const char *applicationName = "OpenToonz"; const char *applicationVersion = "1.0"; const char *dllRelativePath = "./toonz6.app/Contents/Frameworks"; -#ifdef WIN32 +#ifdef _WIN32 TEnv::StringVar EnvSoftwareCurrentFont("SoftwareCurrentFont", "Arial"); #else TEnv::StringVar EnvSoftwareCurrentFont("SoftwareCurrentFont", "Hervetica"); @@ -160,14 +160,14 @@ void qt_mac_set_menubar_merge(bool enable); void fatalError(QString msg) { - MsgBoxInPopup(CRITICAL, msg + "\n" + QObject::tr("Installing %1 again could fix the problem.").arg(applicationFullName)); + DVGui::MsgBoxInPopup(CRITICAL, msg + "\n" + QObject::tr("Installing %1 again could fix the problem.").arg(applicationFullName)); exit(0); } //----------------------------------------------------------------------------- void lastWarningError(QString msg) { - MsgBox(CRITICAL, msg); + DVGui::error(msg); //exit(0); } //----------------------------------------------------------------------------- @@ -201,7 +201,7 @@ extern "C" void licenseObserverCB(char *msg) void toonzRunOutOfContMemHandler(unsigned long size) { -#ifdef WIN32 +#ifdef _WIN32 static bool firstTime = true; if (firstTime) { MessageBox(NULL, (LPCWSTR)L"Run out of contiguous physical memory: please save all and restart Toonz!", @@ -380,7 +380,7 @@ int main(int argc, char *argv[]) std::auto_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. -#ifdef WIN32 +#ifdef _WIN32 #ifndef x64 //Store the floating point control word. It will be re-set before Toonz initialization //has ended. @@ -389,7 +389,7 @@ int main(int argc, char *argv[]) #endif #endif -#ifdef WIN32 +#ifdef _WIN32 //At least on windows, Qt's 4.5.2 native windows feature tend to create //weird flickering effects when dragging panel separators. a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); @@ -412,7 +412,7 @@ int main(int argc, char *argv[]) // splash screen QPixmap splashPixmap(":Resources/splash.png"); -#ifdef WIN32 +#ifdef _WIN32 a.setFont(QFont("Arial", 10)); #else a.setFont(QFont("Helvetica", 10)); @@ -642,7 +642,7 @@ int main(int argc, char *argv[]) License::writeMacAddress(); //Controllo che la data della prima installazione contenuta nella sentinella sia minore della data corrente. if (License::isTemporaryLicense(license) && !License::isValidSentinel(license)) { - MsgBox(CRITICAL, QObject::tr("System date tampered.")); + DVGui::error(QObject::tr("System date tampered.")); return -1; } if (License::checkLicense(license) == License::INVALID_LICENSE || @@ -696,7 +696,7 @@ int main(int argc, char *argv[]) TUndoManager::manager(), SIGNAL(somethingChanged()), TApp::instance()->getCurrentScene(), SLOT(setDirtyFlag())); -#ifdef WIN32 +#ifdef _WIN32 #ifndef x64 //On 32-bit architecture, there could be cases in which initialization could alter the //FPU floating point control word. I've seen this happen when loading some AVI coded (VFAPI), @@ -716,7 +716,7 @@ int main(int argc, char *argv[]) TUndoManager::manager()->reset(); PreviewFxManager::instance()->reset(); -#ifdef WIN32 +#ifdef _WIN32 if (consoleAttached) { ::FreeConsole(); } diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index a38fcb9..0a368f9 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -108,7 +108,7 @@ bool readRoomList(std::vector &roomPaths, if (!argumentLayoutFileName.isEmpty()) { fp = ToonzFolder::getModuleFile(argumentLayoutFileName.toStdString()); if (!TFileStatus(fp).doesExist()) { - MsgBox(WARNING, "Room layout file " + argumentLayoutFileName + " not found!"); + DVGui::warning("Room layout file " + argumentLayoutFileName + " not found!"); fp = ToonzFolder::getModuleFile(layoutsFileName); if (!TFileStatus(fp).doesExist()) return false; @@ -202,7 +202,7 @@ void makePrivate(Room *room) if (TFileStatus(templateFullMBPath).doesExist()) TSystem::copyFile(myMBPath, templateFullMBPath); else - DVGui::MsgBox(WARNING, QObject::tr("Cannot open menubar settings template file. Re-installing Toonz will solve this problem.")); + DVGui::warning(QObject::tr("Cannot open menubar settings template file. Re-installing Toonz will solve this problem.")); } } } @@ -1073,7 +1073,7 @@ void MainWindow::resetRoomsLayout() } } - MsgBox(INFORMATION, QObject::tr("The rooms will be reset the next time you run Toonz.")); + DVGui::info(QObject::tr("The rooms will be reset the next time you run Toonz.")); } //----------------------------------------------------------------------------- @@ -1297,7 +1297,7 @@ void MainWindow::onUpdateCheckerDone(bool error) std::vector buttons; buttons.push_back(QString(tr("Visit Web Site"))); buttons.push_back(QString(tr("Cancel"))); - int ret = MsgBox(INFORMATION, QObject::tr("An update is available for this software.\nVisit the Web site for more information."), buttons); + int ret = DVGui::MsgBox(DVGui::INFORMATION, QObject::tr("An update is available for this software.\nVisit the Web site for more information."), buttons); if (ret == 1) QDesktopServices::openUrl(webPageUrl); @@ -1324,8 +1324,7 @@ void MainWindow::onLicenseCheckerDone(bool error) { if (!error) { if (!m_licenseChecker->isLicenseValid()) { - MsgBox(CRITICAL, - QObject::tr("The license validation process was not able to confirm the right to use this software on this computer.\n Please contact [ support@toonz.com ] for assistance.")); + DVGui::error(QObject::tr("The license validation process was not able to confirm the right to use this software on this computer.\n Please contact [ support@toonz.com ] for assistance.")); qApp->exit(0); } } @@ -1350,7 +1349,7 @@ void MainWindow::closeEvent(QCloseEvent *event) #ifdef BRAVODEMO QString question; question = "Quit: are you sure you want to quit?"; - int ret = MsgBox(question, QObject::tr("Quit"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Quit"), QObject::tr("Cancel"), 0); if (ret == 0 || ret == 2) { event->ignore(); return; diff --git a/toonz/sources/toonz/matchline.cpp b/toonz/sources/toonz/matchline.cpp index 796d188..975a583 100644 --- a/toonz/sources/toonz/matchline.cpp +++ b/toonz/sources/toonz/matchline.cpp @@ -709,7 +709,7 @@ void doMatchlines(int column, int mColumn, int index, int inkPrevalence, int Mer /*-- 左カラムに複数のLevelが入っている場合、警告を出して抜ける --*/ else if (level != cell[i].getSimpleLevel()) { getImageProgressBar->close(); - MsgBox(WARNING, QObject::tr("It is not possible to apply match lines to a column containing more than one level.")); + DVGui::warning(QObject::tr("It is not possible to apply match lines to a column containing more than one level.")); /*-- 前に遡ってキャッシュを消去 --*/ i--; for (; i >= 0; i--) { @@ -725,7 +725,7 @@ void doMatchlines(int column, int mColumn, int index, int inkPrevalence, int Mer mLevel = mCell[i].getSimpleLevel(); else if (mLevel != mCell[i].getSimpleLevel()) { getImageProgressBar->close(); - MsgBox(WARNING, QObject::tr("It is not possible to use a match lines column containing more than one level.")); + DVGui::warning(QObject::tr("It is not possible to use a match lines column containing more than one level.")); /*-- 前に遡ってキャッシュを消去 --*/ i--; for (; i >= 0; i--) { @@ -752,7 +752,7 @@ void doMatchlines(int column, int mColumn, int index, int inkPrevalence, int Mer //ラスタLevelじゃないとき、エラーを返す if (!timg || !tmatch) { getImageProgressBar->close(); - MsgBox(WARNING, QObject::tr("Match lines can be applied to Toonz raster levels only.")); + DVGui::warning(QObject::tr("Match lines can be applied to Toonz raster levels only.")); /*-- 前に遡ってキャッシュを消去 --*/ i--; for (; i >= 0; i--) { @@ -779,7 +779,7 @@ void doMatchlines(int column, int mColumn, int index, int inkPrevalence, int Mer getImageProgressBar->close(); if (matchingLevels.empty()) { - MsgBox(WARNING, QObject::tr("Match lines can be applied to Toonz raster levels only.")); + DVGui::warning(QObject::tr("Match lines can be applied to Toonz raster levels only.")); return; } @@ -787,7 +787,7 @@ void doMatchlines(int column, int mColumn, int index, int inkPrevalence, int Mer { TPalette *plt = level->getPalette(); if (!plt) { - MsgBox(WARNING, QObject::tr("The level you are using has not a valid palette.")); + DVGui::warning(QObject::tr("The level you are using has not a valid palette.")); return; } @@ -813,7 +813,7 @@ void doMatchlines(int column, int mColumn, int index, int inkPrevalence, int Mer index = md->getInkIndex(); if (index >= styleCount) - MsgBox(WARNING, QObject::tr("The style index you specified is not available in the palette of the destination level.")); + DVGui::warning(QObject::tr("The style index you specified is not available in the palette of the destination level.")); if (index != -1) LastMatchlineIndex = index; } @@ -875,19 +875,19 @@ bool contains(const vector &v, const TFrameId &val) //----------------------------------------------------------------------------- -QString indexes2string(const set fids) +QString indexes2string(const std::set fids) { if (fids.empty()) return ""; QString str; - set::const_iterator it = fids.begin(); + std::set::const_iterator it = fids.begin(); str = QString::number(it->getNumber()); while (it != fids.end()) { - set::const_iterator it1 = it; + std::set::const_iterator it1 = it; it1++; int lastVal = it->getNumber(); @@ -1012,12 +1012,12 @@ void DeleteInkDialog::setRange(const QString &str) DeleteLinesコマンドから呼ばれる場合:chooseInkがtrue --*/ -void doDeleteMatchlines(TXshSimpleLevel *sl, const set &fids, bool chooseInk) +void doDeleteMatchlines(TXshSimpleLevel *sl, const std::set &fids, bool chooseInk) { - vector indexes; + std::vector indexes; //vector images; - vector frames; - vector fidsToProcess; + std::vector frames; + std::vector fidsToProcess; int i; if (chooseInk) { TPaletteHandle *ph = TApp::instance()->getPaletteController()->getCurrentLevelPalette(); @@ -1037,13 +1037,13 @@ void doDeleteMatchlines(TXshSimpleLevel *sl, const set &fids, bool cho return; indexes = md->getInkIndexes(); if (indexes.empty()) { - MsgBox(WARNING, QObject::tr("The style index range you specified is not valid: please separate values with a comma (e.g. 1,2,5) or with a dash (e.g. 4-7 will refer to indexes 4, 5, 6 and 7).")); + DVGui::warning(QObject::tr("The style index range you specified is not valid: please separate values with a comma (e.g. 1,2,5) or with a dash (e.g. 4-7 will refer to indexes 4, 5, 6 and 7).")); continue; } frames = md->getFrames(); if (frames.empty()) { - MsgBox(WARNING, QObject::tr("The frame range you specified is not valid: please separate values with a comma (e.g. 1,2,5) or with a dash (e.g. 4-7 will refer to frames 4, 5, 6 and 7).")); + DVGui::warning(QObject::tr("The frame range you specified is not valid: please separate values with a comma (e.g. 1,2,5) or with a dash (e.g. 4-7 will refer to frames 4, 5, 6 and 7).")); continue; } for (i = 0; i < frames.size(); i++) { @@ -1066,7 +1066,7 @@ void doDeleteMatchlines(TXshSimpleLevel *sl, const set &fids, bool cho } if (fidsToProcess.empty()) { - MsgBox(WARNING, QObject::tr("No drawing is available in the frame range you specified.")); + DVGui::warning(QObject::tr("No drawing is available in the frame range you specified.")); return; } @@ -1088,12 +1088,12 @@ void doDeleteMatchlines(TXshSimpleLevel *sl, const set &fids, bool cho //----------------------------------------------------------------------------- -void deleteMatchlines(TXshSimpleLevel *sl, const set &fids) +void deleteMatchlines(TXshSimpleLevel *sl, const std::set &fids) { doDeleteMatchlines(sl, fids, false); } -void deleteInk(TXshSimpleLevel *sl, const set &fids) +void deleteInk(TXshSimpleLevel *sl, const std::set &fids) { doDeleteMatchlines(sl, fids, true); } diff --git a/toonz/sources/toonz/matchline.h b/toonz/sources/toonz/matchline.h index 4646a11..f2fa2c9 100644 --- a/toonz/sources/toonz/matchline.h +++ b/toonz/sources/toonz/matchline.h @@ -26,7 +26,7 @@ class TXsheet; //================================================== -class MergeCmappedDialog : public Dialog +class MergeCmappedDialog : public DVGui::Dialog { Q_OBJECT @@ -47,13 +47,13 @@ protected slots: //---------------------------------------------------------------- -class MatchlinesDialog : public Dialog +class MatchlinesDialog : public DVGui::Dialog { Q_OBJECT QRadioButton *m_button1, *m_button2; - StyleIndexLineEdit *m_inkIndex; - IntField *m_inkPrevalence; + DVGui::StyleIndexLineEdit *m_inkIndex; + DVGui::IntField *m_inkPrevalence; TPaletteHandle *m_pltHandle; QPushButton *m_lup_noGapButton; @@ -82,12 +82,12 @@ public: //---------------------------------------------------------------- -class DeleteInkDialog : public Dialog +class DeleteInkDialog : public DVGui::Dialog { Q_OBJECT - LineEdit *m_inkIndex; - LineEdit *m_frames; + DVGui::LineEdit *m_inkIndex; + DVGui::LineEdit *m_frames; public: DeleteInkDialog(const QString &str, int inkIndex); diff --git a/toonz/sources/toonz/matchlinecommand.cpp b/toonz/sources/toonz/matchlinecommand.cpp index 83d96f6..5343adf 100644 --- a/toonz/sources/toonz/matchlinecommand.cpp +++ b/toonz/sources/toonz/matchlinecommand.cpp @@ -68,12 +68,12 @@ MergeCmappedDialog::MergeCmappedDialog(TFilePath &levelPath) QString name = QString::fromStdString(m_levelPath.getName()); setWindowTitle(tr(" Merge Tlv Levels")); - m_saveInFileFld = new FileField(0, path); + m_saveInFileFld = new DVGui::FileField(0, path); ret = ret && connect(m_saveInFileFld, SIGNAL(pathChanged()), this, SLOT(onPathChanged())); addWidget(tr("Save in:"), m_saveInFileFld); - m_fileNameFld = new LineEdit(name + "_merged"); - m_fileNameFld->setMaximumHeight(WidgetHeight); + m_fileNameFld = new DVGui::LineEdit(name + "_merged"); + m_fileNameFld->setMaximumHeight(DVGui::WidgetHeight); ret = ret && connect(m_fileNameFld, SIGNAL(editingFinished()), SLOT(onNameChanged())); addWidget(tr("File Name:"), m_fileNameFld); @@ -102,12 +102,12 @@ public: std::set indices = selection ? selection->getIndices() : std::set(); if (indices.empty()) { - MsgBox(WARNING, tr("It is not possible to execute the merge column command because no column was selected.")); + DVGui::warning(tr("It is not possible to execute the merge column command because no column was selected.")); return; } if (indices.size() == 1) { - MsgBox(WARNING, tr("It is not possible to execute the merge column command because only one columns is selected.")); + DVGui::warning(tr("It is not possible to execute the merge column command because only one columns is selected.")); return; } @@ -130,14 +130,14 @@ public: { TColumnSelection *selection = dynamic_cast(TSelection::getCurrent()); if (!selection) { - MsgBox(WARNING, tr("It is not possible to apply the match lines because no column was selected.")); + DVGui::warning(tr("It is not possible to apply the match lines because no column was selected.")); return; } std::set indices = selection->getIndices(); if (indices.size() != 2) { - MsgBox(WARNING, tr("It is not possible to apply the match lines because two columns have to be selected.")); + DVGui::warning(tr("It is not possible to apply the match lines because two columns have to be selected.")); return; } @@ -177,11 +177,11 @@ bool checkColumnValidity(int column) level = cell[i].getSimpleLevel(); if (cell[i].getSimpleLevel()->getType() != TZP_XSHLEVEL) { - MsgBox(WARNING, QObject::tr("Match lines can be applied to Toonz raster levels only.")); + DVGui::warning(QObject::tr("Match lines can be applied to Toonz raster levels only.")); return false; } if (level != cell[i].getSimpleLevel()) { - MsgBox(WARNING, QObject::tr("It is not possible to merge tlv columns containing more than one level")); + DVGui::warning(QObject::tr("It is not possible to merge tlv columns containing more than one level")); return false; } } @@ -190,7 +190,7 @@ bool checkColumnValidity(int column) return false; if (!level->getPalette()) { - MsgBox(WARNING, QObject::tr("The level you are using has not a valid palette.")); + DVGui::warning(QObject::tr("The level you are using has not a valid palette.")); return false; } return true; @@ -402,14 +402,14 @@ public: { TColumnSelection *selection = dynamic_cast(TSelection::getCurrent()); if (!selection) { - MsgBox(WARNING, tr("It is not possible to merge tlv columns because no column was selected.")); + DVGui::warning(tr("It is not possible to merge tlv columns because no column was selected.")); return; } std::set indices = selection->getIndices(); if (indices.size() < 2) { - MsgBox(WARNING, tr("It is not possible to merge tlv columns because at least two columns have to be selected.")); + DVGui::warning(tr("It is not possible to merge tlv columns because at least two columns have to be selected.")); return; } @@ -486,14 +486,14 @@ void doDeleteCommand(bool isMatchline) TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); return; } else if (!columnSelection || (indices = columnSelection->getIndices()).size() != 1) { - MsgBox(WARNING, QObject::tr("It is not possible to delete lines because no column, cell or level strip frame was selected.")); + DVGui::warning(QObject::tr("It is not possible to delete lines because no column, cell or level strip frame was selected.")); return; } int from, to; int columnIndex = *indices.begin(); TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); if (!xsh->getCellRange(*indices.begin(), from, to)) { - MsgBox(WARNING, QObject::tr("The selected column is empty.")); + DVGui::warning(QObject::tr("The selected column is empty.")); return; } r.y0 = from; @@ -503,7 +503,7 @@ void doDeleteCommand(bool isMatchline) sel->getSelectedCells(r.y0, r.x0, r.y1, r.x1); if (r.x0 != r.x1) { - MsgBox(WARNING, QObject::tr("Selected cells must be in the same column.")); + DVGui::warning(QObject::tr("Selected cells must be in the same column.")); return; } @@ -514,11 +514,11 @@ void doDeleteCommand(bool isMatchline) for (i = r.y0; i <= r.y1; i++) { TXshCell cell = xsh->getCell(i, r.x0); if (cell.isEmpty()) { - MsgBox(WARNING, QObject::tr("It is not possible to delete lines because no column, cell or level strip frame was selected.")); + DVGui::warning(QObject::tr("It is not possible to delete lines because no column, cell or level strip frame was selected.")); return; } if (cell.m_level->getType() != TZP_XSHLEVEL) { - MsgBox(WARNING, QObject::tr("Match lines can be deleted from Toonz raster levels only")); + DVGui::warning(QObject::tr("Match lines can be deleted from Toonz raster levels only")); return; } } diff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cpp index 866880f..02de277 100644 --- a/toonz/sources/toonz/menubar.cpp +++ b/toonz/sources/toonz/menubar.cpp @@ -1449,13 +1449,13 @@ void StackedMenuBar::doCustomizeMenuBar(int index) TFilePath mbPath = ToonzFolder::getMyModuleDir() + mbFileName; if (!TFileStatus(mbPath).isReadable()) { - DVGui::MsgBox(WARNING, tr("Cannot open menubar settings file %1").arg(QString::fromStdString(mbFileName))); + DVGui::warning(tr("Cannot open menubar settings file %1").arg(QString::fromStdString(mbFileName))); return; } QMenuBar* newMenu = loadMenuBar(mbPath); if (!newMenu) { - DVGui::MsgBox(WARNING, tr("Failed to create menubar")); + DVGui::warning(tr("Failed to create menubar")); return; } diff --git a/toonz/sources/toonz/menubarpopup.h b/toonz/sources/toonz/menubarpopup.h index 2670331..1b5af84 100644 --- a/toonz/sources/toonz/menubarpopup.h +++ b/toonz/sources/toonz/menubarpopup.h @@ -57,7 +57,7 @@ protected: // MenuBarPopup //----------------------------------------------------------------------------- -class MenuBarPopup : public Dialog +class MenuBarPopup : public DVGui::Dialog { Q_OBJECT CommandListTree* m_commandListTree; diff --git a/toonz/sources/toonz/mergecmapped.cpp b/toonz/sources/toonz/mergecmapped.cpp index 7e00172..9d1d3d5 100644 --- a/toonz/sources/toonz/mergecmapped.cpp +++ b/toonz/sources/toonz/mergecmapped.cpp @@ -1,5 +1,3 @@ - - #include "tapp.h" #include "tpalette.h" #include "toonz/txsheet.h" @@ -35,6 +33,8 @@ #include "toonz/toonzscene.h" #include "toonz/childstack.h" +#include + using namespace DVGui; namespace @@ -457,13 +457,13 @@ void mergeCmapped(int column, int mColumn, const QString &fullpath, bool isRedo) if (start > end) return; - vector cell(max(end, mEnd) - min(start, mStart) + 1); + vector cell(std::max(end, mEnd) - std::min(start, mStart) + 1); vector mCell(cell.size()); - xsh->getCells(min(start, mStart), column, cell.size(), &(cell[0])); + xsh->getCells(std::min(start, mStart), column, cell.size(), &(cell[0])); if (mColumn != -1) - xsh->getCells(min(start, mStart), mColumn, cell.size(), &(mCell[0])); + xsh->getCells(std::min(start, mStart), mColumn, cell.size(), &(mCell[0])); TXshColumn *col = xsh->getColumn(column); TXshColumn *mcol = xsh->getColumn(mColumn); @@ -511,8 +511,8 @@ void mergeCmapped(int column, int mColumn, const QString &fullpath, bool isRedo) TAffine imgAff, matchAff; - getColumnPlacement(imgAff, xsh, min(start, mStart) + i, column, false); - getColumnPlacement(matchAff, xsh, min(start, mStart) + i, mColumn, false); + getColumnPlacement(imgAff, xsh, std::min(start, mStart) + i, column, false); + getColumnPlacement(matchAff, xsh, std::min(start, mStart) + i, mColumn, false); //std::map::iterator it; MergedPair mp(cell[i].isEmpty() ? TFrameId() : cell[i].getFrameId(), @@ -629,19 +629,19 @@ bool contains(const vector &v, const TFrameId &val) //----------------------------------------------------------------------------- -QString indexes2string(const set fids) +QString indexes2string(const std::set fids) { if (fids.empty()) return ""; QString str; - set::const_iterator it = fids.begin(); + std::set::const_iterator it = fids.begin(); str = QString::number(it->getNumber()); while (it != fids.end()) { - set::const_iterator it1 = it; + std::set::const_iterator it1 = it; it1++; int lastVal = it->getNumber(); diff --git a/toonz/sources/toonz/mergecolumns.cpp b/toonz/sources/toonz/mergecolumns.cpp index a6ac143..bd2f697 100644 --- a/toonz/sources/toonz/mergecolumns.cpp +++ b/toonz/sources/toonz/mergecolumns.cpp @@ -68,7 +68,7 @@ void mergeRasterColumns(const vector &matchingLevels) TRaster32P ras = img->getRaster(); // img->getCMapped(false); TRaster32P matchRas = match->getRaster(); // match->getCMapped(true); if (!ras || !matchRas) { - MsgBox(WARNING, QObject::tr("The merge command is not available for greytones images.")); + DVGui::warning(QObject::tr("The merge command is not available for greytones images.")); return; } TAffine aff = matchingLevels[i].m_imgAff.inv() * matchingLevels[i].m_matchAff; @@ -260,11 +260,11 @@ public: //----------------------------------------------------------------------------- -void mergeColumns(const set &columns) +void mergeColumns(const std::set &columns) { QApplication::setOverrideCursor(Qt::WaitCursor); - set::const_iterator it = columns.begin(); + std::set::const_iterator it = columns.begin(); int dstColumn = *it; ++it; @@ -321,14 +321,14 @@ void mergeColumns(int column, int mColumn, bool isRedo) } else if (level != cell[i].getSimpleLevel()) { - MsgBox(WARNING, QObject::tr("It is not possible to perform a merging involving more than one level per column.")); + DVGui::warning(QObject::tr("It is not possible to perform a merging involving more than one level per column.")); return; } if (!mLevel) mLevel = mCell[i].getSimpleLevel(); else if (mLevel != mCell[i].getSimpleLevel()) { - MsgBox(WARNING, QObject::tr("It is not possible to perform a merging involving more than one level per column.")); + DVGui::warning(QObject::tr("It is not possible to perform a merging involving more than one level per column.")); return; } TImageP img = cell[i].getImage(true); @@ -347,17 +347,17 @@ void mergeColumns(int column, int mColumn, bool isRedo) if (timg) { if (!tmatch) { - MsgBox(WARNING, QObject::tr("Only raster levels can be merged to a raster level.")); + DVGui::warning(QObject::tr("Only raster levels can be merged to a raster level.")); return; } areRasters = true; } else if (vimg) { if (!vmatch) { - MsgBox(WARNING, QObject::tr("Only vector levels can be merged to a vector level.")); + DVGui::warning(QObject::tr("Only vector levels can be merged to a vector level.")); return; } } else { - MsgBox(WARNING, QObject::tr("It is possible to merge only Toonz vector levels or standard raster levels.")); + DVGui::warning(QObject::tr("It is possible to merge only Toonz vector levels or standard raster levels.")); return; } @@ -375,7 +375,7 @@ void mergeColumns(int column, int mColumn, bool isRedo) } if (matchingLevels.empty()) { - MsgBox(WARNING, QObject::tr("It is possible to merge only Toonz vector levels or standard raster levels.")); + DVGui::warning(QObject::tr("It is possible to merge only Toonz vector levels or standard raster levels.")); return; } @@ -435,19 +435,19 @@ bool contains(const vector &v, const TFrameId &val) //----------------------------------------------------------------------------- -QString indexes2string(const set fids) +QString indexes2string(const std::set fids) { if (fids.empty()) return ""; QString str; - set::const_iterator it = fids.begin(); + std::set::const_iterator it = fids.begin(); str = QString::number(it->getNumber()); while (it != fids.end()) { - set::const_iterator it1 = it; + std::set::const_iterator it1 = it; it1++; int lastVal = it->getNumber(); diff --git a/toonz/sources/toonz/meshifypopup.cpp b/toonz/sources/toonz/meshifypopup.cpp index 81d0af4..5df6e19 100644 --- a/toonz/sources/toonz/meshifypopup.cpp +++ b/toonz/sources/toonz/meshifypopup.cpp @@ -294,7 +294,7 @@ TXshSimpleLevel *createMeshLevel(TXshLevel *texturesLevel) << MeshifyPopup::tr("Keep the old level and overwrite processed frames") << MeshifyPopup::tr("Choose a different path (%1)").arg(QString::fromStdWString(codedDstPath.getWideString())); - answer = DVGui::RadioButtonMsgBox(QUESTION, question, optionsList, TApp::instance()->getMainWindow()); + answer = DVGui::RadioButtonMsgBox(DVGui::QUESTION, question, optionsList, TApp::instance()->getMainWindow()); } // Apply decision @@ -637,7 +637,7 @@ MeshifyPopup::MeshifyPopup() QLabel *edgesLengthLabel = new QLabel(tr("Mesh Edges Length:")); topLayout->addWidget(edgesLengthLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter); - m_edgesLength = new MeasuredDoubleField; + m_edgesLength = new DVGui::MeasuredDoubleField; m_edgesLength->setMeasure("length.x"); m_edgesLength->setRange(0.0, 1.0); // In inches (standard unit) m_edgesLength->setValue(0.2); @@ -647,7 +647,7 @@ MeshifyPopup::MeshifyPopup() QLabel *rasterizationDpiLabel = new QLabel(tr("Rasterization DPI:")); topLayout->addWidget(rasterizationDpiLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter); - m_rasterizationDpi = new DoubleLineEdit; + m_rasterizationDpi = new DVGui::DoubleLineEdit; m_rasterizationDpi->setRange(1.0, (std::numeric_limits::max)()); m_rasterizationDpi->setValue(300.0); @@ -656,7 +656,7 @@ MeshifyPopup::MeshifyPopup() QLabel *shapeMarginLabel = new QLabel(tr("Mesh Margin (pixels):")); topLayout->addWidget(shapeMarginLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter); - m_margin = new IntLineEdit; + m_margin = new DVGui::IntLineEdit; m_margin->setRange(2, (std::numeric_limits::max)()); m_margin->setValue(5); @@ -1277,13 +1277,13 @@ bool meshifySelection(const MeshifyOptions &options) CASE HAS_LEVEL_COLUMNS | HAS_MESH_COLUMNS : // Error message - DVGui::MsgBox(DVGui::CRITICAL, MeshifyPopup::tr("Current selection contains mixed image and mesh level types")); + DVGui::error(MeshifyPopup::tr("Current selection contains mixed image and mesh level types")); return false; DEFAULT: // Error message - DVGui::MsgBox(DVGui::CRITICAL, MeshifyPopup::tr("Current selection contains no image or mesh level types")); + DVGui::error(MeshifyPopup::tr("Current selection contains no image or mesh level types")); return false; } diff --git a/toonz/sources/toonz/outputsettingspopup.cpp b/toonz/sources/toonz/outputsettingspopup.cpp index 200d566..730f1bd 100644 --- a/toonz/sources/toonz/outputsettingspopup.cpp +++ b/toonz/sources/toonz/outputsettingspopup.cpp @@ -125,9 +125,9 @@ OutputSettingsPopup::OutputSettingsPopup(bool isPreview) QFrame *cameraParametersBox; if (!isPreview) { //Save In - m_saveInFileFld = new FileField(0, QString("")); + m_saveInFileFld = new DVGui::FileField(0, QString("")); //File Name - m_fileNameFld = new LineEdit(QString("")); + m_fileNameFld = new DVGui::LineEdit(QString("")); //File Format m_fileFormat = new QComboBox(); m_fileFormatButton = new QPushButton(tr("Options")); @@ -143,18 +143,18 @@ OutputSettingsPopup::OutputSettingsPopup(bool isPreview) if (isPreview) { #ifndef LINETEST //Subcamera checkbox - m_subcameraChk = new CheckBox(tr("Use Sub-Camera")); + m_subcameraChk = new DVGui::CheckBox(tr("Use Sub-Camera")); #endif } //Frame Start-End - m_startFld = new IntLineEdit(this); - m_endFld = new IntLineEdit(this); + m_startFld = new DVGui::IntLineEdit(this); + m_endFld = new DVGui::IntLineEdit(this); //Step-Shrink - m_stepFld = new IntLineEdit(this); - m_shrinkFld = new IntLineEdit(this); + m_stepFld = new DVGui::IntLineEdit(this); + m_shrinkFld = new DVGui::IntLineEdit(this); if (isPreview) - m_applyShrinkChk = new CheckBox(tr("Apply Shrink to Main Viewer"), this); + m_applyShrinkChk = new DVGui::CheckBox(tr("Apply Shrink to Main Viewer"), this); else m_applyShrinkChk = 0; //Resample Balance @@ -176,7 +176,7 @@ OutputSettingsPopup::OutputSettingsPopup(bool isPreview) otherSettingsFrame = new QFrame(this); //Gamma - m_gammaFld = new DoubleLineEdit(); + m_gammaFld = new DVGui::DoubleLineEdit(); //Dominant Field m_dominantFieldOm = new QComboBox(); @@ -185,10 +185,10 @@ OutputSettingsPopup::OutputSettingsPopup(bool isPreview) //Scene Settings FPS double frameRate = getProperties()->getFrameRate(); - m_frameRateFld = new DoubleLineEdit(this, frameRate); + m_frameRateFld = new DVGui::DoubleLineEdit(this, frameRate); - m_stretchFromFld = new DoubleLineEdit(this, rs.m_timeStretchFrom); - m_stretchToFld = new DoubleLineEdit(this, rs.m_timeStretchTo); + m_stretchFromFld = new DVGui::DoubleLineEdit(this, rs.m_timeStretchFrom); + m_stretchToFld = new DVGui::DoubleLineEdit(this, rs.m_timeStretchTo); m_multimediaOm = new QComboBox(this); showCameraSettingsButton = new QPushButton("", this); @@ -196,8 +196,8 @@ OutputSettingsPopup::OutputSettingsPopup(bool isPreview) removePresetButton = new QPushButton(tr("Remove"), this); m_presetCombo = new QComboBox(this); - m_doStereoscopy = new CheckBox("Do stereoscopy", this); - m_stereoShift = new DoubleLineEdit(this, 0.05); + m_doStereoscopy = new DVGui::CheckBox("Do stereoscopy", this); + m_stereoShift = new DVGui::DoubleLineEdit(this, 0.05); } //Threads m_threadsComboOm = new QComboBox(); @@ -878,7 +878,7 @@ void OutputSettingsPopup::onNameChanged() QString name = m_fileNameFld->text(); if (!isValidFileName(name)) { - error("A filename cannot be empty or contain any of the following characters:\n \\ / : * ? \" < > |"); + DVGui::error("A filename cannot be empty or contain any of the following characters:\n \\ / : * ? \" < > |"); TOutputProperties *prop = getProperties(); TFilePath fp = prop->getPath(); QString name = QString::fromStdString(fp.getName()); @@ -1186,7 +1186,7 @@ void OutputSettingsPopup::onDominantFieldChanged(int type) TOutputProperties *prop = getProperties(); TRenderSettings rs = prop->getRenderSettings(); if (type != c_none && m_stretchFromFld->getValue() != m_stretchToFld->getValue()) { - error("Can't apply field rendering in a time stretched scene"); + DVGui::error("Can't apply field rendering in a time stretched scene"); rs.m_fieldPrevalence = TRenderSettings::NoField; m_dominantFieldOm->setCurrentIndex(c_none); } else if (type == c_odd) @@ -1215,7 +1215,7 @@ void OutputSettingsPopup::onStretchFldEditFinished() TOutputProperties *prop = getProperties(); TRenderSettings rs = prop->getRenderSettings(); if (m_dominantFieldOm->currentIndex() != c_none) { - error("Can't stretch time in a field rendered scene\n"); + DVGui::error("Can't stretch time in a field rendered scene\n"); m_stretchFromFld->setValue(rs.m_timeStretchFrom); m_stretchToFld->setValue(rs.m_timeStretchTo); } else { diff --git a/toonz/sources/toonz/overwritepopup.cpp b/toonz/sources/toonz/overwritepopup.cpp index d4aff6e..1c5f74e 100644 --- a/toonz/sources/toonz/overwritepopup.cpp +++ b/toonz/sources/toonz/overwritepopup.cpp @@ -47,7 +47,7 @@ bool OverwriteDialog::DecodeFileExistsFunc::operator()(const TFilePath &fp) cons //************************************************************************************ OverwriteDialog::OverwriteDialog() - : Dialog(TApp::instance()->getMainWindow(), true) + : DVGui::Dialog(TApp::instance()->getMainWindow(), true) { setModal(true); setWindowTitle(tr("Warning!")); @@ -72,7 +72,7 @@ OverwriteDialog::OverwriteDialog() m_rename = new QRadioButton(tr("Rename the new file adding the suffix"), this); buttonGroup->addButton(m_rename); - m_suffix = new LineEdit("_1", this); + m_suffix = new DVGui::LineEdit("_1", this); m_suffix->setFixedWidth(25); m_suffix->setEnabled(false); @@ -266,13 +266,13 @@ std::wstring OverwriteDialog::execute(ToonzScene *scene, const TFilePath &srcLev if (m_rename->isChecked()) { if (m_suffix->text() == "") { - MsgBox(WARNING, tr("The suffix field is empty. Please specify a suffix.")); + DVGui::warning(tr("The suffix field is empty. Please specify a suffix.")); return execute(scene, srcLevelPath, multiload); } levelPath = addSuffix(srcLevelPath); actualLevelPath = scene->decodeFilePath(levelPath); if (TSystem::doesExistFileOrLevel(actualLevelPath)) { - MsgBox(WARNING, tr("File %1 exists as well; please choose a different suffix.").arg(toQString(levelPath))); + DVGui::warning(tr("File %1 exists as well; please choose a different suffix.").arg(toQString(levelPath))); return execute(scene, srcLevelPath, multiload); } m_choice = RENAME; diff --git a/toonz/sources/toonz/overwritepopup.h b/toonz/sources/toonz/overwritepopup.h index 1dd353f..4d1ebfc 100644 --- a/toonz/sources/toonz/overwritepopup.h +++ b/toonz/sources/toonz/overwritepopup.h @@ -41,7 +41,7 @@ class QPushButton; Additionally, the dialog could be \t CANCELED, either by closing it or pressing the "Cancel" button. */ -class OverwriteDialog : public Dialog +class OverwriteDialog : public DVGui::Dialog { Q_OBJECT @@ -112,7 +112,7 @@ private: QRadioButton *m_overwrite; QRadioButton *m_keep; QRadioButton *m_rename; - LineEdit *m_suffix; + DVGui::LineEdit *m_suffix; QPushButton *m_okBtn, *m_okToAllBtn, *m_cancelBtn; private: diff --git a/toonz/sources/toonz/pltgizmopopup.h b/toonz/sources/toonz/pltgizmopopup.h index e775248..1beb435 100644 --- a/toonz/sources/toonz/pltgizmopopup.h +++ b/toonz/sources/toonz/pltgizmopopup.h @@ -8,8 +8,6 @@ #include "toonzqt/doublefield.h" #include "toonzqt/colorfield.h" -using namespace DVGui; - //============================================================================= // ValueAdjuster //----------------------------------------------------------------------------- @@ -18,7 +16,7 @@ class ValueAdjuster : public QWidget { Q_OBJECT - DoubleLineEdit *m_valueLineEdit; + DVGui::DoubleLineEdit *m_valueLineEdit; public: #if QT_VERSION >= 0x050500 @@ -44,7 +42,7 @@ class ValueShifter : public QWidget { Q_OBJECT - DoubleLineEdit *m_valueLineEdit; + DVGui::DoubleLineEdit *m_valueLineEdit; public: #if QT_VERSION >= 0x050500 @@ -72,7 +70,7 @@ class ColorFader : public QWidget { Q_OBJECT - DoubleLineEdit *m_valueLineEdit; + DVGui::DoubleLineEdit *m_valueLineEdit; public: #if QT_VERSION >= 0x050500 @@ -93,11 +91,11 @@ signals: // PltGizmoPopup //----------------------------------------------------------------------------- -class PltGizmoPopup : public Dialog +class PltGizmoPopup : public DVGui::Dialog { Q_OBJECT - ColorField *m_colorFld; + DVGui::ColorField *m_colorFld; public: PltGizmoPopup(); diff --git a/toonz/sources/toonz/predict3d.cpp b/toonz/sources/toonz/predict3d.cpp index 80bd339..f5c5f59 100644 --- a/toonz/sources/toonz/predict3d.cpp +++ b/toonz/sources/toonz/predict3d.cpp @@ -25,6 +25,7 @@ * - i punti di cui e' nota la posizione corrente non sono * allineati, ovvero non giacciono su un'unica retta ---------------------------------------------------------------------*/ +#include #include "predict3d.h" #include "metnum.h" @@ -59,8 +60,6 @@ bool Predict3D::Predict(int k, Point initial[], Point current[], bool visible[]) /* Definizione e allocazione delle variabili */ int n, m, kvis; double **x; - double *y; - double *c; int i, ii, j, l; kvis = 0; for (i = 0; i < k; i++) @@ -74,8 +73,8 @@ bool Predict3D::Predict(int k, Point initial[], Point current[], bool visible[]) x = AllocMatrix(m, n); if (x == 0) return false; - y = new double[n]; - c = new double[m]; + std::unique_ptr y(new double[n]); + std::unique_ptr c(new double[m]); /* Costruzione dei coefficienti del sistema */ @@ -108,11 +107,9 @@ bool Predict3D::Predict(int k, Point initial[], Point current[], bool visible[]) /* Soluzione del sistema */ - int status = Approx(n, m, x, y, c); + int status = Approx(n, m, x, y.get(), c.get()); if (status != 0) { FreeMatrix(m, x); - delete[] y; - delete[] c; return false; } @@ -130,8 +127,6 @@ bool Predict3D::Predict(int k, Point initial[], Point current[], bool visible[]) } FreeMatrix(m, x); - delete[] y; - delete[] c; return true; } diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 4b7e42c..8eeb75b 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -839,7 +839,7 @@ PreferencesPopup::PreferencesPopup() CheckBox *useDefaultViewerCB = new CheckBox(tr("Use Default Viewer for Movie Formats"), this); CheckBox *minimizeRasterMemoryCB = new CheckBox(tr("Minimize Raster Memory Fragmentation *"), this); CheckBox *autoSaveCB = new CheckBox(tr("Save Automatically Every Minutes")); - m_minuteFld = new IntLineEdit(this, 15, 1, 60); + m_minuteFld = new DVGui::IntLineEdit(this, 15, 1, 60); CheckBox *replaceAfterSaveLevelAsCB = new CheckBox(tr("Replace Toonz Level after SaveLevelAs command"), this); m_cellsDragBehaviour = new QComboBox(); @@ -872,10 +872,10 @@ PreferencesPopup::PreferencesPopup() QComboBox *styleSheetType = new QComboBox(this); QComboBox *unitOm = new QComboBox(this); QComboBox *cameraUnitOm = new QComboBox(this); - m_iconSizeLx = new IntLineEdit(this, 80, 10, 400); - m_iconSizeLy = new IntLineEdit(this, 60, 10, 400); - m_viewShrink = new IntLineEdit(this, 1, 1, 20); - m_viewStep = new IntLineEdit(this, 1, 1, 20); + m_iconSizeLx = new DVGui::IntLineEdit(this, 80, 10, 400); + m_iconSizeLy = new DVGui::IntLineEdit(this, 60, 10, 400); + m_viewShrink = new DVGui::IntLineEdit(this, 1, 1, 20); + m_viewStep = new DVGui::IntLineEdit(this, 1, 1, 20); CheckBox *moveCurrentFrameCB = new CheckBox(tr("Move Current Frame by Clicking on Xsheet / Numerical Columns Cell Area"), this); //Viewer BG color @@ -948,12 +948,12 @@ PreferencesPopup::PreferencesPopup() categoryList->addItem(tr("Animation")); m_keyframeType = new QComboBox(this); - m_animationStepField = new IntLineEdit(this, 1, 1, 500); + m_animationStepField = new DVGui::IntLineEdit(this, 1, 1, 500); //--- Preview ------------------------------ categoryList->addItem(tr("Preview")); - m_blanksCount = new IntLineEdit(this, 0, 0, 1000); + m_blanksCount = new DVGui::IntLineEdit(this, 0, 0, 1000); m_blankColor = new ColorField(this, false, TPixel::Black); CheckBox *rewindAfterPlaybackCB = new CheckBox(tr("Rewind after Playback"), this); CheckBox *displayInNewFlipBookCB = new CheckBox(tr("Display in a New Flipbook Window"), this); @@ -972,7 +972,7 @@ PreferencesPopup::PreferencesPopup() m_inksOnly->setChecked(onlyInks); int thickness = m_pref->getOnionPaperThickness(); - m_onionPaperThickness = new IntLineEdit(this, thickness, 0, 100); + m_onionPaperThickness = new DVGui::IntLineEdit(this, thickness, 0, 100); //--- Transparency Check ------------------------------ categoryList->addItem(tr("Transparency Check")); diff --git a/toonz/sources/toonz/previewer.cpp b/toonz/sources/toonz/previewer.cpp index 79b3220..f72ccbc 100644 --- a/toonz/sources/toonz/previewer.cpp +++ b/toonz/sources/toonz/previewer.cpp @@ -742,7 +742,7 @@ enum { eBegin, eIncrement, eEnd }; -static ProgressDialog *Pd = 0; +static DVGui::ProgressDialog *Pd = 0; //----------------------------------------------------------------------------- @@ -758,7 +758,7 @@ public: switch (m_choice) { case eBegin: if (!Pd) - Pd = new ProgressDialog(QObject::tr("Saving previewed frames...."), QObject::tr("Cancel"), 0, m_val); + Pd = new DVGui::ProgressDialog(QObject::tr("Saving previewed frames...."), QObject::tr("Cancel"), 0, m_val); else Pd->setMaximum(m_val); Pd->show(); @@ -773,7 +773,7 @@ public: } break; case eEnd: { - MsgBox(DVGui::INFORMATION, m_str); + DVGui::info(m_str); delete Pd; Pd = 0; } break; @@ -837,12 +837,12 @@ bool Previewer::Imp::doSaveRenderedFrames(TFilePath fp) fp = fp.withType(ext); } if (fp.getName() == "") { - MsgBox(WARNING, tr("The file name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); + DVGui::warning(tr("The file name cannot be empty or contain any of the following characters:(new line) \\ / : * ? \" |")); return false; } if (!formats.contains(QString::fromStdString(ext))) { - MsgBox(WARNING, "Unsopporter raster format, cannot save"); + DVGui::warning("Unsopporter raster format, cannot save"); return false; } @@ -869,7 +869,7 @@ bool Previewer::Imp::doSaveRenderedFrames(TFilePath fp) if (TSystem::doesExistFileOrLevel(fp)) { QString question(tr("File %1 already exists.\nDo you want to overwrite it?").arg(toQString(fp))); - int ret = MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"), QObject::tr("Cancel"), 0); if (ret == 2) return false; } diff --git a/toonz/sources/toonz/projectpopup.cpp b/toonz/sources/toonz/projectpopup.cpp index adf6702..10233fe 100644 --- a/toonz/sources/toonz/projectpopup.cpp +++ b/toonz/sources/toonz/projectpopup.cpp @@ -520,7 +520,7 @@ void ProjectSettingsPopup::onFolderChanged() try { project->save(); } catch (TSystemException se) { - MsgBox(WARNING, QString::fromStdWString(se.getMessage())); + DVGui::warning(QString::fromStdWString(se.getMessage())); return; } DvDirModel::instance()->refreshFolder(project->getProjectFolder()); @@ -535,7 +535,7 @@ void ProjectSettingsPopup::onUseSceneChekboxChanged(int) try { project->save(); } catch (TSystemException se) { - MsgBox(WARNING, QString::fromStdWString(se.getMessage())); + DVGui::warning(QString::fromStdWString(se.getMessage())); return; } DvDirModel::instance()->refreshFolder(project->getProjectFolder()); @@ -631,9 +631,9 @@ void ProjectCreatePopup::createProject() try { bool isSaved = project->save(projectPath); if (!isSaved) - MsgBox(CRITICAL, tr("It is not possible to create the %1 project.").arg(toQString(projectPath))); + DVGui::error(tr("It is not possible to create the %1 project.").arg(toQString(projectPath))); } catch (TSystemException se) { - MsgBox(WARNING, QString::fromStdWString(se.getMessage())); + DVGui::warning(QString::fromStdWString(se.getMessage())); return; } pm->setCurrentProjectPath(projectPath); diff --git a/toonz/sources/toonz/rendercommand.cpp b/toonz/sources/toonz/rendercommand.cpp index 4efcfb7..91cd2b7 100644 --- a/toonz/sources/toonz/rendercommand.cpp +++ b/toonz/sources/toonz/rendercommand.cpp @@ -31,7 +31,7 @@ #include "toonz/multimediarenderer.h" #include "toutputproperties.h" -#ifdef WIN32 +#ifdef _WIN32 #include "avicodecrestrictions.h" #endif @@ -196,7 +196,7 @@ public: { if (m_error) { m_error = false; - MsgBox(DVGui::CRITICAL, QObject::tr("There was an error saving frames for the %1 level.").arg(QString::fromStdWString(m_fp.withoutParentDir().getWideString()))); + DVGui::error(QObject::tr("There was an error saving frames for the %1 level.").arg(QString::fromStdWString(m_fp.withoutParentDir().getWideString()))); } bool isPreview = (m_fp.getType() == "noext"); @@ -214,7 +214,7 @@ public: if (!TSystem::showDocument(m_fp)) { QString msg(QObject::tr("It is not possible to display the file %1: no player associated with its format").arg(QString::fromStdWString(m_fp.withoutParentDir().getWideString()))); - MsgBox(WARNING, msg); + DVGui::warning(msg); } } @@ -301,7 +301,7 @@ bool RenderCommand::init(bool isPreview) if (m_r1 >= scene->getFrameCount()) m_r1 = scene->getFrameCount() - 1; if (m_r1 < m_r0) { - MsgBox(WARNING, QObject::tr("The command cannot be executed because the scene is empty.")); + DVGui::warning(QObject::tr("The command cannot be executed because the scene is empty.")); return false; // throw TException("empty scene"); // non so perche', ma termina il programma @@ -345,10 +345,10 @@ bool RenderCommand::init(bool isPreview) TSystem::mkDir(parent); DvDirModel::instance()->refreshFolder(parent.getParentDir()); } catch (TException &e) { - MsgBox(WARNING, QObject::tr("It is not possible to create folder : %1").arg(QString::fromStdString(toString(e.getMessage())))); + DVGui::warning(QObject::tr("It is not possible to create folder : %1").arg(QString::fromStdString(toString(e.getMessage())))); return false; } catch (...) { - MsgBox(WARNING, QObject::tr("It is not possible to create a folder.")); + DVGui::warning(QObject::tr("It is not possible to create a folder.")); return false; } } @@ -387,7 +387,7 @@ void RenderCommand::flashRender() FILE *fileP = fopen(m_fp, "wb"); if (!fileP) return; - ProgressDialog pb("rendering " + toQString(m_fp), "Cancel", 0, m_numFrames); + DVGui::ProgressDialog pb("rendering " + toQString(m_fp), "Cancel", 0, m_numFrames); pb.show(); TDimension cameraSize = scene->getCurrentCamera()->getRes(); @@ -446,7 +446,7 @@ void RenderCommand::flashRender() //=================================================================== class RenderListener - : public ProgressDialog, + : public DVGui::ProgressDialog, public MovieRenderer::Listener { QString m_progressBarString; @@ -476,7 +476,7 @@ class RenderListener public: RenderListener(TRenderer *renderer, const TFilePath &path, int steps, bool isPreview) - : ProgressDialog("Precomputing " + QString::number(steps) + " Frames" + ((isPreview) ? "" : " of " + toQString(path)), "Cancel", 0, steps, TApp::instance()->getMainWindow()), m_renderer(renderer), m_frameCounter(0), m_error(false) + : DVGui::ProgressDialog("Precomputing " + QString::number(steps) + " Frames" + ((isPreview) ? "" : " of " + toQString(path)), "Cancel", 0, steps, TApp::instance()->getMainWindow()), m_renderer(renderer), m_frameCounter(0), m_error(false) { #ifdef MACOSX //Modal dialogs seem to be preventing the execution of Qt::BlockingQueuedConnections on MAC...! @@ -530,14 +530,14 @@ void RenderCommand::rasterRender(bool isPreview) string ext = m_fp.getType(); -#ifdef WIN32 +#ifdef _WIN32 if (ext == "avi" && !isPreview) { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); - MsgBox(WARNING, msg); + DVGui::warning(msg); return; } } @@ -632,7 +632,7 @@ void RenderCommand::rasterRender(bool isPreview) //=================================================================== class MultimediaProgressBar - : public ProgressDialog, + : public DVGui::ProgressDialog, public MultimediaRenderer::Listener { QString m_progressBarString; @@ -740,14 +740,14 @@ void RenderCommand::multimediaRender() ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); string ext = m_fp.getType(); -#ifdef WIN32 +#ifdef _WIN32 if (ext == "avi") { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); - MsgBox(WARNING, msg); + DVGui::warning(msg); return; } } @@ -846,7 +846,7 @@ void RenderCommand::doRender(bool isPreview) if (!isWritable) { string str = "It is not possible to write the output: the file"; str += isMultiFrame ? "s are read only." : " is read only."; - MsgBox(WARNING, QString::fromStdString(str)); + DVGui::warning(QString::fromStdString(str)); return; } @@ -865,9 +865,9 @@ void RenderCommand::doRender(bool isPreview) /*-- 通常のRendering --*/ rasterRender(isPreview); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); } catch (...) { - MsgBox(WARNING, QObject::tr("It is not possible to complete the rendering.")); + DVGui::warning(QObject::tr("It is not possible to complete the rendering.")); } } diff --git a/toonz/sources/toonz/renumberpopup.cpp b/toonz/sources/toonz/renumberpopup.cpp index c0638a7..a2765fc 100644 --- a/toonz/sources/toonz/renumberpopup.cpp +++ b/toonz/sources/toonz/renumberpopup.cpp @@ -21,9 +21,9 @@ RenumberPopup::RenumberPopup() setWindowTitle(tr("Renumber")); beginHLayout(); - addWidget(tr("Start:"), m_startFld = new IntLineEdit(this)); + addWidget(tr("Start:"), m_startFld = new DVGui::IntLineEdit(this)); addSpacing(10); - addWidget(tr("Step:"), m_stepFld = new IntLineEdit(this)); + addWidget(tr("Step:"), m_stepFld = new DVGui::IntLineEdit(this)); endHLayout(); m_okBtn = new QPushButton(tr("Renumber"), this); diff --git a/toonz/sources/toonz/renumberpopup.h b/toonz/sources/toonz/renumberpopup.h index febcf5d..a04ff26 100644 --- a/toonz/sources/toonz/renumberpopup.h +++ b/toonz/sources/toonz/renumberpopup.h @@ -10,20 +10,18 @@ // forward declaration class QPushButton; -using namespace DVGui; - //============================================================================= // RenumberPopup //----------------------------------------------------------------------------- -class RenumberPopup : public Dialog +class RenumberPopup : public DVGui::Dialog { Q_OBJECT QPushButton *m_okBtn; QPushButton *m_cancelBtn; - IntLineEdit *m_startFld, *m_stepFld; + DVGui::IntLineEdit *m_startFld, *m_stepFld; public: RenumberPopup(); diff --git a/toonz/sources/toonz/savepresetpopup.cpp b/toonz/sources/toonz/savepresetpopup.cpp index 628f765..45c18ca 100644 --- a/toonz/sources/toonz/savepresetpopup.cpp +++ b/toonz/sources/toonz/savepresetpopup.cpp @@ -36,7 +36,7 @@ SavePresetPopup::SavePresetPopup() : Dialog(TApp::instance()->getMainWindow(), true, true, "SavePreset") { setWindowTitle(tr("Save Preset")); - addWidget(tr("Preset Name:"), m_nameFld = new LineEdit(this)); + addWidget(tr("Preset Name:"), m_nameFld = new DVGui::LineEdit(this)); m_nameFld->setMinimumWidth(170); QPushButton *okBtn = new QPushButton(tr("Save"), this); @@ -77,12 +77,12 @@ bool SavePresetPopup::apply() TSystem::mkDir(parent); DvDirModel::instance()->refreshFolder(parent.getParentDir()); } catch (...) { - error(tr("It is not possible to create the preset folder %1.").arg(QString::fromStdString(fp.getParentDir().getName()))); + DVGui::error(tr("It is not possible to create the preset folder %1.").arg(QString::fromStdString(fp.getParentDir().getName()))); return 0; } } if (TFileStatus(fp).doesExist()) { - if (MsgBox(tr("Do you want to overwrite?"), tr("Yes"), tr("No")) == 2) + if (DVGui::MsgBox(tr("Do you want to overwrite?"), tr("Yes"), tr("No")) == 2) return 0; } if (isMacro) { diff --git a/toonz/sources/toonz/savepresetpopup.h b/toonz/sources/toonz/savepresetpopup.h index 25541bd..41a0bbd 100644 --- a/toonz/sources/toonz/savepresetpopup.h +++ b/toonz/sources/toonz/savepresetpopup.h @@ -6,17 +6,15 @@ #include "toonzqt/dvdialog.h" #include "toonzqt/lineedit.h" -using namespace DVGui; - //============================================================================= // SavePresetPopup //----------------------------------------------------------------------------- -class SavePresetPopup : public Dialog +class SavePresetPopup : public DVGui::Dialog { Q_OBJECT - LineEdit *m_nameFld; + DVGui::LineEdit *m_nameFld; public: SavePresetPopup(); diff --git a/toonz/sources/toonz/scanpopup.cpp b/toonz/sources/toonz/scanpopup.cpp index 45139ae..6c7dec0 100644 --- a/toonz/sources/toonz/scanpopup.cpp +++ b/toonz/sources/toonz/scanpopup.cpp @@ -63,7 +63,7 @@ void checkPaperFormat(TScannerParameters *parameters) if (parameters->getPaperOverflow()) { TScanner *scanner = TScanner::instance(); QString scannerName = scanner ? scanner->getName() : "no scanner"; - MsgBox(WARNING, QObject::tr("The selected paper format is not available for %1.").arg(scannerName)); + DVGui::warning(QObject::tr("The selected paper format is not available for %1.").arg(scannerName)); } } @@ -78,7 +78,7 @@ bool defineScanner(const QString &scannerType) try { if (!TScanner::instance()->isDeviceAvailable()) { - MsgBox(WARNING, TScanner::m_isTwain ? QObject::tr("No TWAIN scanner is available") : QObject::tr("No scanner is available")); + DVGui::warning(TScanner::m_isTwain ? QObject::tr("No TWAIN scanner is available") : QObject::tr("No scanner is available")); /* FIXME: try/catch からの goto って合法じゃないだろ……。とりあえず応急処置したところ"例外ってナニ?"って感じになったのが indent も腐っておりつらいので後で直す */ //goto end; @@ -87,7 +87,7 @@ bool defineScanner(const QString &scannerType) } TScanner::instance()->selectDevice(); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdWString(e.getMessage())); + DVGui::warning(QString::fromStdWString(e.getMessage())); QApplication::restoreOverrideCursor(); return false; //goto end; @@ -101,7 +101,7 @@ bool defineScanner(const QString &scannerType) try { scanParameters->adaptToCurrentScanner(); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdWString(e.getMessage())); + DVGui::warning(QString::fromStdWString(e.getMessage())); //goto end; QApplication::restoreOverrideCursor(); return false; @@ -645,12 +645,12 @@ MyScannerListener::MyScannerListener(const ScanList &scanList) void MyScannerListener::onImage(const TRasterImageP &rasImg) { if (!rasImg || !rasImg->getRaster()) { - MsgBox(WARNING, tr("The pixel type is not supported.")); + DVGui::warning(tr("The pixel type is not supported.")); m_current += m_inc; return; } if (!m_isPreview && (m_current < 0 || m_current >= m_scanList.getFrameCount())) { - MsgBox(WARNING, tr("The scanning process is completed.")); + DVGui::warning(tr("The scanning process is completed.")); return; } if (m_isPreview) { @@ -665,7 +665,7 @@ void MyScannerListener::onImage(const TRasterImageP &rasImg) cl->setParameters(cp); TRasterImageP outImg = cl->autocenterOnly(rasImg, false, autocentered); if (!autocentered) - MsgBox(WARNING, QObject::tr("The autocentering failed on the current drawing.")); + DVGui::warning(QObject::tr("The autocentering failed on the current drawing.")); else rasImg->setRaster(outImg->getRaster()); } @@ -696,7 +696,7 @@ void MyScannerListener::onError() { if (m_progressDialog) m_progressDialog->hide(); - MsgBox(WARNING, tr("There was an error during the scanning process.")); + DVGui::warning(tr("There was an error during the scanning process.")); } //----------------------------------------------------------------------------- @@ -705,10 +705,10 @@ void MyScannerListener::onNextPaper() { assert(!m_isPreview); if (TScanner::instance()->m_isTwain) - MsgBox(INFORMATION, tr("Please, place the next paper drawing on the scanner flatbed, then select the relevant command in the TWAIN interface.")); + DVGui::info(tr("Please, place the next paper drawing on the scanner flatbed, then select the relevant command in the TWAIN interface.")); else { QString question(tr("Please, place the next paper drawing on the scanner flatbed, then click the Scan button.")); - int ret = MsgBox(question, QObject::tr("Scan"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Scan"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) m_isCanceled = true; } @@ -757,7 +757,7 @@ void doScan() return; ScanList scanList; if (scanList.areScannedFramesSelected()) { - int ret = MsgBox(QObject::tr("Some of the selected drawings were already scanned. Do you want to scan them again?"), + int ret = DVGui::MsgBox(QObject::tr("Some of the selected drawings were already scanned. Do you want to scan them again?"), QObject::tr("Scan"), QObject::tr("Don't Scan"), QObject::tr("Cancel")); if (ret == 3) return; @@ -766,7 +766,7 @@ void doScan() scanList.update(true); if (scanList.getFrameCount() == 0) { - MsgBox(WARNING, QObject::tr("There are no frames to scan.")); + DVGui::warning(QObject::tr("There are no frames to scan.")); return; } @@ -775,7 +775,7 @@ void doScan() int rc = scanner->isDeviceAvailable(); if (!rc) { - MsgBox(WARNING, QObject::tr("TWAIN is not available.")); + DVGui::warning(QObject::tr("TWAIN is not available.")); return; } @@ -791,7 +791,7 @@ void doScan() if (cropboxCheck->isEnabled()) cropboxCheck->uncheck(); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdWString(e.getMessage())); + DVGui::warning(QString::fromStdWString(e.getMessage())); } //If some levels were scanned successfully, their renumber table must be updated. @@ -870,7 +870,7 @@ public: int rc = scanner->isDeviceAvailable(); if (!rc) { - MsgBox(WARNING, QObject::tr("TWAIN is not available.")); + DVGui::warning(QObject::tr("TWAIN is not available.")); return; } @@ -895,7 +895,7 @@ public: if (resetCropAction) resetCropAction->setDisabled(false); } catch (TException &e) { - MsgBox(WARNING, QString::fromStdWString(e.getMessage())); + DVGui::warning(QString::fromStdWString(e.getMessage())); } } } setCropboxCommand; diff --git a/toonz/sources/toonz/scenesettingspopup.cpp b/toonz/sources/toonz/scenesettingspopup.cpp index 3bdbee2..d9b2e61 100644 --- a/toonz/sources/toonz/scenesettingspopup.cpp +++ b/toonz/sources/toonz/scenesettingspopup.cpp @@ -98,23 +98,23 @@ SceneSettingsPopup::SceneSettingsPopup() //Field Guide Size - A/R int fieldGuideSize = sprop->getFieldGuideSize(); - m_fieldGuideFld = new IntLineEdit(this, fieldGuideSize, 0, 50); + m_fieldGuideFld = new DVGui::IntLineEdit(this, fieldGuideSize, 0, 50); m_aspectRatioFld = new DoubleLineEdit(this, 1.38); m_aspectRatioFld->setRange(-10000.0, 10000.0); m_aspectRatioFld->setDecimals(5); //Image Subsampling - Tlv Subsampling int fullcolorSubsampling = sprop->getFullcolorSubsampling(); - m_fullcolorSubsamplingFld = new IntLineEdit(this, fullcolorSubsampling, 1); + m_fullcolorSubsamplingFld = new DVGui::IntLineEdit(this, fullcolorSubsampling, 1); int tlvSubsampling = sprop->getTlvSubsampling(); - m_tlvSubsamplingFld = new IntLineEdit(this, tlvSubsampling, 1); + m_tlvSubsamplingFld = new DVGui::IntLineEdit(this, tlvSubsampling, 1); //Marker Interval - Start Frame int distance, offset; sprop->getMarkers(distance, offset); - m_markerIntervalFld = new IntLineEdit(this, distance, 0); - m_startFrameFld = new IntLineEdit(this, offset); + m_markerIntervalFld = new DVGui::IntLineEdit(this, distance, 0); + m_startFrameFld = new DVGui::IntLineEdit(this, offset); // layout QGridLayout *mainLayout = new QGridLayout(); diff --git a/toonz/sources/toonz/scenesettingspopup.h b/toonz/sources/toonz/scenesettingspopup.h index d37d42a..949c6b9 100644 --- a/toonz/sources/toonz/scenesettingspopup.h +++ b/toonz/sources/toonz/scenesettingspopup.h @@ -13,8 +13,6 @@ class TSceneProperties; class QComboBox; -using namespace DVGui; - //============================================================================= // SceneSettingsPopup //----------------------------------------------------------------------------- @@ -23,17 +21,17 @@ class SceneSettingsPopup : public QDialog { Q_OBJECT - DoubleLineEdit *m_frameRateFld; - ColorField *m_bgColorFld; + DVGui::DoubleLineEdit *m_frameRateFld; + DVGui::ColorField *m_bgColorFld; - IntLineEdit *m_fieldGuideFld; - DoubleLineEdit *m_aspectRatioFld; + DVGui::IntLineEdit *m_fieldGuideFld; + DVGui::DoubleLineEdit *m_aspectRatioFld; - IntLineEdit *m_fullcolorSubsamplingFld; - IntLineEdit *m_tlvSubsamplingFld; + DVGui::IntLineEdit *m_fullcolorSubsamplingFld; + DVGui::IntLineEdit *m_tlvSubsamplingFld; - IntLineEdit *m_markerIntervalFld; - IntLineEdit *m_startFrameFld; + DVGui::IntLineEdit *m_markerIntervalFld; + DVGui::IntLineEdit *m_startFrameFld; TSceneProperties *getProperties() const; diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp index 29467a9..efa7560 100644 --- a/toonz/sources/toonz/sceneviewer.cpp +++ b/toonz/sources/toonz/sceneviewer.cpp @@ -1015,7 +1015,7 @@ void SceneViewer::drawBackground() if (glGetError() == GL_INVALID_FRAMEBUFFER_OPERATION) { /* 起動時一回目になぜか GL_FRAMEBUFFER_COMPLETE なのに invalid operation が出る */ GLenum status = 0; -#if WIN32 +#ifdef _WIN32 PROC proc = wglGetProcAddress("glCheckFramebufferStatusEXT"); if (proc != nullptr) status = reinterpret_cast(proc)(GL_FRAMEBUFFER); @@ -1028,7 +1028,7 @@ void SceneViewer::drawBackground() bool check_framebuffer_status() { -#if WIN32 +#ifdef _WIN32 PROC proc = wglGetProcAddress("glCheckFramebufferStatusEXT"); if (proc == nullptr) return true; diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp index cbee6af..8d7d42b 100644 --- a/toonz/sources/toonz/sceneviewerevents.cpp +++ b/toonz/sources/toonz/sceneviewerevents.cpp @@ -144,7 +144,7 @@ void SceneViewer::onButtonPressed(FlipConsole::EGadget button) CASE FlipConsole::eSaveImg: { if (m_previewMode == NO_PREVIEW) { - DVGui::MsgBox(WARNING, QObject::tr("It is not possible to save images in camera stand view.")); + DVGui::warning(QObject::tr("It is not possible to save images in camera stand view.")); return; } TApp *app = TApp::instance(); @@ -152,7 +152,7 @@ void SceneViewer::onButtonPressed(FlipConsole::EGadget button) Previewer *previewer = Previewer::instance(m_previewMode == SUBCAMERA_PREVIEW); if (!previewer->isFrameReady(row)) { - DVGui::MsgBox(WARNING, QObject::tr("The preview images are not ready yet.")); + DVGui::warning(QObject::tr("The preview images are not ready yet.")); return; } @@ -474,7 +474,7 @@ void SceneViewer::mouseReleaseEvent(QMouseEvent *event) if (!tool || !tool->isEnabled()) { if (!m_toolDisableReason.isEmpty() && m_mouseButton == Qt::LeftButton && !m_editPreviewSubCamera) - MsgBox(WARNING, m_toolDisableReason); + DVGui::warning(m_toolDisableReason); } if (m_freezedStatus != NO_FREEZED) @@ -957,7 +957,7 @@ using namespace ImageUtils; void SceneViewer::contextMenuEvent(QContextMenuEvent *e) { -#ifndef WIN32 +#ifndef _WIN32 /* On windows the widget receive the release event before the menu is shown, on linux and osx the release event is lost, never received by the widget */ diff --git a/toonz/sources/toonz/shortcutpopup.cpp b/toonz/sources/toonz/shortcutpopup.cpp index 78970d9..7331eba 100644 --- a/toonz/sources/toonz/shortcutpopup.cpp +++ b/toonz/sources/toonz/shortcutpopup.cpp @@ -139,7 +139,7 @@ void ShortcutViewer::keyPressEvent(QKeyEvent *event) return; if (oldAction) { QString msg = tr("%1 is already assigned to '%2'\nAssign to '%3'?").arg(keySequence.toString()).arg(oldAction->iconText()).arg(m_action->iconText()); - int ret = MsgBox(msg, tr("Yes"), tr("No"), 1); + int ret = DVGui::MsgBox(msg, tr("Yes"), tr("No"), 1); activateWindow(); if (ret == 2 || ret == 0) return; diff --git a/toonz/sources/toonz/shortcutpopup.h b/toonz/sources/toonz/shortcutpopup.h index d4c645d..2e5192d 100644 --- a/toonz/sources/toonz/shortcutpopup.h +++ b/toonz/sources/toonz/shortcutpopup.h @@ -12,8 +12,6 @@ class QPushButton; class ShortcutItem; -using namespace DVGui; - //============================================================================= // ShortcutViewer // -------------- @@ -81,7 +79,7 @@ signals: // Questo e' il popup che l'utente utilizza per modificare gli shortcut //----------------------------------------------------------------------------- -class ShortcutPopup : public Dialog +class ShortcutPopup : public DVGui::Dialog { Q_OBJECT QPushButton *m_removeBtn; diff --git a/toonz/sources/toonz/subscenecommand.cpp b/toonz/sources/toonz/subscenecommand.cpp index 076f950..4f64f99 100644 --- a/toonz/sources/toonz/subscenecommand.cpp +++ b/toonz/sources/toonz/subscenecommand.cpp @@ -2174,7 +2174,7 @@ void SubsceneCmd::collapse(std::set &indices) list.append(QObject::tr("Include relevant pegbars in the sub-xsheet as well.")); list.append(QObject::tr("Include only selected columns in the sub-xsheet.")); - int ret = RadioButtonMsgBox(DVGui::WARNING, question, list); + int ret = DVGui::RadioButtonMsgBox(DVGui::WARNING, question, list); if (ret == 0) return; @@ -2277,7 +2277,7 @@ void SubsceneCmd::collapse(const QList &fxs) QList list; list.append(QObject::tr("Include relevant pegbars in the sub-xsheet as well.")); list.append(QObject::tr("Include only selected columns in the sub-xsheet.")); - int ret = RadioButtonMsgBox(DVGui::WARNING, question, list); + int ret = DVGui::RadioButtonMsgBox(DVGui::WARNING, question, list); if (ret == 0) return; @@ -2351,7 +2351,7 @@ void SubsceneCmd::explode(int index) QList list; list.append(QObject::tr("Bring relevant pegbars in the main xsheet.")); list.append(QObject::tr("Bring only columns in the main xsheet.")); - int ret = RadioButtonMsgBox(DVGui::WARNING, question, list); + int ret = DVGui::RadioButtonMsgBox(DVGui::WARNING, question, list); if (ret == 0) return; diff --git a/toonz/sources/toonz/svncleanupdialog.h b/toonz/sources/toonz/svncleanupdialog.h index 7d6fc8c..0ea9021 100644 --- a/toonz/sources/toonz/svncleanupdialog.h +++ b/toonz/sources/toonz/svncleanupdialog.h @@ -6,14 +6,12 @@ #include "toonzqt/dvdialog.h" #include "versioncontrol.h" -using namespace DVGui; - class QPushButton; class QLabel; //----------------------------------------------------------------------------- -class SVNCleanupDialog : public Dialog +class SVNCleanupDialog : public DVGui::Dialog { Q_OBJECT @@ -31,6 +29,4 @@ protected slots: void onError(const QString &); }; -using namespace DVGui; - #endif // SVN_CLEANUP_DIALOG_H diff --git a/toonz/sources/toonz/svncommitdialog.h b/toonz/sources/toonz/svncommitdialog.h index c47812f..8f8f47f 100644 --- a/toonz/sources/toonz/svncommitdialog.h +++ b/toonz/sources/toonz/svncommitdialog.h @@ -10,8 +10,6 @@ #include #include -using namespace DVGui; - class QLabel; class QPushButton; class QTreeWidget; @@ -24,7 +22,7 @@ class TXshLevel; //----------------------------------------------------------------------------- -class SVNCommitDialog : public Dialog +class SVNCommitDialog : public DVGui::Dialog { Q_OBJECT @@ -119,7 +117,7 @@ signals: //----------------------------------------------------------------------------- -class SVNCommitFrameRangeDialog : public Dialog +class SVNCommitFrameRangeDialog : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/svndeletedialog.h b/toonz/sources/toonz/svndeletedialog.h index f10dce0..9986950 100644 --- a/toonz/sources/toonz/svndeletedialog.h +++ b/toonz/sources/toonz/svndeletedialog.h @@ -6,8 +6,6 @@ #include "toonzqt/dvdialog.h" #include "versioncontrol.h" -using namespace DVGui; - class QLabel; class QPushButton; class QCheckBox; @@ -17,7 +15,7 @@ class QFile; //----------------------------------------------------------------------------- -class SVNDeleteDialog : public Dialog +class SVNDeleteDialog : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/svnlockdialog.h b/toonz/sources/toonz/svnlockdialog.h index 5818f4e..b2f75aa 100644 --- a/toonz/sources/toonz/svnlockdialog.h +++ b/toonz/sources/toonz/svnlockdialog.h @@ -8,8 +8,6 @@ #include -using namespace DVGui; - class QLabel; class QPushButton; class QCheckBox; @@ -19,7 +17,7 @@ class QFile; //----------------------------------------------------------------------------- -class SVNLockDialog : public Dialog +class SVNLockDialog : public DVGui::Dialog { Q_OBJECT @@ -79,7 +77,7 @@ signals: //----------------------------------------------------------------------------- -class SVNLockInfoDialog : public Dialog +class SVNLockInfoDialog : public DVGui::Dialog { Q_OBJECT SVNStatus m_status; diff --git a/toonz/sources/toonz/svnlockframerangedialog.cpp b/toonz/sources/toonz/svnlockframerangedialog.cpp index 8d38a15..2e09230 100644 --- a/toonz/sources/toonz/svnlockframerangedialog.cpp +++ b/toonz/sources/toonz/svnlockframerangedialog.cpp @@ -66,12 +66,12 @@ SVNLockFrameRangeDialog::SVNLockFrameRangeDialog(QWidget *parent, m_toLabel->setMaximumWidth(60); m_toLabel->hide(); - m_fromLineEdit = new IntLineEdit; + m_fromLineEdit = new DVGui::IntLineEdit; m_fromLineEdit->setRange(1, frameCount); m_fromLineEdit->hide(); connect(m_fromLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onFromLineEditTextChanged())); - m_toLineEdit = new IntLineEdit; + m_toLineEdit = new DVGui::IntLineEdit; m_toLineEdit->setRange(1, frameCount); m_toLineEdit->hide(); m_toLineEdit->setValue(frameCount); @@ -391,12 +391,12 @@ SVNLockMultiFrameRangeDialog::SVNLockMultiFrameRangeDialog(QWidget *parent, int frameCount = m_files.size(); - m_fromLineEdit = new IntLineEdit; + m_fromLineEdit = new DVGui::IntLineEdit; m_fromLineEdit->setRange(1, frameCount); m_fromLineEdit->hide(); connect(m_fromLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onFromLineEditTextChanged())); - m_toLineEdit = new IntLineEdit; + m_toLineEdit = new DVGui::IntLineEdit; m_toLineEdit->setRange(1, frameCount); m_toLineEdit->hide(); m_toLineEdit->setValue(frameCount); diff --git a/toonz/sources/toonz/svnlockframerangedialog.h b/toonz/sources/toonz/svnlockframerangedialog.h index 518a033..cf64552 100644 --- a/toonz/sources/toonz/svnlockframerangedialog.h +++ b/toonz/sources/toonz/svnlockframerangedialog.h @@ -9,15 +9,13 @@ #include -using namespace DVGui; - class QLabel; class QPushButton; class QPlainTextEdit; //----------------------------------------------------------------------------- -class SVNLockFrameRangeDialog : public Dialog +class SVNLockFrameRangeDialog : public DVGui::Dialog { Q_OBJECT @@ -29,8 +27,8 @@ class SVNLockFrameRangeDialog : public Dialog QLabel *m_fromLabel; QLabel *m_toLabel; - IntLineEdit *m_fromLineEdit; - IntLineEdit *m_toLineEdit; + DVGui::IntLineEdit *m_fromLineEdit; + DVGui::IntLineEdit *m_toLineEdit; QPushButton *m_lockButton; QPushButton *m_cancelButton; @@ -77,7 +75,7 @@ signals: //----------------------------------------------------------------------------- -class SVNLockMultiFrameRangeDialog : public Dialog +class SVNLockMultiFrameRangeDialog : public DVGui::Dialog { Q_OBJECT @@ -89,8 +87,8 @@ class SVNLockMultiFrameRangeDialog : public Dialog QLabel *m_fromLabel; QLabel *m_toLabel; - IntLineEdit *m_fromLineEdit; - IntLineEdit *m_toLineEdit; + DVGui::IntLineEdit *m_fromLineEdit; + DVGui::IntLineEdit *m_toLineEdit; QPushButton *m_lockButton; QPushButton *m_cancelButton; @@ -134,7 +132,7 @@ signals: //----------------------------------------------------------------------------- -class SVNUnlockFrameRangeDialog : public Dialog +class SVNUnlockFrameRangeDialog : public DVGui::Dialog { Q_OBJECT @@ -180,7 +178,7 @@ signals: //----------------------------------------------------------------------------- -class SVNUnlockMultiFrameRangeDialog : public Dialog +class SVNUnlockMultiFrameRangeDialog : public DVGui::Dialog { Q_OBJECT @@ -222,7 +220,7 @@ signals: //----------------------------------------------------------------------------- -class SVNFrameRangeLockInfoDialog : public Dialog +class SVNFrameRangeLockInfoDialog : public DVGui::Dialog { Q_OBJECT @@ -245,7 +243,7 @@ protected slots: //----------------------------------------------------------------------------- -class SVNMultiFrameRangeLockInfoDialog : public Dialog +class SVNMultiFrameRangeLockInfoDialog : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/svnpurgedialog.h b/toonz/sources/toonz/svnpurgedialog.h index 4f6416b..d46bfab 100644 --- a/toonz/sources/toonz/svnpurgedialog.h +++ b/toonz/sources/toonz/svnpurgedialog.h @@ -7,14 +7,12 @@ #include "versioncontrol.h" #include -using namespace DVGui; - class QPushButton; class QLabel; //----------------------------------------------------------------------------- -class SVNPurgeDialog : public Dialog +class SVNPurgeDialog : public DVGui::Dialog { Q_OBJECT @@ -49,6 +47,4 @@ signals: void done(const QStringList &); }; -using namespace DVGui; - #endif // SVN_PURGE_DIALOG_H diff --git a/toonz/sources/toonz/svnrevertdialog.h b/toonz/sources/toonz/svnrevertdialog.h index aaf884d..ae4f3b4 100644 --- a/toonz/sources/toonz/svnrevertdialog.h +++ b/toonz/sources/toonz/svnrevertdialog.h @@ -8,15 +8,13 @@ #include -using namespace DVGui; - class QPushButton; class QTreeWidget; class QCheckBox; //----------------------------------------------------------------------------- -class SVNRevertDialog : public Dialog +class SVNRevertDialog : public DVGui::Dialog { Q_OBJECT @@ -75,7 +73,7 @@ signals: //----------------------------------------------------------------------------- -class SVNRevertFrameRangeDialog : public Dialog +class SVNRevertFrameRangeDialog : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/svnupdateandlockdialog.h b/toonz/sources/toonz/svnupdateandlockdialog.h index 7030762..00e0c2f 100644 --- a/toonz/sources/toonz/svnupdateandlockdialog.h +++ b/toonz/sources/toonz/svnupdateandlockdialog.h @@ -8,8 +8,6 @@ #include -using namespace DVGui; - class QLabel; class QPushButton; class QPlainTextEdit; @@ -17,7 +15,7 @@ class QCheckBox; //----------------------------------------------------------------------------- -class SVNUpdateAndLockDialog : public Dialog +class SVNUpdateAndLockDialog : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/svnupdatedialog.h b/toonz/sources/toonz/svnupdatedialog.h index 8156f38..ce9ca3f 100644 --- a/toonz/sources/toonz/svnupdatedialog.h +++ b/toonz/sources/toonz/svnupdatedialog.h @@ -8,8 +8,6 @@ #include -using namespace DVGui; - class QLabel; class QPushButton; class DateChooserWidget; @@ -19,7 +17,7 @@ class QCheckBox; //----------------------------------------------------------------------------- -class SVNUpdateDialog : public Dialog +class SVNUpdateDialog : public DVGui::Dialog { Q_OBJECT diff --git a/toonz/sources/toonz/tapp.cpp b/toonz/sources/toonz/tapp.cpp index 5576387..104a1b8 100644 --- a/toonz/sources/toonz/tapp.cpp +++ b/toonz/sources/toonz/tapp.cpp @@ -183,7 +183,7 @@ TApp::TApp() if (preferences->isRasterOptimizedMemory()) { if (!TBigMemoryManager::instance()->init((int)(/*15*1024*/ TSystem::getFreeMemorySize(true) * .8))) - MsgBox(DVGui::WARNING, tr("Error allocating memory: not enough memory.")); + DVGui::warning(tr("Error allocating memory: not enough memory.")); } ret = ret && connect(preferences, SIGNAL(stopAutoSave()), SLOT(onStopAutoSave())); ret = ret && connect(preferences, SIGNAL(startAutoSave()), SLOT(onStartAutoSave())); @@ -672,7 +672,7 @@ void TApp::autosave() m_autosaveSuspended = false; if (scene->isUntitled()) { - MsgBox(DVGui::WARNING, tr("It is not possible to save automatically an untitled scene.")); + DVGui::warning(tr("It is not possible to save automatically an untitled scene.")); return; } diff --git a/toonz/sources/toonz/tasksviewer.cpp b/toonz/sources/toonz/tasksviewer.cpp index 436e192..e6e7fd8 100644 --- a/toonz/sources/toonz/tasksviewer.cpp +++ b/toonz/sources/toonz/tasksviewer.cpp @@ -1271,7 +1271,7 @@ void TaskTreeModel::start(bool) BatchesController::instance()->start(task->m_id); } } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); } emit layoutChanged(); @@ -1304,7 +1304,7 @@ void TaskTreeModel::stop(bool) BatchesController::instance()->stop(task->m_id); } } catch (TException &e) { - MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); + DVGui::warning(QString::fromStdString(toString(e.getMessage()))); } emit layoutChanged(); diff --git a/toonz/sources/toonz/timestretchpopup.cpp b/toonz/sources/toonz/timestretchpopup.cpp index 13ea0e3..c9d4777 100644 --- a/toonz/sources/toonz/timestretchpopup.cpp +++ b/toonz/sources/toonz/timestretchpopup.cpp @@ -1,4 +1,4 @@ - +#include #include "timestretchpopup.h" @@ -44,7 +44,7 @@ class TimeStretchUndo : public TUndo int m_r0, m_r1; int m_c0, m_c1; int m_newRange; - TXshCell *m_cells; + std::unique_ptr m_cells; //servono per modificare la selezione TimeStretchPopup::STRETCH_TYPE m_type; @@ -53,12 +53,12 @@ class TimeStretchUndo : public TUndo public: TimeStretchUndo(int r0, int c0, int r1, int c1, int newRange, TimeStretchPopup::STRETCH_TYPE type) - : m_r0(r0), m_c0(c0), m_r1(r1), m_c1(c1), m_newRange(newRange), m_cells(0), m_type(type), m_c0Old(0), m_c1Old(0) + : m_r0(r0), m_c0(c0), m_r1(r1), m_c1(c1), m_newRange(newRange), m_type(type), m_c0Old(0), m_c1Old(0) { int nr = m_r1 - m_r0 + 1; int nc = m_c1 - m_c0 + 1; assert(nr > 0 && nc > 0); - m_cells = new TXshCell[nr * nc]; + m_cells.reset(new TXshCell[nr * nc]); assert(m_cells); int k = 0; for (int c = c0; c <= c1; c++) @@ -68,8 +68,6 @@ public: ~TimeStretchUndo() { - delete[] m_cells; - m_cells = 0; } void setOldColumnRange(int c0, int c1) @@ -235,7 +233,7 @@ TimeStretchPopup::TimeStretchPopup() m_oldRange->setFixedSize(43, DVGui::WidgetHeight); rangeLayout->addWidget(m_oldRange); rangeLayout->addSpacing(10); - m_newRangeFld = new IntLineEdit(this); + m_newRangeFld = new DVGui::IntLineEdit(this); rangeLayout->addWidget(new QLabel(tr("New Range:")), 1, Qt::AlignRight); rangeLayout->addWidget(m_newRangeFld, 0, Qt::AlignRight); addLayout(tr("Old Range:"), rangeLayout); diff --git a/toonz/sources/toonz/timestretchpopup.h b/toonz/sources/toonz/timestretchpopup.h index fbf750b..6046c3b 100644 --- a/toonz/sources/toonz/timestretchpopup.h +++ b/toonz/sources/toonz/timestretchpopup.h @@ -14,13 +14,11 @@ class QLabel; class QComboBox; class TSelection; -using namespace DVGui; - //============================================================================= // TimeStretchPopup //----------------------------------------------------------------------------- -class TimeStretchPopup : public Dialog +class TimeStretchPopup : public DVGui::Dialog { Q_OBJECT @@ -28,7 +26,7 @@ class TimeStretchPopup : public Dialog QPushButton *m_cancelBtn; QComboBox *m_stretchType; - IntLineEdit *m_newRangeFld; + DVGui::IntLineEdit *m_newRangeFld; QLabel *m_oldRange; public: diff --git a/toonz/sources/toonz/tpanels.cpp b/toonz/sources/toonz/tpanels.cpp index 18e590d..0d0671f 100644 --- a/toonz/sources/toonz/tpanels.cpp +++ b/toonz/sources/toonz/tpanels.cpp @@ -274,7 +274,7 @@ public: { TFx *currentFx = TApp::instance()->getCurrentFx()->getFx(); if (!currentFx) { - MsgBox(WARNING, "Preview Fx : No Current Fx !"); + DVGui::warning("Preview Fx : No Current Fx !"); return; } /*-- @@ -284,7 +284,7 @@ public: TPaletteColumnFx *pfx = dynamic_cast(currentFx); TOutputFx *ofx = dynamic_cast(currentFx); if (pfx || ofx) { - MsgBox(WARNING, "Preview Fx command is not available on Palette or Output node !"); + DVGui::warning("Preview Fx command is not available on Palette or Output node !"); return; } @@ -660,7 +660,7 @@ ColorFieldEditorController::ColorFieldEditorController() //----------------------------------------------------------------------------- -void ColorFieldEditorController::edit(ColorField *colorField) +void ColorFieldEditorController::edit(DVGui::ColorField *colorField) { if (m_currentColorField && m_currentColorField->isEditing()) m_currentColorField->setIsEditing(false); @@ -729,7 +729,7 @@ CleanupColorFieldEditorController::CleanupColorFieldEditorController() //----------------------------------------------------------------------------- -void CleanupColorFieldEditorController::edit(CleanupColorField *colorField) +void CleanupColorFieldEditorController::edit(DVGui::CleanupColorField *colorField) { if (m_currentColorField && m_currentColorField->isEditing()) m_currentColorField->setIsEditing(false); diff --git a/toonz/sources/toonz/trackerpopup.cpp b/toonz/sources/toonz/trackerpopup.cpp index d046a81..6c997e2 100644 --- a/toonz/sources/toonz/trackerpopup.cpp +++ b/toonz/sources/toonz/trackerpopup.cpp @@ -234,7 +234,7 @@ bool TrackerPopup::apply() m_tracker = new Tracker(threshold, sensibility, activeBackground, manageOcclusion, variationWindow, frameStart, framesNumber); if (m_tracker->getLastError() != 0) { - DVGui::MsgBox(WARNING, m_tracker->getLastError()); + DVGui::warning(m_tracker->getLastError()); return false; } @@ -402,40 +402,40 @@ bool Tracker::setup() } //ID object - short *id = new short[m_trackerCount]; + std::unique_ptr id(new short[m_trackerCount]); if (!id) { m_lastErrorCode = 1; return false; } //(x,y) coordinate object - short *x = new short[m_trackerCount]; + std::unique_ptr x(new short[m_trackerCount]); if (!x) { m_lastErrorCode = 1; return false; } - short *y = new short[m_trackerCount]; + std::unique_ptr y(new short[m_trackerCount]); if (!y) { m_lastErrorCode = 1; return false; } //Width and Height of object box - short *Width = new short[m_trackerCount]; + std::unique_ptr Width(new short[m_trackerCount]); if (!Width) { m_lastErrorCode = 1; return false; } - short *Height = new short[m_trackerCount]; + std::unique_ptr Height(new short[m_trackerCount]); if (!Height) { m_lastErrorCode = 1; return false; } //# start frame - m_numstart = new int[m_trackerCount]; + std::unique_ptr m_numstart(new int[m_trackerCount]); if (!m_numstart) { m_lastErrorCode = 1; return false; @@ -628,11 +628,6 @@ bool Tracker::setup() m_trackerRegionIndex = 0; m_oldObjectId = 0; - delete[] x; - delete[] y; - delete[] Width; - delete[] Height; - delete[] id; return true; } diff --git a/toonz/sources/toonz/versioncontrol.cpp b/toonz/sources/toonz/versioncontrol.cpp index 6b4d700..4a27dde 100644 --- a/toonz/sources/toonz/versioncontrol.cpp +++ b/toonz/sources/toonz/versioncontrol.cpp @@ -486,7 +486,7 @@ void VersionControlManager::onError(const QString &text) m_levelSet = 0; } m_scene = 0; - DVGui::MsgBox(WARNING, text); + DVGui::warning(text); } //============================================================================= @@ -543,7 +543,7 @@ bool VersionControl::testSetup() // Test configuration file if (repositoriesCount == 0) { - MsgBox(CRITICAL, tr("The version control configuration file is empty or wrongly defined.\nPlease refer to the user guide for details.")); + DVGui::error(tr("The version control configuration file is empty or wrongly defined.\nPlease refer to the user guide for details.")); return false; } @@ -554,7 +554,7 @@ bool VersionControl::testSetup() if (!path.isEmpty() && !QFile::exists(path + "/svn.exe")) #endif { - MsgBox(CRITICAL, tr("The version control client application specified on the configuration file cannot be found.\nPlease refer to the user guide for details.")); + DVGui::error(tr("The version control client application specified on the configuration file cannot be found.\nPlease refer to the user guide for details.")); return false; } @@ -571,12 +571,12 @@ bool VersionControl::testSetup() p.start("svn", QStringList("--version")); if (!p.waitForStarted()) { - MsgBox(CRITICAL, tr("The version control client application is not installed on your computer.\nSubversion 1.5 or later is required.\nPlease refer to the user guide for details.")); + DVGui::error(tr("The version control client application is not installed on your computer.\nSubversion 1.5 or later is required.\nPlease refer to the user guide for details.")); return false; } if (!p.waitForFinished()) { - MsgBox(CRITICAL, tr("The version control client application is not installed on your computer.\nSubversion 1.5 or later is required.\nPlease refer to the user guide for details.")); + DVGui::error(tr("The version control client application is not installed on your computer.\nSubversion 1.5 or later is required.\nPlease refer to the user guide for details.")); return false; } @@ -590,7 +590,7 @@ bool VersionControl::testSetup() double version = firstLine.left(3).toDouble(); if (version <= 1.5) { - MsgBox(WARNING, tr("The version control client application installed on your computer needs to be updated, otherwise some features may not be available.\nSubversion 1.5 or later is required.\nPlease refer to the user guide for details.")); + DVGui::warning(tr("The version control client application installed on your computer needs to be updated, otherwise some features may not be available.\nSubversion 1.5 or later is required.\nPlease refer to the user guide for details.")); return true; } } diff --git a/toonz/sources/toonz/viewerpane.h b/toonz/sources/toonz/viewerpane.h index 17958f1..c3079db 100644 --- a/toonz/sources/toonz/viewerpane.h +++ b/toonz/sources/toonz/viewerpane.h @@ -19,8 +19,6 @@ class QButtonGroup; class QToolBar; class Ruler; -using namespace DVGui; - //============================================================================= // ViewerPanel //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp index 5225407..b771c3f 100644 --- a/toonz/sources/toonz/xshcellviewer.cpp +++ b/toonz/sources/toonz/xshcellviewer.cpp @@ -1048,7 +1048,7 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference) isRed = true; p.setPen(isRed ? m_viewer->getSelectedColumnTextColor() : m_viewer->getTextColor()); -#ifdef WIN32 +#ifdef _WIN32 static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); #else static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); @@ -1256,7 +1256,7 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col, bool isReference) p.setPen(isRed ? m_viewer->getSelectedColumnTextColor() : m_viewer->getTextColor()); // il nome va scritto se e' diverso dalla cella precedente oppure se // siamo su una marker line -#ifndef WIN32 +#ifndef _WIN32 static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); #else static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp index c5e60e9..dacc690 100644 --- a/toonz/sources/toonz/xshcolumnviewer.cpp +++ b/toonz/sources/toonz/xshcolumnviewer.cpp @@ -597,7 +597,7 @@ void ColumnArea::drawLevelColumnHead(QPainter &p, int col) TColumnSelection *selection = m_viewer->getColumnSelection(); // Preparing painter -#ifdef WIN32 +#ifdef _WIN32 QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); #else QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); @@ -942,7 +942,7 @@ void ColumnArea::drawPaletteColumnHead(QPainter &p, int col) { TColumnSelection *selection = m_viewer->getColumnSelection(); -#ifdef WIN32 +#ifdef _WIN32 QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); #else QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); @@ -1314,7 +1314,7 @@ ColumnTransparencyPopup::ColumnTransparencyPopup(QWidget *parent) m_slider->setFixedHeight(14); m_slider->setFixedWidth(100); - m_value = new IntLineEdit(this, 1, 1, 100); + m_value = new DVGui::IntLineEdit(this, 1, 1, 100); /*m_value->setValidator(new QIntValidator (1, 100, m_value)); m_value->setFixedHeight(16); m_value->setFixedWidth(30); diff --git a/toonz/sources/toonz/xsheetcmd.cpp b/toonz/sources/toonz/xsheetcmd.cpp index fa58b0b..bbdc181 100644 --- a/toonz/sources/toonz/xsheetcmd.cpp +++ b/toonz/sources/toonz/xsheetcmd.cpp @@ -1683,7 +1683,7 @@ void PrintXsheetCommand::execute() copyCss(fp); QString str = QObject::tr("The %1 file has been generated").arg(toQString(fp)); - MsgBox(WARNING, str); + DVGui::warning(str); TSystem::showDocument(fp); } diff --git a/toonz/sources/toonz/xsheetviewer.h b/toonz/sources/toonz/xsheetviewer.h index b40f36f..464826a 100644 --- a/toonz/sources/toonz/xsheetviewer.h +++ b/toonz/sources/toonz/xsheetviewer.h @@ -13,7 +13,7 @@ #include "cellkeyframeselection.h" #include "toonzqt/spreadsheetviewer.h" -#ifdef WIN32 +#ifdef _WIN32 #define XSHEET_FONT_SIZE 9 #define H_ADJUST 2 #else diff --git a/toonz/sources/toonz/xshnoteviewer.cpp b/toonz/sources/toonz/xshnoteviewer.cpp index de0fd86..38a151b 100644 --- a/toonz/sources/toonz/xshnoteviewer.cpp +++ b/toonz/sources/toonz/xshnoteviewer.cpp @@ -366,7 +366,10 @@ void NotePopup::onXsheetSwitched() //----------------------------------------------------------------------------- NoteWidget::NoteWidget(XsheetViewer *parent, int noteIndex) - : QWidget(parent), m_viewer(parent), m_noteIndex(noteIndex), m_noteEditor(0), m_isHovered(false) + : QWidget(parent) + , m_viewer(parent) + , m_noteIndex(noteIndex) + , m_isHovered(false) { int width = (m_noteIndex < 0) ? 40 : NoteWidth; setFixedSize(width, NoteHeight); @@ -427,13 +430,16 @@ void NoteWidget::paint(QPainter *painter, QPoint pos, bool isCurrent) void NoteWidget::openNotePopup() { - if (!m_noteEditor) - m_noteEditor = new XsheetGUI::NotePopup(m_viewer, m_noteIndex); + if (!m_noteEditor) { + m_noteEditor.reset(new XsheetGUI::NotePopup(m_viewer, m_noteIndex)); + } - if (m_noteEditor->isVisible()) + if (m_noteEditor->isVisible()) { m_noteEditor->activateWindow(); - else + } + else { m_noteEditor->show(); + } } //----------------------------------------------------------------------------- @@ -453,7 +459,8 @@ NoteArea::NoteArea(XsheetViewer *parent, Qt::WindowFlags flags) #else NoteArea::NoteArea(XsheetViewer *parent, Qt::WFlags flags) #endif - : QFrame(parent), m_newNotePopup(0), m_viewer(parent) + : QFrame(parent) + , m_viewer(parent) { setFrameStyle(QFrame::StyledPanel); setObjectName("cornerWidget"); @@ -558,12 +565,14 @@ void NoteArea::updateButtons() void NoteArea::toggleNewNote() { if (!m_newNotePopup) - m_newNotePopup = new XsheetGUI::NotePopup(m_viewer, -1); + m_newNotePopup.reset(new XsheetGUI::NotePopup(m_viewer, -1)); - if (m_newNotePopup->isVisible()) + if (m_newNotePopup->isVisible()) { m_newNotePopup->activateWindow(); - else + } + else { m_newNotePopup->show(); + } } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/xshnoteviewer.h b/toonz/sources/toonz/xshnoteviewer.h index 6d177a6..255e1d0 100644 --- a/toonz/sources/toonz/xshnoteviewer.h +++ b/toonz/sources/toonz/xshnoteviewer.h @@ -1,8 +1,8 @@ - - #ifndef XSHNOTEVIEWER_H #define XSHNOTEVIEWER_H +#include + #include "toonz/txsheet.h" #include "toonzqt/dvdialog.h" #include "toonzqt/dvtextedit.h" @@ -87,15 +87,11 @@ class NoteWidget : public QWidget Q_OBJECT XsheetViewer *m_viewer; int m_noteIndex; - NotePopup *m_noteEditor; + std::unique_ptr m_noteEditor; bool m_isHovered; public: NoteWidget(XsheetViewer *parent = 0, int noteIndex = -1); - ~NoteWidget() - { - delete m_noteEditor; - } int getNoteIndex() const { return m_noteIndex; } void setNoteIndex(int index) @@ -121,7 +117,7 @@ class NoteArea : public QFrame { Q_OBJECT - NotePopup *m_newNotePopup; //Popup used to create new note + std::unique_ptr m_newNotePopup; //Popup used to create new note XsheetViewer *m_viewer; QToolButton *m_nextNoteButton; @@ -135,10 +131,6 @@ public: #else NoteArea(XsheetViewer *parent = 0, Qt::WFlags flags = 0); #endif - ~NoteArea() - { - delete m_newNotePopup; - } void updatePopup() { diff --git a/toonz/sources/toonz/xshrowviewer.cpp b/toonz/sources/toonz/xshrowviewer.cpp index 4cf5860..c53fe61 100644 --- a/toonz/sources/toonz/xshrowviewer.cpp +++ b/toonz/sources/toonz/xshrowviewer.cpp @@ -71,7 +71,7 @@ void RowArea::drawRows(QPainter &p, int r0, int r1) playR0 = 0; } -#ifdef WIN32 +#ifdef _WIN32 static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Bold); #else static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); diff --git a/toonz/sources/toonzfarm/include/service.h b/toonz/sources/toonzfarm/include/service.h index 5e20d3d..5751836 100644 --- a/toonz/sources/toonzfarm/include/service.h +++ b/toonz/sources/toonzfarm/include/service.h @@ -7,7 +7,6 @@ class TFilePath; #include #include -using namespace std; //------------------------------------------------------------------------------ @@ -15,7 +14,7 @@ using namespace std; #undef TFARMAPI #endif -#ifdef WIN32 +#ifdef _WIN32 #ifdef TFARM_EXPORTS #define TFARMAPI __declspec(dllexport) #else @@ -35,14 +34,14 @@ void AddToMessageLog(char *msg); //------------------------------------------------------------------------------ -TFARMAPI string getLastErrorText(); +TFARMAPI std::string getLastErrorText(); //------------------------------------------------------------------------------ class TFARMAPI TService { public: - TService(const string &name, const string &displayName); + TService(const std::string &name, const std::string &displayName); virtual ~TService(); static TService *instance(); @@ -59,8 +58,8 @@ public: void setStatus(Status status, long exitCode, long waitHint); - string getName() const; - string getDisplayName() const; + std::string getName() const; + std::string getDisplayName() const; void run(int argc, char *argv[], bool console = false); @@ -69,17 +68,17 @@ public: bool isRunningAsConsoleApp() const; - static void start(const string &name); - static void stop(const string &name); + static void start(const std::string &name); + static void stop(const std::string &name); static void install( - const string &name, - const string &displayName, + const std::string &name, + const std::string &displayName, const TFilePath &appPath); - static void remove(const string &name); + static void remove(const std::string &name); - static void addToMessageLog(const string &msg); + static void addToMessageLog(const std::string &msg); static void addToMessageLog(const QString &msg); private: diff --git a/toonz/sources/toonzfarm/include/tfarmexecutor.h b/toonz/sources/toonzfarm/include/tfarmexecutor.h index b39c0fa..d1c2da7 100644 --- a/toonz/sources/toonzfarm/include/tfarmexecutor.h +++ b/toonz/sources/toonzfarm/include/tfarmexecutor.h @@ -14,7 +14,7 @@ using std::string; #undef TFARMAPI #endif -#ifdef WIN32 +#ifdef _WIN32 #ifdef TFARM_EXPORTS #define TFARMAPI __declspec(dllexport) #else diff --git a/toonz/sources/toonzfarm/include/tfarmproxy.h b/toonz/sources/toonzfarm/include/tfarmproxy.h index cd8c5a8..dd1d955 100644 --- a/toonz/sources/toonzfarm/include/tfarmproxy.h +++ b/toonz/sources/toonzfarm/include/tfarmproxy.h @@ -14,7 +14,7 @@ using std::vector; #include "texception.h" -#ifdef WIN32 +#ifdef _WIN32 #ifdef TFARM_EXPORTS #define TFARMAPI __declspec(dllexport) #else diff --git a/toonz/sources/toonzfarm/include/tlog.h b/toonz/sources/toonzfarm/include/tlog.h index a489eea..ecc6e49 100644 --- a/toonz/sources/toonzfarm/include/tlog.h +++ b/toonz/sources/toonzfarm/include/tlog.h @@ -12,7 +12,7 @@ class TFilePath; #undef TFARMAPI #endif -#ifdef WIN32 +#ifdef _WIN32 #ifdef TFARM_EXPORTS #define TFARMAPI __declspec(dllexport) #else diff --git a/toonz/sources/toonzfarm/tfarm/service.cpp b/toonz/sources/toonzfarm/tfarm/service.cpp index 7fcc4eb..e03e27d 100644 --- a/toonz/sources/toonzfarm/tfarm/service.cpp +++ b/toonz/sources/toonzfarm/tfarm/service.cpp @@ -6,7 +6,7 @@ #include "tfilepath.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include #include @@ -20,7 +20,7 @@ #define SZDEPENDENCIES "" -#ifdef WIN32 +#ifdef _WIN32 //------------------------------------------------------------------------------ @@ -52,14 +52,14 @@ LPTSTR GetLastErrorText(LPTSTR lpszBuf, DWORD dwSize) return lpszBuf; } -#endif // WIN32 +#endif // _WIN32 //------------------------------------------------------------------------------ -string getLastErrorText() +std::string getLastErrorText() { - string errText; -#ifdef WIN32 + std::string errText; +#ifdef _WIN32 char errBuff[256]; errText = GetLastErrorText(errBuff, sizeof(errBuff)); #else @@ -79,7 +79,7 @@ class TService::Imp public: Imp() {} -#ifdef WIN32 +#ifdef _WIN32 static void WINAPI serviceMain(DWORD dwArgc, LPTSTR *lpszArgv); static void WINAPI serviceCtrl(DWORD dwCtrlCode); @@ -89,11 +89,11 @@ public: #endif - string m_name; - string m_displayName; + std::string m_name; + std::string m_displayName; static bool m_console; -#ifdef WIN32 +#ifdef _WIN32 static SERVICE_STATUS_HANDLE m_hService; static SERVICE_STATUS m_ssStatus; // current status of the service static DWORD m_dwErr; @@ -101,7 +101,7 @@ public: #endif }; -#ifdef WIN32 +#ifdef _WIN32 SERVICE_STATUS_HANDLE TService::Imp::m_hService = 0; SERVICE_STATUS TService::Imp::m_ssStatus; DWORD TService::Imp::m_dwErr = 0; @@ -111,7 +111,7 @@ bool TService::Imp::m_console = false; //------------------------------------------------------------------------------ -TService::TService(const string &name, const string &displayName) +TService::TService(const std::string &name, const std::string &displayName) : m_imp(new Imp) { m_imp->m_name = name; @@ -140,7 +140,7 @@ TService *TService::m_instance = 0; void TService::setStatus(Status status, long exitCode, long waitHint) { -#ifdef WIN32 +#ifdef _WIN32 if (!isRunningAsConsoleApp()) TService::Imp::reportStatusToSCMgr(status, exitCode, waitHint); else { @@ -155,21 +155,21 @@ void TService::setStatus(Status status, long exitCode, long waitHint) //------------------------------------------------------------------------------ -string TService::getName() const +std::string TService::getName() const { return m_imp->m_name; } //------------------------------------------------------------------------------ -string TService::getDisplayName() const +std::string TService::getDisplayName() const { return m_imp->m_displayName; } //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 void WINAPI TService::Imp::serviceCtrl(DWORD dwCtrlCode) { @@ -379,7 +379,7 @@ void TService::run(int argc, char *argv[], bool console) #endif */ -#ifdef WIN32 +#ifdef _WIN32 if (console) { _tprintf(TEXT("Starting %s.\n"), TService::instance()->getDisplayName().c_str()); @@ -388,7 +388,7 @@ void TService::run(int argc, char *argv[], bool console) } else { SERVICE_TABLE_ENTRY dispatchTable[2]; - string name = TService::instance()->getName().c_str(); + std::string name = TService::instance()->getName().c_str(); dispatchTable[0].lpServiceName = (char *)name.c_str(); dispatchTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)TService::Imp::serviceMain; @@ -406,13 +406,13 @@ void TService::run(int argc, char *argv[], bool console) //------------------------------------------------------------------------------ -void TService::start(const string &name) +void TService::start(const std::string &name) { } //------------------------------------------------------------------------------ -void TService::stop(const string &name) +void TService::stop(const std::string &name) { } @@ -425,9 +425,9 @@ bool TService::isRunningAsConsoleApp() const //------------------------------------------------------------------------------ -void TService::install(const string &name, const string &displayName, const TFilePath &appPath) +void TService::install(const std::string &name, const std::string &displayName, const TFilePath &appPath) { -#ifdef WIN32 +#ifdef _WIN32 SC_HANDLE schService; SC_HANDLE schSCManager; @@ -467,10 +467,10 @@ void TService::install(const string &name, const string &displayName, const TFil //------------------------------------------------------------------------------ -void TService::remove(const string &name) +void TService::remove(const std::string &name) { -#ifdef WIN32 - string displayName = name; +#ifdef _WIN32 + std::string displayName = name; SC_HANDLE schService; SC_HANDLE schSCManager; @@ -529,9 +529,9 @@ void TService::addToMessageLog(const QString &msg) addToMessageLog(msg.toStdString()); } -void TService::addToMessageLog(const string &msg) +void TService::addToMessageLog(const std::string &msg) { -#ifdef WIN32 +#ifdef _WIN32 TCHAR szMsg[256]; HANDLE hEventSource; LPCTSTR lpszStrings[2]; @@ -561,7 +561,7 @@ void TService::addToMessageLog(const string &msg) (VOID) DeregisterEventSource(hEventSource); } } else { - cout << msg.c_str(); + std::cout << msg.c_str(); } #else if (!TService::Imp::m_console) { diff --git a/toonz/sources/toonzfarm/tfarm/tfarmtask.cpp b/toonz/sources/toonzfarm/tfarm/tfarmtask.cpp index 2e366c9..3c5838f 100644 --- a/toonz/sources/toonzfarm/tfarm/tfarmtask.cpp +++ b/toonz/sources/toonzfarm/tfarm/tfarmtask.cpp @@ -342,7 +342,7 @@ QString getExeName(bool isComposer) { QString name = isComposer ? "tcomposer" : "tcleanup"; -#ifdef WIN32 +#ifdef _WIN32 return name + ".exe "; #else return "\"./Toonz 7.1.app/Contents/MacOS/" + name + "\" "; diff --git a/toonz/sources/toonzfarm/tfarm/tlog.cpp b/toonz/sources/toonzfarm/tfarm/tlog.cpp index 1c7457c..ed687f0 100644 --- a/toonz/sources/toonzfarm/tfarm/tlog.cpp +++ b/toonz/sources/toonzfarm/tfarm/tlog.cpp @@ -5,7 +5,7 @@ #include "tfilepath_io.h" #include -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include #include @@ -33,7 +33,7 @@ enum LEVEL { LEVEL_INFO }; -#ifdef WIN32 +#ifdef _WIN32 WORD Level2WinEventType(LEVEL level) { switch (level) { @@ -71,7 +71,7 @@ int Level2XPriority(LEVEL level) void notify(LEVEL level, const QString &msg) { -#ifdef WIN32 +#ifdef _WIN32 TCHAR buf[_MAX_PATH + 1]; GetModuleFileName(0, buf, _MAX_PATH); diff --git a/toonz/sources/toonzfarm/tfarm/ttcpipclient.cpp b/toonz/sources/toonzfarm/tfarm/ttcpipclient.cpp index 1abe361..0ae72e5 100644 --- a/toonz/sources/toonzfarm/tfarm/ttcpipclient.cpp +++ b/toonz/sources/toonzfarm/tfarm/ttcpipclient.cpp @@ -3,7 +3,7 @@ #include "ttcpip.h" #include "tconvert.h" -#ifdef WIN32 +#ifdef _WIN32 #include #else #include /* obligatory includes */ @@ -17,7 +17,7 @@ #include #endif -#ifndef WIN32 +#ifndef _WIN32 #define SOCKET_ERROR -1 #endif @@ -25,7 +25,7 @@ TTcpIpClient::TTcpIpClient() { -#ifdef WIN32 +#ifdef _WIN32 WSADATA wsaData; WORD wVersionRequested = MAKEWORD(1, 1); int irc = WSAStartup(wVersionRequested, &wsaData); @@ -36,7 +36,7 @@ TTcpIpClient::TTcpIpClient() TTcpIpClient::~TTcpIpClient() { -#ifdef WIN32 +#ifdef _WIN32 WSACleanup(); #endif } @@ -57,7 +57,7 @@ int TTcpIpClient::connect(const QString &hostName, const QString &addrStr, int p struct hostent *he = gethostbyname(hostName.toAscii()); #endif if (!he) { -#ifdef WIN32 +#ifdef _WIN32 int err = WSAGetLastError(); #else #endif @@ -76,7 +76,7 @@ int TTcpIpClient::connect(const QString &hostName, const QString &addrStr, int p if (rcConnect == SOCKET_ERROR) { sock = -1; -#ifdef WIN32 +#ifdef _WIN32 int err = WSAGetLastError(); switch (err) { case WSAECONNREFUSED: @@ -108,7 +108,7 @@ int TTcpIpClient::connect(const string &hostName, const string &addrStr, int por struct hostent *he = gethostbyname (hostName.c_str()); if (!he) { -#ifdef WIN32 +#ifdef _WIN32 int err = WSAGetLastError(); #else #endif @@ -127,7 +127,7 @@ int TTcpIpClient::connect(const string &hostName, const string &addrStr, int por if (rcConnect == SOCKET_ERROR) { sock = -1; -#ifdef WIN32 +#ifdef _WIN32 int err = WSAGetLastError(); switch (err) { @@ -152,7 +152,7 @@ int TTcpIpClient::connect(const string &hostName, const string &addrStr, int por int TTcpIpClient::disconnect(int sock) { -#ifdef WIN32 +#ifdef _WIN32 closesocket(sock); #else close(sock); @@ -178,7 +178,7 @@ int TTcpIpClient::send(int sock, const QString &data) int nLeft = packet.size(); int idx = 0; while (nLeft > 0) { -#ifdef WIN32 +#ifdef _WIN32 int ret = ::send(sock, packet.c_str() + idx, nLeft, 0); #else int ret = write(sock, packet.c_str() + idx, nLeft); @@ -186,7 +186,7 @@ int TTcpIpClient::send(int sock, const QString &data) if (ret == SOCKET_ERROR) { // Error -#ifdef WIN32 +#ifdef _WIN32 int err = WSAGetLastError(); #else #endif @@ -208,7 +208,7 @@ int readData(int sock, QString &data) char buff[1024]; memset(buff, 0, sizeof(buff)); -#ifdef WIN32 +#ifdef _WIN32 if ((cnt = recv(sock, buff, sizeof(buff), 0)) < 0) { int err = WSAGetLastError(); // GESTIRE L'ERRORE SPECIFICO @@ -243,7 +243,7 @@ int readData(int sock, QString &data) while (size > 0) { memset(buff, 0, sizeof(buff)); -#ifdef WIN32 +#ifdef _WIN32 if ((cnt = recv(sock, buff, sizeof(buff), 0)) < 0) { int err = WSAGetLastError(); // GESTIRE L'ERRORE SPECIFICO @@ -286,7 +286,7 @@ int readData(int sock, string &data) { memset (buff,0,sizeof(buff)); -#ifdef WIN32 +#ifdef _WIN32 if (( cnt = recv(sock, buff, sizeof(buff), 0)) < 0 ) { int err = WSAGetLastError(); @@ -327,7 +327,7 @@ int readData(int sock, string &data) do { memset(buff, 0, sizeof(buff)); -#ifdef WIN32 +#ifdef _WIN32 if ((cnt = recv(sock, buff, sizeof(buff), 0)) < 0) { int err = WSAGetLastError(); // GESTIRE L'ERRORE SPECIFICO diff --git a/toonz/sources/toonzfarm/tfarm/ttcpipserver.cpp b/toonz/sources/toonzfarm/tfarm/ttcpipserver.cpp index 8b200ce..d78f8da 100644 --- a/toonz/sources/toonzfarm/tfarm/ttcpipserver.cpp +++ b/toonz/sources/toonzfarm/tfarm/ttcpipserver.cpp @@ -3,7 +3,7 @@ #include "ttcpip.h" #include "tconvert.h" -#ifdef WIN32 +#ifdef _WIN32 #include #else #include /* obligatory includes */ @@ -19,7 +19,7 @@ #include "tthreadmessage.h" #include "tthread.h" -#ifndef WIN32 +#ifndef _WIN32 #define SOCKET_ERROR -1 #endif @@ -62,7 +62,7 @@ int TTcpIpServerImp::readData(int sock, QString &data) char buff[1025]; memset(buff, 0, sizeof(buff)); -#ifdef WIN32 +#ifdef _WIN32 if ((cnt = recv(sock, buff, sizeof(buff) - 1, 0)) < 0) { int err = WSAGetLastError(); // GESTIRE L'ERRORE SPECIFICO @@ -103,7 +103,7 @@ int TTcpIpServerImp::readData(int sock, QString &data) while (size > 0) { memset(buff, 0, sizeof(buff)); -#ifdef WIN32 +#ifdef _WIN32 if ((cnt = recv(sock, buff, sizeof(buff) - 1, 0)) < 0) { int err = WSAGetLastError(); // GESTIRE L'ERRORE SPECIFICO @@ -161,7 +161,7 @@ int TTcpIpServerImp::readData(int sock, string &data) { memset (buff,0,sizeof(buff)); -#ifdef WIN32 +#ifdef _WIN32 if (( cnt = recv(sock, buff, sizeof(buff), 0)) < 0 ) { int err = WSAGetLastError(); @@ -202,7 +202,7 @@ int TTcpIpServerImp::readData(int sock, string &data) do { memset(buff, 0, sizeof(buff)); -#ifdef WIN32 +#ifdef _WIN32 if ((cnt = recv(sock, buff, sizeof(buff), 0)) < 0) { int err = WSAGetLastError(); // GESTIRE L'ERRORE SPECIFICO @@ -246,7 +246,7 @@ TTcpIpServer::TTcpIpServer(int port) { m_imp->m_server = this; -#ifdef WIN32 +#ifdef _WIN32 // Windows Socket startup WSADATA wsaData; WORD wVersionRequested = MAKEWORD(1, 1); @@ -261,7 +261,7 @@ TTcpIpServer::TTcpIpServer(int port) TTcpIpServer::~TTcpIpServer() { if (m_imp->m_s != -1) -#ifdef WIN32 +#ifdef _WIN32 closesocket(m_imp->m_s); WSACleanup(); #else @@ -307,7 +307,7 @@ void DataReader::run() Sthutdown = true; else m_serverImp->onReceive(m_clientSocket, data); -#ifdef WIN32 +#ifdef _WIN32 closesocket(m_clientSocket); #else close(m_clientSocket); @@ -335,7 +335,7 @@ public: void DataReceiver::run() { m_serverImp->onReceive(m_clientSocket, m_data); -#ifdef WIN32 +#ifdef _WIN32 closesocket(m_clientSocket); #else close(m_clientSocket); @@ -347,7 +347,7 @@ void DataReceiver::run() void TTcpIpServer::run() { try { -#ifdef WIN32 +#ifdef _WIN32 int err = establish(m_imp->m_port, m_imp->m_s); if (!err && m_imp->m_s != -1) { @@ -382,7 +382,7 @@ void TTcpIpServer::run() return; } -#else // !WIN32 +#else // !_WIN32 int err = establish(m_imp->m_port, m_imp->m_s); if (!err && m_imp->m_s != -1) { @@ -417,7 +417,7 @@ void TTcpIpServer::run() return; } -#endif // WIN32 +#endif // _WIN32 } catch (...) { m_exitCode = 2000; return; @@ -450,7 +450,7 @@ void TTcpIpServer::sendReply(int socket, const QString &reply) int nLeft = packet.size(); int idx = 0; while (nLeft > 0) { -#ifdef WIN32 +#ifdef _WIN32 int ret = send(socket, packet.c_str() + idx, nLeft, 0); #else int ret = write(socket, packet.c_str() + idx, nLeft); @@ -485,7 +485,7 @@ int establish(unsigned short portnum, int &sock) sa.sin_port = htons(portnum); /* this is our port number */ if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* create socket */ { -#ifdef WIN32 +#ifdef _WIN32 int err = WSAGetLastError(); return err; #else @@ -494,7 +494,7 @@ int establish(unsigned short portnum, int &sock) } if (::bind(sock, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) < 0) { -#ifdef WIN32 +#ifdef _WIN32 int err = WSAGetLastError(); closesocket(sock); return err; @@ -519,7 +519,7 @@ int get_connection(int s) return (t); } -#ifndef WIN32 +#ifndef _WIN32 //----------------------------------------------------------------------- /* as children die we should get catch their returns or else we get * zombies, A Bad Thing. fireman() catches falling children. diff --git a/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp b/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp index 5a9f70f..6f55f56 100644 --- a/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp +++ b/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp @@ -23,7 +23,7 @@ #include using namespace std; -#ifndef WIN32 +#ifndef _WIN32 #include #include #include @@ -39,14 +39,14 @@ int inline STRICMP(const char *a, const char *b) return str.compare(QString(b), Qt::CaseSensitive); } /* -#ifdef WIN32 +#ifdef _WIN32 #define STRICMP stricmp #else #define STRICMP strcasecmp #endif */ -#ifndef WIN32 +#ifndef _WIN32 #define NO_ERROR 0 #endif @@ -59,7 +59,7 @@ TFilePath getGlobalRoot() { TFilePath rootDir; -#ifdef WIN32 +#ifdef _WIN32 TFilePath name(L"SOFTWARE\\OpenToonz\\OpenToonz\\1.0\\FARMROOT"); rootDir = TFilePath(TSystem::getSystemValue(name).toStdString()); #else @@ -94,7 +94,7 @@ TFilePath getLocalRoot() { TFilePath lroot; -#ifdef WIN32 +#ifdef _WIN32 TFilePath name(L"SOFTWARE\\OpenToonz\\OpenToonz\\1.0\\TOONZROOT"); lroot = TFilePath(TSystem::getSystemValue(name).toStdString()) + TFilePath("toonzfarm"); #else @@ -132,7 +132,7 @@ TFilePath getLocalRoot() bool myDoesExists(const TFilePath &fp) { bool exists = false; -#ifdef WIN32 +#ifdef _WIN32 TFileStatus fs(fp); exists = fs.doesExist(); #else @@ -147,7 +147,7 @@ bool myDoesExists(const TFilePath &fp) bool dirExists(const TFilePath &dirFp) { bool exists = false; -#ifdef WIN32 +#ifdef _WIN32 TFileStatus fs(dirFp); exists = fs.isDirectory(); #else @@ -179,7 +179,7 @@ bool isAScript(TFarmTask *task) { return false; //todo per gli script /* -#ifdef WIN32 +#ifdef _WIN32 return task->m_cmdline.contains(".bat"); #else return (task->m_cmdline.contains(".csh")|| @@ -483,7 +483,7 @@ bool doTestConnection(const QString &hostName, const QString &addr, int port) int sock; int ret = client.connect(hostName, addr, port, sock); if (ret == OK) { -#ifdef WIN32 +#ifdef _WIN32 closesocket(sock); #else close(sock); @@ -494,7 +494,7 @@ bool doTestConnection(const QString &hostName, const QString &addr, int port) } //------------------------------------------------------------------------------ -#ifdef WIN32 +#ifdef _WIN32 class ConnectionTest : public TThread::Runnable { public: @@ -521,7 +521,7 @@ void ConnectionTest::run() bool FarmServerProxy::testConnection(int timeout) { -#ifdef WIN32 +#ifdef _WIN32 HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!hEvent) { @@ -550,7 +550,7 @@ bool FarmServerProxy::testConnection(int timeout) int sock; int ret = client.connect(m_hostName, m_addr, m_port, sock); if (ret == OK) { -#ifdef WIN32 +#ifdef _WIN32 closesocket(sock); #else close(sock); @@ -2524,7 +2524,7 @@ int main(int argc, char **argv) if (!usage.parse(argc, argv)) exit(1); -#ifdef WIN32 +#ifdef _WIN32 if (installQualifier.isSelected()) { char szPath[512]; diff --git a/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp b/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp index fc74e17..f0b2b4a 100644 --- a/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp +++ b/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp @@ -22,7 +22,7 @@ #include "tthread.h" -#ifdef WIN32 +#ifdef _WIN32 #include using namespace std; #else @@ -33,7 +33,7 @@ using namespace std; //#define REDIRECT_OUPUT -#ifdef WIN32 +#ifdef _WIN32 #define QUOTE_STR "\"" #define CASMPMETER "casmpmeter.exe" #else @@ -41,7 +41,7 @@ using namespace std; #define CASMPMETER "casmpmeter" #endif -#ifndef WIN32 +#ifndef _WIN32 #define NO_ERROR 0 #endif @@ -66,7 +66,7 @@ TFilePath getGlobalRoot() { TFilePath rootDir; -#ifdef WIN32 +#ifdef _WIN32 TFilePath name(L"SOFTWARE\\OpenToonz\\OpenToonz\\1.0\\FARMROOT"); rootDir = TFilePath(TSystem::getSystemValue(name).toStdString()); #else @@ -101,7 +101,7 @@ TFilePath getLocalRoot() { TFilePath lroot; -#ifdef WIN32 +#ifdef _WIN32 TFilePath name("SOFTWARE\\OpenToonz\\OpenToonz\\1.0\\TOONZROOT"); lroot = TFilePath(TSystem::getSystemValue(name).toStdString()) + TFilePath("toonzfarm"); #else @@ -140,7 +140,7 @@ TFilePath getAppsCfgFilePath() TFilePath getBinRoot() { -#ifdef WIN32 +#ifdef _WIN32 return TSystem::getBinDir(); #else return getLocalRoot() + "bin"; @@ -151,7 +151,7 @@ TFilePath getBinRoot() /* string myGetHostName() { -#ifdef WIN32 +#ifdef _WIN32 return TSystem::getHostName(); #else char hostName[MAXHOSTNAMELEN]; @@ -165,7 +165,7 @@ string myGetHostName() bool dirExists(const TFilePath &dirFp) { bool exists = false; -#ifdef WIN32 +#ifdef _WIN32 TFileStatus fs(dirFp); exists = fs.isDirectory(); #else @@ -180,7 +180,7 @@ bool dirExists(const TFilePath &dirFp) bool myDoesExists(const TFilePath &fp) { bool exists = false; -#ifdef WIN32 +#ifdef _WIN32 TFileStatus fs(fp); exists = fs.doesExist(); #else @@ -217,7 +217,7 @@ public: void onStop(); void loadControllerData(QString &hostName, string &ipAddr, int &port); -#ifdef WIN32 +#ifdef _WIN32 void loadDiskMountingPoints(const TFilePath &fp); void mountDisks(); @@ -421,7 +421,7 @@ void Task::run() // =========== -#ifdef WIN32 +#ifdef _WIN32 if (m_cmdline.contains("runcasm")) service.mountDisks(); #endif @@ -648,7 +648,7 @@ int FarmServer::addTask(const QString &id, const QString &cmdline) int FarmServer::terminateTask(const QString &taskid) { -#ifdef WIN32 +#ifdef _WIN32 HANDLE hJob = OpenJobObject( MAXIMUM_ALLOWED, // access right TRUE, // inheritance state @@ -681,7 +681,7 @@ int FarmServer::getTasks(vector &tasks) void FarmServer::queryHwInfo(HwInfo &hwInfo) { -#ifdef WIN32 +#ifdef _WIN32 MEMORYSTATUS buff; GlobalMemoryStatus(&buff); @@ -790,7 +790,7 @@ bool loadServerData(const QString &hostname, QString &addr, int &port) TFilePath fp = rootDir + "config" + "servers.txt"; -#ifndef WIN32 +#ifndef _WIN32 int acc = access(toString(fp.getWideString()).c_str(), 00); // 00 == solo esistenza bool fileExists = acc != -1; if (!fileExists) @@ -834,7 +834,7 @@ void FarmServerService::onStart(int argc, char *argv[]) // Initialize thread components TThread::init(); -#ifdef WIN32 +#ifdef _WIN32 // DebugBreak(); #endif @@ -950,7 +950,7 @@ void FarmServerService::onStart(int argc, char *argv[]) } catch (TException & /*e*/) { } -#ifdef WIN32 +#ifdef _WIN32 TFilePath diskMountingsFilePath = lRootDir + "config" + "diskmap.cfg"; if (myDoesExists(diskMountingsFilePath)) { loadDiskMountingPoints(diskMountingsFilePath); @@ -1008,7 +1008,7 @@ void FarmServerService::onStart(int argc, char *argv[]) string msg("An error occurred starting the ToonzFarm Server"); msg += "\n"; -#ifdef WIN32 +#ifdef _WIN32 LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | @@ -1051,7 +1051,7 @@ void FarmServerService::onStop() // i dischi vengono montati al primo task di tipo "runcasm" // e smontati allo stop del servizio -#ifdef WIN32 +#ifdef _WIN32 unmountDisks(); #endif @@ -1064,7 +1064,7 @@ void FarmServerService::onStop() } } -#ifdef WIN32 +#ifdef _WIN32 //------------------------------------------------------------------------------ @@ -1210,7 +1210,7 @@ int main(int argc, char **argv) if (!usage.parse(argc, argv)) exit(1); -#ifdef WIN32 +#ifdef _WIN32 if (installQualifier.isSelected()) { char szPath[512]; diff --git a/toonz/sources/toonzlib/cleanupparameters.cpp b/toonz/sources/toonzlib/cleanupparameters.cpp index 5f07208..5692ce6 100644 --- a/toonz/sources/toonzlib/cleanupparameters.cpp +++ b/toonz/sources/toonzlib/cleanupparameters.cpp @@ -12,7 +12,7 @@ #include "cleanuppalette.h" #include "tpalette.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif diff --git a/toonz/sources/toonzlib/sandor_fxs/BlurMatrix.cpp b/toonz/sources/toonzlib/sandor_fxs/BlurMatrix.cpp index 82410be..f1e3d3a 100644 --- a/toonz/sources/toonzlib/sandor_fxs/BlurMatrix.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/BlurMatrix.cpp @@ -3,7 +3,7 @@ // BlurMatrix.cpp: implementation of the CBlurMatrix class. // ////////////////////////////////////////////////////////////////////// -#ifdef WIN32 +#ifdef _WIN32 #include "Windows.h" #else #ifdef __sgi @@ -17,10 +17,12 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); #endif #endif + #include +#include -#include -#include +#include +#include //#include "SError.h" #include "BlurMatrix.h" @@ -199,7 +201,7 @@ void CBlurMatrix::addPath(vector::iterator pBS) //SXYD* xyd= pBS->begin(); int x = xyd->x; int y = xyd->y; - int l = max(abs(x), abs(y)); + int l = std::max(std::abs(x), std::abs(y)); double dx = -(double)x / (double)l; double dy = -(double)y / (double)l; double xx = (double)x + dx; diff --git a/toonz/sources/toonzlib/sandor_fxs/BlurMatrix.h b/toonz/sources/toonzlib/sandor_fxs/BlurMatrix.h index 922a646..00a4306 100644 --- a/toonz/sources/toonzlib/sandor_fxs/BlurMatrix.h +++ b/toonz/sources/toonzlib/sandor_fxs/BlurMatrix.h @@ -16,17 +16,15 @@ #include "SError.h" #include "SDef.h" -using namespace std; - #define NBRS 10 // Number of Random Samples -typedef vector BLURSECTION; +typedef std::vector BLURSECTION; class CBlurMatrix { public: bool m_isSAC; // Stop At Contour bool m_isRS; // Random Sampling - vector m_m[NBRS]; + std::vector m_m[NBRS]; CBlurMatrix() : m_isSAC(false), m_isRS(false){}; CBlurMatrix(const CBlurMatrix &m); //throw(SBlurMatrixError); @@ -36,10 +34,10 @@ public: void createRandom(const double d, const int nb); // throw(SBlurMatrixError); void createEqual(const double d, const int nb); // throw(SBlurMatrixError); - void addPath(vector::iterator pBS); // throw(exception); + void addPath(std::vector::iterator pBS); // throw(exception); void addPath(); // throw(SBlurMatrixError); void print() const; - bool isIn(const vector &m, const SXYD &xyd) const; + bool isIn(const std::vector &m, const SXYD &xyd) const; }; #endif // !defined(AFX_BLURMATRIX_H__8298C171_0035_11D6_B94F_0040F674BE6A__INCLUDED_) diff --git a/toonz/sources/toonzlib/sandor_fxs/CIL.cpp b/toonz/sources/toonzlib/sandor_fxs/CIL.cpp index 564fd85..0991275 100644 --- a/toonz/sources/toonzlib/sandor_fxs/CIL.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/CIL.cpp @@ -3,7 +3,7 @@ // CIL.cpp: implementation of the CCIL class. // ////////////////////////////////////////////////////////////////////// -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif diff --git a/toonz/sources/toonzlib/sandor_fxs/CallCircle.cpp b/toonz/sources/toonzlib/sandor_fxs/CallCircle.cpp index 491d90f..015db27 100644 --- a/toonz/sources/toonzlib/sandor_fxs/CallCircle.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/CallCircle.cpp @@ -27,7 +27,7 @@ int callcircle_xydwCompare(const void *a, const void *b) return 0; } -CCallCircle::CCallCircle(const double r) : m_r(r), m_nb(0), m_c(0) +CCallCircle::CCallCircle(const double r) : m_r(r), m_nb(0) { int rr = (int)r + 1; rr *= 2; @@ -39,7 +39,7 @@ CCallCircle::CCallCircle(const double r) : m_r(r), m_nb(0), m_c(0) return; } - m_c = new SXYDW[dd2]; + m_c.reset(new SXYDW[dd2]); if (!m_c) throw SMemAllocError("in callCircle"); for (int y = -rr; y <= rr; y++) @@ -52,17 +52,14 @@ CCallCircle::CCallCircle(const double r) : m_r(r), m_nb(0), m_c(0) m_nb++; } } - qsort(m_c, m_nb, sizeof(SXYDW), callcircle_xydwCompare); + qsort(m_c.get(), m_nb, sizeof(SXYDW), callcircle_xydwCompare); } void CCallCircle::null() { m_nb = 0; m_r = 0.0; - if (m_c) { - delete[] m_c; - m_c = 0; - } + m_c.reset(); } CCallCircle::~CCallCircle() diff --git a/toonz/sources/toonzlib/sandor_fxs/CallCircle.h b/toonz/sources/toonzlib/sandor_fxs/CallCircle.h index cfbe6e6..66cd369 100644 --- a/toonz/sources/toonzlib/sandor_fxs/CallCircle.h +++ b/toonz/sources/toonzlib/sandor_fxs/CallCircle.h @@ -22,14 +22,14 @@ class CCallCircle { double m_r; int m_nb; - SXYDW *m_c; + std::unique_ptr m_c; void draw(UCHAR *drawB, const int lX, const int lY, const int xx, const int yy, const double r); void null(); public: - CCallCircle() : m_r(0.0), m_nb(0), m_c(0){}; + CCallCircle() : m_r(0.0), m_nb(0) {} CCallCircle(const double r); virtual ~CCallCircle(); void print(); @@ -38,7 +38,7 @@ public: void getCC(CSTColSelPic

&pic, P &col) { int xy = pic.m_lX * pic.m_lY; - UCHAR *pSel = pic.m_sel; + UCHAR *pSel = pic.m_sel.get(); for (int i = 0; i < xy; i++, pSel++) if (*pSel > (UCHAR)0) { P *pPic = pic.m_pic + i; @@ -57,7 +57,7 @@ public: int x = xx + m_c[i].x; int y = yy + m_c[i].y; if (x >= 0 && y >= 0 && x < pic.m_lX && y < pic.m_lY) { - UCHAR *pSel = pic.m_sel + y * pic.m_lX + x; + UCHAR *pSel = pic.m_sel.get() + y * pic.m_lX + x; if (*pSel > (UCHAR)0) { P *pPic = pic.m_pic + y * pic.m_lX + x; col.r = pPic->r; @@ -128,15 +128,14 @@ public: return; try { - UCHAR *drawB = 0; CSTColSelPic

picOri; picOri = pic; if (pic.m_lX > 0 && pic.m_lY > 0) { - drawB = new UCHAR[pic.m_lX * pic.m_lY]; + std::unique_ptr drawB(new UCHAR[pic.m_lX * pic.m_lY]); if (!drawB) throw SMemAllocError("in callCircle"); - memset(drawB, 0, pic.m_lX * pic.m_lY); - UCHAR *pSel = pic.m_sel; + memset(drawB.get(), 0, pic.m_lX * pic.m_lY); + UCHAR *pSel = pic.m_sel.get(); for (int y = 0; y < pic.m_lY; y++) for (int x = 0; x < pic.m_lX; x++, pSel++) if (*pSel > (UCHAR)0) { @@ -144,10 +143,9 @@ public: int rani = I_ROUND(random); int ranii = rani > 0 ? rand() % (2 * rani) - 15 * rani / 8 : 0; q = q * (1.0 + (double)ranii / 100.0); - draw(drawB, pic.m_lX, pic.m_lY, x, y, q); + draw(drawB.get(), pic.m_lX, pic.m_lY, x, y, q); } - setNewContour(picOri, pic, drawB, isOneCC); - delete[] drawB; + setNewContour(picOri, pic, drawB.get(), isOneCC); } } catch (SMemAllocError) { throw; diff --git a/toonz/sources/toonzlib/sandor_fxs/EraseContour.cpp b/toonz/sources/toonzlib/sandor_fxs/EraseContour.cpp index 0dad41b..6378301 100644 --- a/toonz/sources/toonzlib/sandor_fxs/EraseContour.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/EraseContour.cpp @@ -25,14 +25,14 @@ void CEraseContour::null() m_lX = m_lY = 0; m_picUC = 0; m_picUS = 0; - m_sel = 0; + m_sel.reset(); m_ras = 0; m_cil.m_nb = 0; } int CEraseContour::makeSelectionCMAP32() { - UCHAR *pSel = m_sel; + UCHAR *pSel = m_sel.get(); int xy = 0, nbSel = 0; for (int y = 0; y < m_lY; y++) @@ -74,7 +74,7 @@ int CEraseContour::makeSelection(const CCIL &iil) return 0; if (m_lX <= 0 || m_lY <= 0 || !m_sel || !m_ras || !(m_picUC || m_picUS)) return 0; - memset(m_sel, 0, m_lX * m_lY); + memset(m_sel.get(), 0, m_lX * m_lY); if (m_ras->type == RAS_CM32) nb = makeSelectionCMAP32(); if (nb > 0) @@ -90,7 +90,7 @@ int CEraseContour::makeSelection(const CCIL &iil) // 3 - paint color int CEraseContour::makeSelection() { - memset(m_sel, 0, m_lX * m_lY); + memset(m_sel.get(), 0, m_lX * m_lY); if (m_ras->type == RAS_CM32) return makeSelectionCMAP32(); return 0; @@ -116,14 +116,14 @@ int CEraseContour::doIt(const CCIL &iil) void CEraseContour::sel0123To01() { int xy = m_lX * m_lY; - UCHAR *pSel = m_sel; + UCHAR *pSel = m_sel.get(); for (int i = 0; i < xy; i++, pSel++) *pSel = *(pSel) == (UCHAR)1 ? (UCHAR)1 : (UCHAR)0; } void CEraseContour::eraseInkColors() { - UCHAR *pSel = m_sel; + UCHAR *pSel = m_sel.get(); prepareNeighbours(); for (int y = 0; y < m_lY; y++) for (int x = 0; x < m_lX; x++, pSel++) @@ -170,7 +170,7 @@ void CEraseContour::prepareNeighbours() m_neighbours[m_nbNeighbours].w = sqrt((double)(x * x + y * y)); m_nbNeighbours++; } - qsort(m_neighbours, m_nbNeighbours, sizeof(SXYDW), erasecontour_xydwCompare); + qsort(m_neighbours.data(), m_nbNeighbours, sizeof(SXYDW), erasecontour_xydwCompare); } bool CEraseContour::findClosestPaint(const int xx, const int yy, I_PIXEL &ip) @@ -180,7 +180,7 @@ bool CEraseContour::findClosestPaint(const int xx, const int yy, I_PIXEL &ip) int x = xx + m_neighbours[i].x; int y = yy + m_neighbours[i].y; if (x >= 0 && y >= 0 && x < m_lX && y < m_lY) - if (*(m_sel + y * m_lX + x) == (UCHAR)3) { + if (*(m_sel.get() + y * m_lX + x) == (UCHAR)3) { if (m_picUC) { UC_PIXEL *uc = m_picUC + y * m_lX + x; ip.r = (int)uc->r; diff --git a/toonz/sources/toonzlib/sandor_fxs/EraseContour.h b/toonz/sources/toonzlib/sandor_fxs/EraseContour.h index 8d2e26c..61cc816 100644 --- a/toonz/sources/toonzlib/sandor_fxs/EraseContour.h +++ b/toonz/sources/toonzlib/sandor_fxs/EraseContour.h @@ -11,6 +11,9 @@ #pragma once #endif // _MSC_VER > 1000 +#include +#include + #include "STColSelPic.h" #include "toonz4.6/raster.h" #include "SDef.h" @@ -22,10 +25,10 @@ class CEraseContour UC_PIXEL *m_picUC; US_PIXEL *m_picUS; const RASTER *m_ras; - UCHAR *m_sel; + std::shared_ptr m_sel; int m_lX, m_lY; CCIL m_cil; - SXYDW m_neighbours[MAXNB_NEIGHBOURS]; + std::array m_neighbours; int m_nbNeighbours; void null(); @@ -37,8 +40,15 @@ class CEraseContour void sel0123To01(); public: - CEraseContour() : m_picUC(0), m_picUS(0), m_ras(0), m_sel(0), - m_lX(0), m_lY(0), m_cil(){}; + CEraseContour() + : m_picUC(0) + , m_picUS(0) + , m_ras(0) + , m_lX(0) + , m_lY(0) + , m_cil() + { + } virtual ~CEraseContour(); int makeSelection(const CCIL &iil); int doIt(const CCIL &iil); diff --git a/toonz/sources/toonzlib/sandor_fxs/InputParam.h b/toonz/sources/toonzlib/sandor_fxs/InputParam.h index 06cd8be..3e09c15 100644 --- a/toonz/sources/toonzlib/sandor_fxs/InputParam.h +++ b/toonz/sources/toonzlib/sandor_fxs/InputParam.h @@ -11,20 +11,18 @@ #pragma once #endif // _MSC_VER > 1000 -#ifdef WIN32 +#ifdef _WIN32 #include "Windows.h" #endif #include #include -using namespace std; - class CInputParam { public: double m_scale; bool m_isEconf; - basic_string m_econfFN; + std::basic_string m_econfFN; CInputParam() : m_scale(0), m_isEconf(false), m_econfFN(""){}; CInputParam(const CInputParam &p) : m_scale(p.m_scale), m_isEconf(p.m_isEconf), diff --git a/toonz/sources/toonzlib/sandor_fxs/Params.h b/toonz/sources/toonzlib/sandor_fxs/Params.h index 1541b11..f29680e 100644 --- a/toonz/sources/toonzlib/sandor_fxs/Params.h +++ b/toonz/sources/toonzlib/sandor_fxs/Params.h @@ -11,7 +11,7 @@ #pragma once #endif // _MSC_VER > 1000 -#ifdef WIN32 +#ifdef _WIN32 #include "Windows.h" #endif #include @@ -21,13 +21,11 @@ #define P(d) tmsg_info(" - %d -\n", d) -using namespace std; - template class CParams { public: - vector m_params; + std::vector m_params; double m_scale; CParams() : m_params(0), m_scale(1.0){}; diff --git a/toonz/sources/toonzlib/sandor_fxs/Pattern.cpp b/toonz/sources/toonzlib/sandor_fxs/Pattern.cpp index c8ebad3..3d98a54 100644 --- a/toonz/sources/toonzlib/sandor_fxs/Pattern.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/Pattern.cpp @@ -3,7 +3,7 @@ // Pattern.cpp: implementation of the CPattern class. // ////////////////////////////////////////////////////////////////////// -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif @@ -30,7 +30,7 @@ //#define P(a) tmsg_warning("-- %d --",a) -CPattern::CPattern(RASTER *imgContour) : m_lX(0), m_lY(0), m_pat(0) +CPattern::CPattern(RASTER *imgContour) : m_lX(0), m_lY(0) { if (!readPattern(imgContour)) { throw SFileReadError(); @@ -50,10 +50,7 @@ CPattern::~CPattern() void CPattern::null() { m_lX = m_lY = 0; - if (m_pat) { - delete[] m_pat; - m_pat = 0; - } + m_pat.reset(); m_fn[0] = '\0'; } @@ -130,7 +127,7 @@ bool CPattern::readPattern(RASTER *imgContour) if (lpic.m_lX > 0 && lpic.m_lY > 0 && lpic.m_pic) { m_lX = lpic.m_lX; m_lY = lpic.m_lY; - m_pat = new UC_PIXEL[m_lX * m_lY]; + m_pat.reset(new UC_PIXEL[m_lX * m_lY]); if (!m_pat) { m_lX = m_lY = 0; lpic.null(); @@ -140,7 +137,7 @@ bool CPattern::readPattern(RASTER *imgContour) for (int y = 0; y < m_lY; y++) for (int x = 0; x < m_lX; x++) { UC_PIXEL *plp = lpic.m_pic + y * lpic.m_lX + x; - UC_PIXEL *ucp = m_pat + y * m_lX + x; + UC_PIXEL *ucp = m_pat.get() + y * m_lX + x; ucp->r = plp->r; ucp->g = plp->g; ucp->b = plp->b; @@ -169,7 +166,7 @@ void CPattern::getMapPixel(const int xx, const int yy, const double invScale, int x = I_ROUND(d2xx); int y = I_ROUND(d2yy); if (x >= 0 && x < m_lX && y >= 0 && y < m_lY) { - pucp = m_pat + y * m_lX + x; + pucp = m_pat.get() + y * m_lX + x; pucp = (pucp->m) == (UCHAR)0 ? 0 : pucp; } } @@ -183,7 +180,7 @@ void CPattern::getMapPixel(const int xx, const int yy, const double invScale, int x = I_ROUND(dxx); int y = I_ROUND(dyy); if (x >= 0 && x < m_lX && y >= 0 && y < m_lY) { - pucp = m_pat + y * m_lX + x; + pucp = m_pat.get() + y * m_lX + x; pucp = (pucp->m) == (UCHAR)0 ? 0 : pucp; } } @@ -194,7 +191,7 @@ void CPattern::getBBox(SRECT &bb) bb.y0 = m_lY; bb.x1 = -1; bb.y1 = -1; - UC_PIXEL *pPic = m_pat; + UC_PIXEL *pPic = m_pat.get(); for (int y = 0; y < m_lY; y++) for (int x = 0; x < m_lX; x++, pPic++) if (pPic->m > (UCHAR)0) { @@ -213,7 +210,7 @@ void CPattern::optimalizeSize() if (bb.x0 <= bb.x1 && bb.y0 <= bb.y1) { int nLX = bb.x1 - bb.x0 + 1; int nLY = bb.y1 - bb.y0 + 1; - UC_PIXEL *nPat = new UC_PIXEL[nLX * nLY]; + std::unique_ptr nPat(new UC_PIXEL[nLX * nLY]); if (!nPat) { char s[200]; sprintf(s, "in Pattern Optimalization \n"); @@ -221,8 +218,8 @@ void CPattern::optimalizeSize() } for (int y = bb.y0; y <= bb.y1; y++) for (int x = bb.x0; x <= bb.x1; x++) { - UC_PIXEL *pPat = m_pat + y * m_lX + x; - UC_PIXEL *pNPat = nPat + (y - bb.y0) * nLX + x - bb.x0; + UC_PIXEL *pPat = m_pat.get() + y * m_lX + x; + UC_PIXEL *pNPat = nPat.get() + (y - bb.y0) * nLX + x - bb.x0; pNPat->r = pPat->r; pNPat->g = pPat->g; pNPat->b = pPat->b; @@ -230,8 +227,7 @@ void CPattern::optimalizeSize() } m_lX = nLX; m_lY = nLY; - delete[] m_pat; - m_pat = nPat; + m_pat = std::move(nPat); } } @@ -255,15 +251,15 @@ void CPattern::rotate(const double angle) double co = cos(-DEG2RAD(angle)); double si = sin(-DEG2RAD(angle)); - UC_PIXEL *nPat = new UC_PIXEL[nLXY * nLXY]; + std::unique_ptr nPat(new UC_PIXEL[nLXY * nLXY]); if (!nPat) { char s[200]; sprintf(s, "in Pattern Rotation \n"); throw SMemAllocError(s); } - eraseBuffer(nLXY, nLXY, nPat); + eraseBuffer(nLXY, nLXY, nPat.get()); - UC_PIXEL *pNPat = nPat; + UC_PIXEL *pNPat = nPat.get(); for (int y = 0; y < nLXY; y++) for (int x = 0; x < nLXY; x++, pNPat++) { UC_PIXEL *pucp = 0; @@ -276,8 +272,7 @@ void CPattern::rotate(const double angle) } } m_lX = m_lY = nLXY; - delete[] m_pat; - m_pat = nPat; + m_pat = std::move(nPat); try { optimalizeSize(); diff --git a/toonz/sources/toonzlib/sandor_fxs/Pattern.h b/toonz/sources/toonzlib/sandor_fxs/Pattern.h index dd76666..8a3c327 100644 --- a/toonz/sources/toonzlib/sandor_fxs/Pattern.h +++ b/toonz/sources/toonzlib/sandor_fxs/Pattern.h @@ -11,6 +11,7 @@ #pragma once #endif // _MSC_VER > 1000 +#include #include "STColSelPic.h" #include "SDef.h" #include "toonz4.6/pixel.h" @@ -18,7 +19,7 @@ class CPattern { int m_lX, m_lY; - UC_PIXEL *m_pat; + std::unique_ptr m_pat; char m_fn[1024]; void null(); @@ -37,7 +38,7 @@ class CPattern void eraseBuffer(const int lX, const int lY, UC_PIXEL *buffer); public: - CPattern() : m_lX(0), m_lY(0), m_pat(0) { m_fn[0] = '\0'; }; + CPattern() : m_lX(0), m_lY(0) { m_fn[0] = '\0'; }; CPattern(RASTER *imgContour); virtual ~CPattern(); void rotate(const double angle); @@ -50,7 +51,7 @@ public: for (int x = 0; x < m_lX; x++) if ((x + ox) < pic.m_lX && (y + oy) < pic.m_lY) { P *p = pic.m_pic + (y + oy) * pic.m_lX + x + ox; - UC_PIXEL *pP = m_pat + y * m_lX + x; + UC_PIXEL *pP = m_pat.get() + y * m_lX + x; if (pP->m > (UCHAR)0) { double q = ((double)(pP->m) / 255.0) * ((double)eCol.m / 255.0); @@ -132,7 +133,7 @@ public: int x1 = I_ROUND(d2xx); int y1 = I_ROUND(d2yy); if (x1 >= 0 && x1 < m_lX && y1 >= 0 && y1 < m_lY) { - pucp = m_pat + y1 * m_lX + x1; + pucp = m_pat.get() + y1 * m_lX + x1; pucp = (pucp->m) == (UCHAR)0 ? 0 : pucp; } // ---------------------------------------------------- diff --git a/toonz/sources/toonzlib/sandor_fxs/PatternMapParam.cpp b/toonz/sources/toonzlib/sandor_fxs/PatternMapParam.cpp index a2d8f34..74ecf2b 100644 --- a/toonz/sources/toonzlib/sandor_fxs/PatternMapParam.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/PatternMapParam.cpp @@ -4,7 +4,7 @@ // ////////////////////////////////////////////////////////////////////// -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif #include diff --git a/toonz/sources/toonzlib/sandor_fxs/PatternPosition.cpp b/toonz/sources/toonzlib/sandor_fxs/PatternPosition.cpp index 5a9bd42..62879b5 100644 --- a/toonz/sources/toonzlib/sandor_fxs/PatternPosition.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/PatternPosition.cpp @@ -4,10 +4,12 @@ // ////////////////////////////////////////////////////////////////////// -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif +#include + #include #include #include @@ -180,7 +182,6 @@ void CPatternPosition::makeDDPositions(const int lX, const int lY, UCHAR *sel, { const int maxNbDDC = 20; vector ddc[maxNbDDC]; - UCHAR *lSel = 0; // Checking parameters if (lX <= 0 || lY <= 0 || !sel) @@ -202,33 +203,29 @@ void CPatternPosition::makeDDPositions(const int lX, const int lY, UCHAR *sel, throw; } // Preparing local selection - lSel = new UCHAR[lX * lY]; + std::unique_ptr lSel(new UCHAR[lX * lY]); if (!lSel) { char s[50]; sprintf(s, "in Pattern Position Generation"); throw SMemAllocError(s); } - memcpy(lSel, sel, lX * lY * sizeof(UCHAR)); + memcpy(lSel.get(), sel, lX * lY * sizeof(UCHAR)); SRECT bb; - sel0255To01(lX, lY, lSel, bb); + sel0255To01(lX, lY, lSel.get(), bb); if (bb.x0 > bb.x1 || bb.y0 > bb.y1) { - delete[] lSel; return; } try { int x = 0, y = 0; - while (findEmptyPos(lX, lY, lSel, x, y, bb)) { + while (findEmptyPos(lX, lY, lSel.get(), x, y, bb)) { SPOINT sp = {x, y}; m_pos.push_back(sp); int iddc = nbDDC == 1 ? 0 : rand() % nbDDC; - eraseCurrentArea(lX, lY, lSel, ddc[iddc], sp.x, sp.y); + eraseCurrentArea(lX, lY, lSel.get(), ddc[iddc], sp.x, sp.y); } - delete[] lSel; - } catch (exception) { - delete[] lSel; char s[50]; sprintf(s, "in Pattern Position Generation"); throw SMemAllocError(s); diff --git a/toonz/sources/toonzlib/sandor_fxs/PatternPosition.h b/toonz/sources/toonzlib/sandor_fxs/PatternPosition.h index 77a62a0..e0ee507 100644 --- a/toonz/sources/toonzlib/sandor_fxs/PatternPosition.h +++ b/toonz/sources/toonzlib/sandor_fxs/PatternPosition.h @@ -18,8 +18,6 @@ #include "SError.h" #include "SDef.h" -using namespace std; - class CPatternPosition { bool isInSet(const int nbSet, const int *set, const int val); @@ -55,10 +53,10 @@ public: // nbPat= nbPat>(int)(0.9*nbPixel) ? (int)(0.9*nbPixel) : nbPat; nbPat = nbPat > nbPixel ? nbPixel : nbPat; if (nbPat > 0) - makeRandomPositions(nbPat, nbPixel, p.m_lX, p.m_lY, p.m_sel); + makeRandomPositions(nbPat, nbPixel, p.m_lX, p.m_lY, p.m_sel.get()); } else { // Distance-driven position - makeDDPositions(p.m_lX, p.m_lY, p.m_sel, minD, maxD); + makeDDPositions(p.m_lX, p.m_lY, p.m_sel.get(), minD, maxD); } } catch (SMemAllocError) { throw; diff --git a/toonz/sources/toonzlib/sandor_fxs/SDirection.cpp b/toonz/sources/toonzlib/sandor_fxs/SDirection.cpp index 88b3336..3b24878 100644 --- a/toonz/sources/toonzlib/sandor_fxs/SDirection.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/SDirection.cpp @@ -1,4 +1,4 @@ - +#include // SDirection.cpp: implementation of the CSDirection class. // @@ -12,7 +12,7 @@ // Construction/Destruction ////////////////////////////////////////////////////////////////////// -CSDirection::CSDirection() : m_lX(0), m_lY(0), m_dir(0), m_lDf(0) +CSDirection::CSDirection() : m_lX(0), m_lY(0), m_lDf(0) { for (int i = 0; i < NBDIR; i++) m_df[i] = 0; @@ -20,19 +20,19 @@ CSDirection::CSDirection() : m_lX(0), m_lY(0), m_dir(0), m_lDf(0) CSDirection::CSDirection(const int lX, const int lY, const UCHAR *sel, const int sens) - : m_lX(lX), m_lY(lY), m_dir(0), m_lDf(0) + : m_lX(lX), m_lY(lY), m_lDf(0) { for (int i = 0; i < NBDIR; i++) m_df[i] = 0; try { if (m_lX > 0 && m_lY > 0) { - m_dir = new UCHAR[m_lX * m_lY]; + m_dir.reset(new UCHAR[m_lX * m_lY]); if (!m_dir) { null(); throw SMemAllocError("in directionMap"); } - memcpy(m_dir, sel, sizeof(UCHAR) * m_lX * m_lY); + memcpy(m_dir.get(), sel, sizeof(UCHAR) * m_lX * m_lY); setDir01(); // For optimalization purpose. // The quality is better, if it is removed. @@ -46,19 +46,19 @@ CSDirection::CSDirection(const int lX, const int lY, const UCHAR *sel, CSDirection::CSDirection(const int lX, const int lY, const UCHAR *sel, const int sens, const int border) - : m_lX(lX), m_lY(lY), m_dir(0), m_lDf(0) + : m_lX(lX), m_lY(lY), m_lDf(0) { for (int i = 0; i < NBDIR; i++) m_df[i] = 0; try { if (m_lX > 0 && m_lY > 0) { - m_dir = new UCHAR[m_lX * m_lY]; + m_dir.reset(new UCHAR[m_lX * m_lY]); if (!m_dir) { null(); throw SMemAllocError("in directionMap"); } - memcpy(m_dir, sel, sizeof(UCHAR) * m_lX * m_lY); + memcpy(m_dir.get(), sel, sizeof(UCHAR) * m_lX * m_lY); setDir01(); if (border > 0) setContourBorder(border); @@ -75,14 +75,14 @@ bool CSDirection::isContourBorder(const int xx, const int yy, for (int y = yy - border; y <= (yy + border); y++) for (int x = xx - border; x <= (xx + border); x++) if (x >= 0 && y >= 0 && x < m_lX && y < m_lY) - if (*(m_dir + y * m_lX + x) == (UCHAR)0) + if (*(m_dir.get() + y * m_lX + x) == (UCHAR)0) return true; return false; } void CSDirection::setContourBorder(const int border) { - UCHAR *pDir = m_dir; + UCHAR *pDir = m_dir.get(); int y = 0; for (y = 0; y < m_lY; y++) for (int x = 0; x < m_lX; x++, pDir++) @@ -91,22 +91,17 @@ void CSDirection::setContourBorder(const int border) *pDir = (UCHAR)2; int xy = m_lX * m_lY; - pDir = m_dir; + pDir = m_dir.get(); for (y = 0; y < xy; y++, pDir++) *pDir = *pDir == (UCHAR)2 ? (UCHAR)0 : *pDir; } void CSDirection::null() { - if (m_dir) { - delete[] m_dir; - m_dir = 0; + m_dir.reset(); + for (auto&& df : m_df) { + df.reset(); } - for (int i = 0; i < NBDIR; i++) - if (m_df[i]) { - delete[] m_df[i]; - m_df[i] = 0; - } m_lX = m_lY = 0; m_lDf = 0; } @@ -203,7 +198,7 @@ UCHAR CSDirection::getDir(const int xx, const int yy, UCHAR *sel) void CSDirection::makeDir(UCHAR *sel) { UCHAR *pSel = sel; - UCHAR *pDir = m_dir; + UCHAR *pDir = m_dir.get(); for (int y = 0; y < m_lY; y++) for (int x = 0; x < m_lX; x++, pSel++, pDir++) { *pDir = 0; @@ -281,7 +276,7 @@ UCHAR CSDirection::equalizeDir_LT50(UCHAR *sel, void CSDirection::equalizeDir(UCHAR *sel, const int d) { UCHAR *pSel = sel; - UCHAR *pDir = m_dir; + UCHAR *pDir = m_dir.get(); for (int y = 0; y < m_lY; y++) for (int x = 0; x < m_lX; x++, pSel++) { if (*pSel > (UCHAR)0) { @@ -321,7 +316,7 @@ void CSDirection::makeDirFilter(const int sens) m_lDf = size * size; for (int i = 0; i < NBDIR; i++) { - m_df[i] = new SXYW[m_lDf]; + m_df[i].reset(new SXYW[m_lDf]); if (!m_df[i]) { null(); throw SMemAllocError("in directionMap"); @@ -378,41 +373,38 @@ UCHAR CSDirection::blurRadius(UCHAR *sel, const int xx, const int yy, const int void CSDirection::blurRadius(const int dBlur) { if (m_lX > 0 && m_lY > 0 && m_dir) { - UCHAR *sel = new UCHAR[m_lX * m_lY]; + std::unique_ptr sel(new UCHAR[m_lX * m_lY]); if (!sel) throw SMemAllocError("in directionMap"); - memcpy(sel, m_dir, m_lX * m_lY * sizeof(UCHAR)); - UCHAR *pSel = sel; - UCHAR *pDir = m_dir; + memcpy(sel.get(), m_dir.get(), m_lX * m_lY * sizeof(UCHAR)); + UCHAR *pSel = sel.get(); + UCHAR *pDir = m_dir.get(); for (int y = 0; y < m_lY; y++) for (int x = 0; x < m_lX; x++, pSel++, pDir++) if (*pSel > (UCHAR)0) - *pDir = blurRadius(sel, x, y, dBlur); - delete[] sel; + *pDir = blurRadius(sel.get(), x, y, dBlur); } } void CSDirection::setDir01() { int xy = m_lX * m_lY; - UCHAR *pDir = m_dir; + UCHAR *pDir = m_dir.get(); for (int i = 0; i < xy; i++, pDir++) *pDir = *pDir > (UCHAR)0 ? (UCHAR)1 : (UCHAR)0; } void CSDirection::doDir() { - UCHAR *sel = 0; if (m_lX > 0 && m_lY > 0 && m_dir) { - sel = new UCHAR[m_lX * m_lY]; + std::unique_ptr sel(new UCHAR[m_lX * m_lY]); if (!sel) throw SMemAllocError("in directionMap"); size_t length = (size_t)(m_lX * m_lY * sizeof(UCHAR)); - memcpy(sel, m_dir, length); - makeDir(sel); - memcpy(sel, m_dir, length); - equalizeDir(sel, 3); - delete[] sel; + memcpy(sel.get(), m_dir.get(), length); + makeDir(sel.get()); + memcpy(sel.get(), m_dir.get(), length); + equalizeDir(sel.get(), 3); } } @@ -421,7 +413,7 @@ void CSDirection::doRadius(const double rH, const double rLR, { try { int xy = m_lX * m_lY; - UCHAR *pDir = m_dir; + UCHAR *pDir = m_dir.get(); double r[4] = {D_CUT_0_1(rH), D_CUT_0_1(rLR), D_CUT_0_1(rV), D_CUT_0_1(rRL)}; for (int i = 0; i < xy; i++, pDir++) @@ -439,5 +431,5 @@ void CSDirection::doRadius(const double rH, const double rLR, void CSDirection::getResult(UCHAR *sel) { - memcpy(sel, m_dir, (size_t)(m_lX * m_lY * sizeof(UCHAR))); + memcpy(sel, m_dir.get(), (size_t)(m_lX * m_lY * sizeof(UCHAR))); } diff --git a/toonz/sources/toonzlib/sandor_fxs/SDirection.h b/toonz/sources/toonzlib/sandor_fxs/SDirection.h index 9e03f80..f8b1de5 100644 --- a/toonz/sources/toonzlib/sandor_fxs/SDirection.h +++ b/toonz/sources/toonzlib/sandor_fxs/SDirection.h @@ -13,10 +13,10 @@ #include "SDef.h" +#include +#include #include -using namespace std; - //#define MSIZE 3 typedef struct { @@ -29,8 +29,8 @@ typedef struct { class CSDirection { int m_lX, m_lY; - UCHAR *m_dir; - SXYW *m_df[NBDIR]; + std::unique_ptr m_dir; + std::array, NBDIR> m_df; int m_lDf; void null(); diff --git a/toonz/sources/toonzlib/sandor_fxs/SError.h b/toonz/sources/toonzlib/sandor_fxs/SError.h index d3294b2..cdc9394 100644 --- a/toonz/sources/toonzlib/sandor_fxs/SError.h +++ b/toonz/sources/toonzlib/sandor_fxs/SError.h @@ -16,12 +16,10 @@ #include "SDef.h" -using namespace std; - class SError { protected: - string m_msg; + std::string m_msg; public: SError() : m_msg(""){}; diff --git a/toonz/sources/toonzlib/sandor_fxs/STColSelPic.h b/toonz/sources/toonzlib/sandor_fxs/STColSelPic.h index 6d1b237..48cdd5a 100644 --- a/toonz/sources/toonzlib/sandor_fxs/STColSelPic.h +++ b/toonz/sources/toonzlib/sandor_fxs/STColSelPic.h @@ -15,11 +15,12 @@ #pragma once #endif // _MSC_VER > 1000 -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif #include #include +#include #include #include @@ -29,35 +30,27 @@ #include "CIL.h" #include "SError.h" -using namespace std; - template class CSTColSelPic : public CSTPic

{ public: - UCHAR *m_sel; + std::shared_ptr m_sel; - CSTColSelPic() : CSTPic

(), m_sel(0){}; + CSTColSelPic() : CSTPic

() {} virtual ~CSTColSelPic() { - if (m_sel) { - delete[] m_sel, m_sel = 0; - } }; void nullSel() { - if (m_sel) { - delete[] m_sel; - m_sel = 0; - } + m_sel.reset(); } void initSel() //throw(SMemAllocError) { nullSel(); if (CSTPic

::m_lX > 0 && CSTPic

::m_lY > 0) { - m_sel = new UCHAR[CSTPic

::m_lX * CSTPic

::m_lY]; + m_sel.reset(new UCHAR[CSTPic

::m_lX * CSTPic

::m_lY], std::default_delete()); if (!m_sel) throw SMemAllocError(" in initColorSelection"); } else { @@ -69,29 +62,17 @@ public: void copySel(const UCHAR *sel) { - memcpy(m_sel, sel, CSTPic

::m_lX * CSTPic

::m_lY * sizeof(UCHAR)); + memcpy(m_sel.get(), sel, CSTPic

::m_lX * CSTPic

::m_lY * sizeof(UCHAR)); } void copySel(const UCHAR sel) { - memset(m_sel, sel, CSTPic

::m_lX * CSTPic

::m_lY * sizeof(UCHAR)); + memset(m_sel.get(), sel, CSTPic

::m_lX * CSTPic

::m_lY * sizeof(UCHAR)); } CSTColSelPic(const CSTColSelPic &csp) /*throw(SMemAllocError) */ : CSTPic

(csp) - /* , m_sel(0) */ { - /* - try { - if ( csp.m_sel && m_lX>0 m_lY>0) { - initSel(); - copySel(csp.m_sel); - } - } - catch (SMemAllocError) { - throw; - } -*/ } const CSTColSelPic

&operator=(const CSTColSelPic

&sp) // throw(SMemAllocError) @@ -106,7 +87,7 @@ public: *dpp = *spp; if (sp.m_sel && CSTPic

::m_lX > 0 && CSTPic

::m_lY > 0) { initSel(); - copySel(sp.m_sel); + copySel(sp.m_sel.get()); } } catch (SMemAllocError) { throw; @@ -125,7 +106,7 @@ public: int makeSelectionCMAP32(const COLOR_INDEX_LIST &ink, const COLOR_INDEX_LIST &paint) { - UCHAR *pSel = m_sel; + UCHAR *pSel = m_sel.get(); P *pic = CSTPic

::m_pic; int xy = 0, nbSel = 0; @@ -296,21 +277,21 @@ public: bool isBetween(const I_PIXEL &a, const I_PIXEL &b, const I_PIXEL &c) const { - if (c.r < min(a.r, b.r)) + if (c.r < std::min(a.r, b.r)) return false; - if (c.r > max(a.r, b.r)) + if (c.r > std::max(a.r, b.r)) return false; - if (c.g < min(a.g, b.g)) + if (c.g < std::min(a.g, b.g)) return false; - if (c.g > max(a.g, b.g)) + if (c.g > std::max(a.g, b.g)) return false; - if (c.b < min(a.b, b.b)) + if (c.b < std::min(a.b, b.b)) return false; - if (c.b > max(a.b, b.b)) + if (c.b > std::max(a.b, b.b)) return false; - if (c.m < min(a.m, b.m)) + if (c.m < std::min(a.m, b.m)) return false; - if (c.m > max(a.m, b.m)) + if (c.m > std::max(a.m, b.m)) return false; /* //if ( c.m!=0 ) @@ -561,10 +542,10 @@ public: for (int y = 0; y < CSTPic

::m_lY; y++) for (int x = 0; x < CSTPic

::m_lX; x++, pSel++) if (*pSel > (UCHAR)0) { - box.x0 = min(box.x0, x); - box.x1 = max(box.x1, x); - box.y0 = min(box.y0, y); - box.y1 = max(box.y1, y); + box.x0 = std::min(box.x0, x); + box.x1 = std::max(box.x1, x); + box.y0 = std::min(box.y0, y); + box.y1 = std::max(box.y1, y); } } diff --git a/toonz/sources/toonzlib/sandor_fxs/YOMBInputParam.cpp b/toonz/sources/toonzlib/sandor_fxs/YOMBInputParam.cpp index 4357333..b41d3b1 100644 --- a/toonz/sources/toonzlib/sandor_fxs/YOMBInputParam.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/YOMBInputParam.cpp @@ -4,15 +4,17 @@ // ////////////////////////////////////////////////////////////////////// +#ifdef _WIN32 +#pragma warning(disable : 4996) +#endif + +#include #include #include #include #include #include "YOMBInputParam.h" -//#include "tmsg.h" -#ifdef WIN32 -#pragma warning(disable : 4996) -#endif + ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -72,9 +74,9 @@ void CYOMBInputParam::strToColorIndex(const char *s, COLOR_INDEX_LIST &cil, int begin = getRangeBegin(s); int end = getRangeEnd(s); if (begin >= 0 && end >= 0) { - begin = min(begin, maxIndex); - end = min(end, maxIndex); - for (int i = min(begin, end); i <= max(begin, end) && cil.nb < MAXNBCIL; i++) + begin = std::min(begin, maxIndex); + end = std::min(end, maxIndex); + for (int i = std::min(begin, end); i <= std::max(begin, end) && cil.nb < MAXNBCIL; i++) cil.ci[cil.nb++] = (unsigned short)i; } // If there is no 'begin' or 'end' of range, it is considered diff --git a/toonz/sources/toonzlib/sandor_fxs/YOMBParam.cpp b/toonz/sources/toonzlib/sandor_fxs/YOMBParam.cpp index e1aa37a..da2fdb8 100644 --- a/toonz/sources/toonzlib/sandor_fxs/YOMBParam.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/YOMBParam.cpp @@ -3,7 +3,7 @@ // YOMBParam.cpp: implementation of the CYOMBParam class. // ////////////////////////////////////////////////////////////////////// -#ifdef WIN32 +#ifdef _WIN32 #include "Windows.h" #endif #include @@ -72,7 +72,7 @@ void CYOMBParam::null() m_color.resize(0); } -#ifdef WIN32 +#ifdef _WIN32 bool CYOMBParam::read(basic_ifstream &in) { char token[1000] = ""; diff --git a/toonz/sources/toonzlib/sandor_fxs/YOMBParam.h b/toonz/sources/toonzlib/sandor_fxs/YOMBParam.h index bcce4cc..a4cd93e 100644 --- a/toonz/sources/toonzlib/sandor_fxs/YOMBParam.h +++ b/toonz/sources/toonzlib/sandor_fxs/YOMBParam.h @@ -22,8 +22,6 @@ #define P(d) tmsg_info(" - %d -\n", d) -using namespace std; - class CYOMBParam { public: @@ -80,8 +78,8 @@ public: void print(); void null(); void read(const CInputParam &ip); -#ifdef WIN32 - bool read(basic_ifstream &in); +#ifdef _WIN32 + bool read(std::basic_ifstream &in); #endif void makeColorsUS(); void makeItUS(); diff --git a/toonz/sources/toonzlib/sandor_fxs/blend.cpp b/toonz/sources/toonzlib/sandor_fxs/blend.cpp index 5c57d12..ad4be77 100644 --- a/toonz/sources/toonzlib/sandor_fxs/blend.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/blend.cpp @@ -100,31 +100,28 @@ struct SelectionData { // using raw bits and bitwise operators, and use just the double of the space required with bit arrays. class SelectionArrayPtr { - SelectionData *m_buffer; + std::unique_ptr m_buffer; public: - SelectionArrayPtr() : m_buffer(0) {} - inline void allocate(unsigned int count) { - m_buffer = new SelectionData[count]; - memset(m_buffer, 0, count * sizeof(SelectionData)); + m_buffer.reset(new SelectionData[count]); + memset(m_buffer.get(), 0, count * sizeof(SelectionData)); } inline void destroy() { - delete[] m_buffer; - m_buffer = 0; + m_buffer.reset(); } inline SelectionData *data() const { - return m_buffer; + return m_buffer.get(); } inline SelectionData *data() { - return m_buffer; + return m_buffer.get(); } }; diff --git a/toonz/sources/toonzlib/sandor_fxs/calligraph.cpp b/toonz/sources/toonzlib/sandor_fxs/calligraph.cpp index 6e29095..fde6a67 100644 --- a/toonz/sources/toonzlib/sandor_fxs/calligraph.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/calligraph.cpp @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include "windows.h" #endif @@ -56,7 +56,7 @@ void calligraphUC(const RASTER *inr, RASTER *outr, CCallParam &par, fSize = D_CUT(fSize, 1.0, 20.0); // CSDirection dir(ipUC.m_lX,ipUC.m_lY,ipUC.m_sel,I_ROUND(fSize)); // Only on border (thickness of border is 3 ) - CSDirection dir(ipUC.m_lX, ipUC.m_lY, ipUC.m_sel, I_ROUND(fSize), 3); + CSDirection dir(ipUC.m_lX, ipUC.m_lY, ipUC.m_sel.get(), I_ROUND(fSize), 3); dir.doDir(); // Calculation of 'RADIUS MAP' based on the 'DIRECTION MAP' @@ -65,7 +65,7 @@ void calligraphUC(const RASTER *inr, RASTER *outr, CCallParam &par, fSize = D_CUT(fSize, 1.0, 10.0); ; dir.doRadius(par.m_rH, par.m_rLR, par.m_rV, par.m_rRL, I_ROUND(fSize)); - dir.getResult(ipUC.m_sel); + dir.getResult(ipUC.m_sel.get()); // Draws the circles CCallCircle cc(par.m_thickness); @@ -105,7 +105,7 @@ void calligraphUS(const RASTER *inr, RASTER *outr, CCallParam &par, fSize = D_CUT(fSize, 1.0, 20.0); // CSDirection dir(ipUS.m_lX,ipUS.m_lY,ipUS.m_sel,I_ROUND(fSize)); // Only on border (thickness of border is 3 ) - CSDirection dir(ipUS.m_lX, ipUS.m_lY, ipUS.m_sel, I_ROUND(fSize), 3); + CSDirection dir(ipUS.m_lX, ipUS.m_lY, ipUS.m_sel.get(), I_ROUND(fSize), 3); dir.doDir(); // Calculation of 'RADIUS MAP' based on the 'DIRECTION MAP' @@ -114,7 +114,7 @@ void calligraphUS(const RASTER *inr, RASTER *outr, CCallParam &par, fSize = D_CUT(fSize, 1.0, 10.0); ; dir.doRadius(par.m_rH, par.m_rLR, par.m_rV, par.m_rRL, I_ROUND(fSize)); - dir.getResult(ipUS.m_sel); + dir.getResult(ipUS.m_sel.get()); // Draws the circles CCallCircle cc(par.m_thickness); diff --git a/toonz/sources/toonzlib/sandor_fxs/patternmap.cpp b/toonz/sources/toonzlib/sandor_fxs/patternmap.cpp index 83fc4d6..bc18f18 100644 --- a/toonz/sources/toonzlib/sandor_fxs/patternmap.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/patternmap.cpp @@ -1,6 +1,6 @@ -#ifdef WIN32 +#ifdef _WIN32 #include "Windows.h" #endif #include @@ -66,9 +66,9 @@ void patternmapUC(const RASTER *iras, RASTER *oras, CPatternMapParam &pmP, } if (nbContourPixel > 0) { if (!pmP.m_isRandomDir) { - CSDirection dir(ipUC.m_lX, ipUC.m_lY, ipUC.m_sel, DIRACCURACY); + CSDirection dir(ipUC.m_lX, ipUC.m_lY, ipUC.m_sel.get(), DIRACCURACY); dir.doDir(); - dir.getResult(ipUC.m_sel); + dir.getResult(ipUC.m_sel.get()); } CPatternPosition pPos(ipUC, nbContourPixel, pmP.m_density, pmP.m_minDist, pmP.m_maxDist); // Reads the pattern @@ -84,7 +84,7 @@ void patternmapUC(const RASTER *iras, RASTER *oras, CPatternMapParam &pmP, angle = pmP.m_minDirAngle + (double)(rand() % 1001) * 0.001 * (pmP.m_maxDirAngle - pmP.m_minDirAngle); else { if (pp->x >= 0 && pp->y >= 0 && pp->x < ipUC.m_lX && pp->y < ipUC.m_lY) { - UCHAR *sel = ipUC.m_sel + pp->y * ipUC.m_lX + pp->x; + UCHAR *sel = ipUC.m_sel.get() + pp->y * ipUC.m_lX + pp->x; if (*sel > (UCHAR)0) angle = (double)(*sel) - 50.0; } @@ -139,9 +139,9 @@ void patternmapUS(const RASTER *iras, RASTER *oras, CPatternMapParam &pmP, } if (nbContourPixel > 0) { if (!pmP.m_isRandomDir) { - CSDirection dir(ipUS.m_lX, ipUS.m_lY, ipUS.m_sel, DIRACCURACY); + CSDirection dir(ipUS.m_lX, ipUS.m_lY, ipUS.m_sel.get(), DIRACCURACY); dir.doDir(); - dir.getResult(ipUS.m_sel); + dir.getResult(ipUS.m_sel.get()); } CPatternPosition pPos(ipUS, nbContourPixel, pmP.m_density, pmP.m_minDist, pmP.m_maxDist); // Reads the pattern @@ -157,7 +157,7 @@ void patternmapUS(const RASTER *iras, RASTER *oras, CPatternMapParam &pmP, angle = pmP.m_minDirAngle + (double)(rand() % 1001) * 0.001 * (pmP.m_maxDirAngle - pmP.m_minDirAngle); else { if (pp->x >= 0 && pp->y >= 0 && pp->x < ipUS.m_lX && pp->y < ipUS.m_lY) { - UCHAR *sel = ipUS.m_sel + pp->y * ipUS.m_lX + pp->x; + UCHAR *sel = ipUS.m_sel.get() + pp->y * ipUS.m_lX + pp->x; if (*sel > (UCHAR)0) angle = (double)(*sel) - 50.0; } diff --git a/toonz/sources/toonzlib/sandor_fxs/toonz4_6staff.cpp b/toonz/sources/toonzlib/sandor_fxs/toonz4_6staff.cpp index 53baf05..0d8f851 100644 --- a/toonz/sources/toonzlib/sandor_fxs/toonz4_6staff.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/toonz4_6staff.cpp @@ -5,7 +5,7 @@ #include "tconvert.h" #include "toonz4.6/toonz.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #endif //--------------------------------------------------------------------- diff --git a/toonz/sources/toonzlib/screensavermaker.cpp b/toonz/sources/toonzlib/screensavermaker.cpp index 1234e92..360aff8 100644 --- a/toonz/sources/toonzlib/screensavermaker.cpp +++ b/toonz/sources/toonzlib/screensavermaker.cpp @@ -5,7 +5,7 @@ #include "tsystem.h" -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include diff --git a/toonz/sources/toonzlib/tcenterlinepolygonizer.cpp b/toonz/sources/toonzlib/tcenterlinepolygonizer.cpp index 4e81016..028f0fe 100644 --- a/toonz/sources/toonzlib/tcenterlinepolygonizer.cpp +++ b/toonz/sources/toonzlib/tcenterlinepolygonizer.cpp @@ -166,13 +166,12 @@ inline unsigned char PixelEvaluator::getBlackOrWhite(int x, int y) class Signaturemap { - unsigned char *m_array; + std::unique_ptr m_array; int m_rowSize; int m_colSize; public: Signaturemap(const TRasterP &ras, int threshold); - ~Signaturemap() { delete[] m_array; } template void readRasterData(const TRasterPT &ras, int threshold); @@ -238,11 +237,11 @@ void Signaturemap::readRasterData(const TRasterPT &ras, int threshold) m_rowSize = ras->getLx() + 2; m_colSize = ras->getLy() + 2; - m_array = new unsigned char[m_rowSize * m_colSize]; + m_array.reset(new unsigned char[m_rowSize * m_colSize]); - memset(m_array, none << 1, m_rowSize); + memset(m_array.get(), none << 1, m_rowSize); - currByte = m_array + m_rowSize; + currByte = m_array.get() + m_rowSize; for (y = 0; y < ras->getLy(); ++y) { *currByte = none << 1; currByte++; @@ -512,14 +511,13 @@ inline bool isCircular(int a, int b, int c) //-------------------------------------------------------------------------- //Extracts a 'next corner' array - helps improving overall speed -inline int *findNextCorners(RawBorder &path) +inline std::unique_ptr findNextCorners(RawBorder &path) { - int i, currentCorner; - int *corners = new int[path.size()]; + std::unique_ptr corners(new int[path.size()]); //NOTE: 0 is a corner, due to the path extraction procedure. - currentCorner = 0; - for (i = path.size() - 1; i >= 0; --i) { + int currentCorner = 0; + for (int i = path.size() - 1; i >= 0; --i) { if (path[currentCorner].x() != path[i].x() && path[currentCorner].y() != path[i].y()) currentCorner = i + 1; @@ -532,11 +530,11 @@ inline int *findNextCorners(RawBorder &path) //-------------------------------------------------------------------------- //Calculate furthest k satisfying 1) for all fixed i. -inline int *furthestKs(RawBorder &path, int *&nextCorners) +inline std::unique_ptr furthestKs(RawBorder &path, std::unique_ptr& nextCorners) { int n = path.size(); - int *kVector = new int[n]; + std::unique_ptr kVector(new int[n]); enum { left, up, @@ -650,17 +648,18 @@ inline int *furthestKs(RawBorder &path, int *&nextCorners) // arcs approximating the given raw border: // for every a in [i,res[i]], the arc connecting border[i] and // border[a] will be a possible one. -inline int *calculateForwardArcs(RawBorder &border, bool ambiguitiesCheck) +inline std::unique_ptr calculateForwardArcs(RawBorder &border, bool ambiguitiesCheck) { - int i, j, n = (int)border.size(); + int const n = (int)border.size(); - int *nextCorners; - int *k = furthestKs(border, nextCorners); - int *K = new int[n]; - int *res = new int[n]; + std::unique_ptr nextCorners; + std::unique_ptr k = furthestKs(border, nextCorners); + std::unique_ptr K(new int[n]); + std::unique_ptr res(new int[n]); //find K[i]= min {k[j]}, j=i..n-1. - for (i = 0; i < n; ++i) { + for (int i = 0; i < n; ++i) { + int j; for (j = i, K[i] = k[i]; isCircular(i, j, K[i]); j = (j + 1) % n) if (isCircular(j, k[j], K[i])) K[i] = k[j]; @@ -672,7 +671,7 @@ inline int *calculateForwardArcs(RawBorder &border, bool ambiguitiesCheck) // square); // second, arcs of the kind [i,j] with j 0; i = nextCorners[i]) { + for (int i = 1; nextCorners[i] > 0; i = nextCorners[i]) { if (border[i].getAmbiguous() == RawBorderPoint::right) { //Check vertices from i (excluded) to res[res[i]]; if in it there exists vertex k so that pos(k)==pos(i)... //This prevents the existence of 0 degree angles in the optimal polygon. int rrPlus1 = (res[res[i] % n] + 1) % n; - for (j = nextCorners[i]; + for (int j = nextCorners[i]; isCircular(i, j, rrPlus1) && j != i; //remember that isCircular(a,a,b) == 1 ... j = nextCorners[j]) { if (border[j].getAmbiguous() && (border[j].pos() == border[i].pos())) { @@ -707,10 +706,6 @@ inline int *calculateForwardArcs(RawBorder &border, bool ambiguitiesCheck) } } - delete[] k; - delete[] K; - delete[] nextCorners; - return res; } @@ -772,16 +767,15 @@ inline double penalty(RawBorder &path, int a, int b) inline void reduceBorder(RawBorder &border, Contour &res, bool ambiguitiesCheck) { - int i, j, k, a, *b, n = border.size(), m; - double newPenalty; + int n = border.size(); int minPenaltyNext; - int *minPenaltyNextArray = new int[n]; + std::unique_ptr minPenaltyNextArray(new int[n]); //Calculate preliminary infos - int *longestArcFrom = calculateForwardArcs(border, ambiguitiesCheck); + std::unique_ptr longestArcFrom = calculateForwardArcs(border, ambiguitiesCheck); calculateSums(border); - double *penaltyToEnd = new double[n + 1]; + std::unique_ptr penaltyToEnd(new double[n + 1]); //EXPLANATION: //The fastest way to extract the optimal reduced border is based on the @@ -793,24 +787,26 @@ inline void reduceBorder(RawBorder &border, Contour &res, bool ambiguitiesCheck) //longestArc[a[i-1]-1] b(new int[m + 1]); b[m] = n; - for (i = 0, j = 0; j < m; i = longestArcFrom[i], ++j) + for (int i = 0, j = 0; j < m; i = longestArcFrom[i], ++j) b[j] = i; //NOTE: a[] need not be completely found - we just remember the //a=a[j+1] currently needed. //Now, build the optimal polygon - for (j = m - 1, a = n; j >= 0; --j) { + for (int j = m - 1, a = n; j >= 0; --j) { + int k; for (k = b[j]; k >= 0 && longestArcFrom[k] >= a; --k) { penaltyToEnd[k] = infinity; - for (i = a; i <= longestArcFrom[k]; ++i) { - newPenalty = penaltyToEnd[i] + penalty(border, k, i); + for (int i = a; i <= longestArcFrom[k]; ++i) { + double newPenalty = penaltyToEnd[i] + penalty(border, k, i); if (newPenalty < penaltyToEnd[k]) penaltyToEnd[k] = newPenalty; minPenaltyNext = i; @@ -823,7 +819,7 @@ inline void reduceBorder(RawBorder &border, Contour &res, bool ambiguitiesCheck) //Finally, read off the optimal polygon res.resize(m); - for (i = j = 0; i < n; i = minPenaltyNextArray[i], ++j) { + for (int i = 0, j = 0; i < n; i = minPenaltyNextArray[i], ++j) { res[j] = ContourNode(border[i].x(), border[i].y()); //Ambiguities are still remembered in the output polygon. @@ -833,13 +829,9 @@ inline void reduceBorder(RawBorder &border, Contour &res, bool ambiguitiesCheck) res[j].setAttribute(ContourNode::AMBIGUOUS_RIGHT); } - delete[] longestArcFrom; - delete[] minPenaltyNextArray; delete[] border.sums(); delete[] border.sums2(); delete[] border.sumsMix(); - delete[] penaltyToEnd; - delete[] b; } //-------------------------------------------------------------------------- diff --git a/toonz/sources/toonzlib/tcleanupper.cpp b/toonz/sources/toonzlib/tcleanupper.cpp index 2ada536..fe39df8 100644 --- a/toonz/sources/toonzlib/tcleanupper.cpp +++ b/toonz/sources/toonzlib/tcleanupper.cpp @@ -573,7 +573,7 @@ CleanupPreprocessedImage *TCleanupper::process( bool isSameDpi = false; bool autocentered = getResampleValues(image, aff, blur, outDim, outDpi, isCameraTest, isSameDpi); if (m_parameters->m_autocenterType != AUTOCENTER_NONE && !autocentered) - DVGui::MsgBox(DVGui::WARNING, QObject::tr("The autocentering failed on the current drawing.")); + DVGui::warning(QObject::tr("The autocentering failed on the current drawing.")); bool fromGr8 = (bool)TRasterGR8P(image->getRaster()); bool toGr8 = (m_parameters->m_lineProcessingMode == lpGrey); diff --git a/toonz/sources/toonzlib/tcolumnfx.cpp b/toonz/sources/toonzlib/tcolumnfx.cpp index 2d75e7d..be90606 100644 --- a/toonz/sources/toonzlib/tcolumnfx.cpp +++ b/toonz/sources/toonzlib/tcolumnfx.cpp @@ -65,7 +65,7 @@ extern "C" { // Preliminaries //**************************************************************************************** -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TFxDeclarationT; template class DV_EXPORT_API TFxDeclarationT; template class DV_EXPORT_API TFxDeclarationT; diff --git a/toonz/sources/toonzlib/tdistort.cpp b/toonz/sources/toonzlib/tdistort.cpp index 66efdf1..b3921e3 100644 --- a/toonz/sources/toonzlib/tdistort.cpp +++ b/toonz/sources/toonzlib/tdistort.cpp @@ -1,4 +1,5 @@ - +#include +#include #include "toonz/tdistort.h" #include "traster.h" @@ -115,7 +116,7 @@ void resample(const TRasterCM32P &rasIn, TRasterCM32P &rasOut, const TDistorter if (rasOut->getLx() < 1 || rasOut->getLy() < 1 || rasIn->getLx() < 1 || rasIn->getLy() < 1) return; - TPointD *preImages = new TPointD[distorter.maxInvCount()]; + std::unique_ptr preImages(new TPointD[distorter.maxInvCount()]); int x, y; int i; @@ -126,7 +127,7 @@ void resample(const TRasterCM32P &rasIn, TRasterCM32P &rasOut, const TDistorter for (x = 0; pix != endPix; pix++, x++) { TPixelCM32 pixDown; - int count = distorter.invMap(convert(p) + TPointD(x + 0.5, y + 0.5), preImages); + int count = distorter.invMap(convert(p) + TPointD(x + 0.5, y + 0.5), preImages.get()); for (i = count - 1; i >= 0; --i) { TPixelCM32 pixUp; TPointD preImage(preImages[i].x - 0.5, preImages[i].y - 0.5); @@ -141,8 +142,6 @@ void resample(const TRasterCM32P &rasIn, TRasterCM32P &rasOut, const TDistorter *pix = pixDown; } } - - delete[] preImages; } //--------------------------------------------------------------------------------- @@ -165,7 +164,7 @@ void resampleClosestPixel(const TRasterPT &rasIn, TRasterPT &rasOut, if (rasOut->getLx() < 1 || rasOut->getLy() < 1 || rasIn->getLx() < 1 || rasIn->getLy() < 1) return; - TPointD *preImages = new TPointD[distorter.maxInvCount()]; + std::unique_ptr preImages(new TPointD[distorter.maxInvCount()]); int x, y; int i; @@ -178,7 +177,7 @@ void resampleClosestPixel(const TRasterPT &rasIn, TRasterPT &rasOut, T pixDown(0, 0, 0, 0); //preImages.clear(); - int count = distorter.invMap(convert(p) + TPointD(x + 0.5, y + 0.5), preImages); + int count = distorter.invMap(convert(p) + TPointD(x + 0.5, y + 0.5), preImages.get()); for (i = count - 1; i >= 0; --i) { T pixUp(0, 0, 0, 0); TPointD preImage(preImages[i].x - 0.5, preImages[i].y - 0.5); @@ -191,8 +190,6 @@ void resampleClosestPixel(const TRasterPT &rasIn, TRasterPT &rasOut, *pix = pixDown; } } - - delete[] preImages; } //--------------------------------------------------------------------------------- @@ -213,7 +210,7 @@ void resampleClosestPixel(const TRasterCM32P &rasIn, TRasterCM32P &rasOut, if (rasOut->getLx() < 1 || rasOut->getLy() < 1 || rasIn->getLx() < 1 || rasIn->getLy() < 1) return; - TPointD *preImages = new TPointD[distorter.maxInvCount()]; + std::unique_ptr preImages(new TPointD[distorter.maxInvCount()]); int x, y; int i; @@ -225,7 +222,7 @@ void resampleClosestPixel(const TRasterCM32P &rasIn, TRasterCM32P &rasOut, for (; pix != endPix; pix++, x++) { TPixelCM32 pixDown(0, 0, 255); - int count = distorter.invMap(convert(p) + TPointD(x + 0.5, y + 0.5), preImages); + int count = distorter.invMap(convert(p) + TPointD(x + 0.5, y + 0.5), preImages.get()); for (i = count - 1; i >= 0; --i) { TPixelCM32 pixUp(0, 0, 255); TPointD preImage(preImages[i].x - 0.5, preImages[i].y - 0.5); @@ -238,8 +235,6 @@ void resampleClosestPixel(const TRasterCM32P &rasIn, TRasterCM32P &rasOut, *pix = pixDown; } } - - delete[] preImages; } //================================================================================= @@ -359,51 +354,55 @@ void resample(const TRasterPT &rasIn, TRasterPT &rasOut, const TDistorter int invsCount = distorter.maxInvCount(); //Allocate buffers - TPointD *invs[2]; - invs[0] = new TPointD[invsCount * (rasOut->getLx() + 1)]; - invs[1] = new TPointD[invsCount * (rasOut->getLx() + 1)]; - int *counts[2]; - counts[0] = new int[rasOut->getLx() + 1]; - counts[1] = new int[rasOut->getLx() + 1]; - T *temp = new T[rasIn->getLx()]; - TPointD *newInvs, *oldInvs, *currOldInv, *currNewInv; - int x, y, i, *newCounts, *oldCounts; + std::array, 2> invs = { + std::unique_ptr(new TPointD[invsCount * (rasOut->getLx() + 1)]), + std::unique_ptr(new TPointD[invsCount * (rasOut->getLx() + 1)]), + }; + std::array, 2> counts = { + std::unique_ptr(new int[rasOut->getLx() + 1]), + std::unique_ptr(new int[rasOut->getLx() + 1]), + }; + std::unique_ptr temp(new T[rasIn->getLx()]); TPointD shift(convert(p) + TPointD(0.5, 0.5)); //Fill in the first inverses (lower edge of output image) - currOldInv = invs[0]; - oldCounts = counts[0]; - for (x = 0; x <= rasOut->getLx(); currOldInv += invsCount, ++x) - oldCounts[x] = distorter.invMap(shift + TPointD(x, 0.0), currOldInv); + { + TPointD* currOldInv = invs[0].get(); + int* oldCounts = counts[0].get(); + for (int x = 0; x <= rasOut->getLx(); currOldInv += invsCount, ++x) + oldCounts[x] = distorter.invMap(shift + TPointD(x, 0.0), currOldInv); + } //For each output row - for (y = 0; y < rasOut->getLy(); ++y) { + for (int y = 0; y < rasOut->getLy(); ++y) { //Alternate inverse buffers - oldInvs = invs[y % 2]; - newInvs = invs[(y + 1) % 2]; - oldCounts = counts[y % 2]; - newCounts = counts[(y + 1) % 2]; + TPointD* oldInvs = invs[y % 2].get(); + TPointD* newInvs = invs[(y + 1) % 2].get(); + int* oldCounts = counts[y % 2].get(); + int* newCounts = counts[(y + 1) % 2].get(); //Build the new inverses - currNewInv = newInvs; - for (x = 0; x <= rasOut->getLx(); currNewInv += invsCount, ++x) - newCounts[x] = distorter.invMap(shift + TPointD(x, y + 1.0), currNewInv); + { + TPointD* currNewInv = newInvs; + for (int x = 0; x <= rasOut->getLx(); currNewInv += invsCount, ++x) + newCounts[x] = distorter.invMap(shift + TPointD(x, y + 1.0), currNewInv); + } //Filter each pixel in the row T *pix = rasOut->pixels(y); - currOldInv = oldInvs; - currNewInv = newInvs; - for (x = 0; x < rasOut->getLx(); currOldInv += invsCount, currNewInv += invsCount, ++x, ++pix) { + TPointD* currOldInv = oldInvs; + TPointD* currNewInv = newInvs; + for (int x = 0; x < rasOut->getLx(); currOldInv += invsCount, currNewInv += invsCount, ++x, ++pix) { T pixDown(0, 0, 0, 0); int count = tmin(oldCounts[x], oldCounts[x + 1], newCounts[x]); - for (i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { T pixUp(0, 0, 0, 0); pixUp = filterPixel( currOldInv[i].x - 0.5, (currOldInv + invsCount)[i].x - 0.5, currOldInv[i].y - 0.5, currNewInv[i].y - 0.5, - rasIn, temp); + rasIn, temp.get()); pixDown = overPix(pixDown, pixUp); } @@ -411,12 +410,6 @@ void resample(const TRasterPT &rasIn, TRasterPT &rasOut, const TDistorter *pix = pixDown; } } - - delete[] invs[0]; - delete[] invs[1]; - delete[] counts[0]; - delete[] counts[1]; - delete[] temp; } } // namespace diff --git a/toonz/sources/toonzlib/texturemanager.cpp b/toonz/sources/toonzlib/texturemanager.cpp index fb9f9e3..37ab2f9 100644 --- a/toonz/sources/toonzlib/texturemanager.cpp +++ b/toonz/sources/toonzlib/texturemanager.cpp @@ -17,7 +17,7 @@ TextureManager *TextureManager::instance() return m_instance; } -#ifdef WIN32 +#ifdef _WIN32 TDimensionI TextureManager::getMaxSize(bool isRGBM) { GLenum fmt, type; diff --git a/toonz/sources/toonzlib/tlog.cpp b/toonz/sources/toonzlib/tlog.cpp index 64204d1..c874d9e 100644 --- a/toonz/sources/toonzlib/tlog.cpp +++ b/toonz/sources/toonzlib/tlog.cpp @@ -6,7 +6,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4996) #include #include @@ -35,7 +35,7 @@ enum LEVEL { LEVEL_INFO }; -#ifdef WIN32 +#ifdef _WIN32 WORD Level2WinEventType(LEVEL level) { switch (level) { @@ -73,7 +73,7 @@ int Level2XPriority(LEVEL level) void notify(LEVEL level, const string &msg) { -#ifdef WIN32 +#ifdef _WIN32 TCHAR buf[_MAX_PATH + 1]; GetModuleFileName(0, buf, _MAX_PATH); @@ -216,7 +216,7 @@ TUserLogAppend::~TUserLogAppend() void TUserLogAppend::warning(const string &msg) { - DVGui::MsgBox(DVGui::WARNING, QString::fromStdString(msg)); + DVGui::warning(QString::fromStdString(msg)); string fullMsg(myGetCurrentTime()); fullMsg += " WRN:"; @@ -230,7 +230,7 @@ void TUserLogAppend::warning(const string &msg) void TUserLogAppend::error(const string &msg) { - DVGui::MsgBox(DVGui::CRITICAL, QString::fromStdString(msg)); + DVGui::error(QString::fromStdString(msg)); string fullMsg(myGetCurrentTime()); fullMsg += " ERR:"; fullMsg += "\n"; diff --git a/toonz/sources/toonzlib/toutlinevectorizer.cpp b/toonz/sources/toonzlib/toutlinevectorizer.cpp index 6b391b3..bebfc19 100644 --- a/toonz/sources/toonzlib/toutlinevectorizer.cpp +++ b/toonz/sources/toonzlib/toutlinevectorizer.cpp @@ -18,6 +18,7 @@ #include "tcg/tcg_function_types.h" // STD includes +#include #include #undef DEBUG @@ -59,7 +60,7 @@ public: }; //--------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 template class DV_EXPORT_API TSmartPointerT>; #endif typedef TRasterPT DataRasterP; diff --git a/toonz/sources/toonzlib/tstageobject.cpp b/toonz/sources/toonzlib/tstageobject.cpp index 92ba32c..67fb3d7 100644 --- a/toonz/sources/toonzlib/tstageobject.cpp +++ b/toonz/sources/toonzlib/tstageobject.cpp @@ -43,14 +43,14 @@ using namespace std; // il problema si verifica ruotando gli oggetti sul camera stand // -#ifdef WIN32 +#ifdef _WIN32 #pragma optimize("", off) #endif TAffine makeRotation(double ang) { return TRotation(ang); } -#ifdef WIN32 +#ifdef _WIN32 #pragma optimize("", on) #endif diff --git a/toonz/sources/toonzlib/txsheet.cpp b/toonz/sources/toonzlib/txsheet.cpp index afb8692..8fe7fb3 100644 --- a/toonz/sources/toonzlib/txsheet.cpp +++ b/toonz/sources/toonzlib/txsheet.cpp @@ -761,7 +761,7 @@ void TXsheet::stepCells(int r0, int c0, int r1, int c1, int type) if (nr < 1 || nc <= 0) return; int size = nr * nc; - TXshCell *cells = new TXshCell[size]; + std::unique_ptr cells(new TXshCell[size]); if (!cells) return; //salvo il contenuto delle celle in cells @@ -788,10 +788,6 @@ void TXsheet::stepCells(int r0, int c0, int r1, int c1, int type) i += type; //dipende dal tipo di step (2 o 3 per ora) } } - - if (cells) - delete[] cells; - cells = 0; } //----------------------------------------------------------------------------- @@ -877,7 +873,7 @@ void TXsheet::eachCells(int r0, int c0, int r1, int c1, int type) int size = newRows * nc; assert(size > 0); - TXshCell *cells = new TXshCell[size]; + std::unique_ptr cells(new TXshCell[size]); assert(cells); int i, j, k; @@ -900,10 +896,6 @@ void TXsheet::eachCells(int r0, int c0, int r1, int c1, int type) setCell(i, j, cells[k]); k++; } - - if (cells) - delete[] cells; - cells = 0; } //----------------------------------------------------------------------------- @@ -989,7 +981,7 @@ void TXsheet::rollupCells(int r0, int c0, int r1, int c1) int nc = c1 - c0 + 1; int size = 1 * nc; assert(size > 0); - TXshCell *cells = new TXshCell[size]; + std::unique_ptr cells(new TXshCell[size]); assert(cells); //in cells copio il contenuto delle celle che mi interessano @@ -1004,10 +996,6 @@ void TXsheet::rollupCells(int r0, int c0, int r1, int c1) insertCells(r1, k, 1); setCell(r1, k, cells[k - c0]); //setto le celle } - - if (cells) - delete[] cells; - cells = 0; } //----------------------------------------------------------------------------- @@ -1018,7 +1006,7 @@ void TXsheet::rolldownCells(int r0, int c0, int r1, int c1) int nc = c1 - c0 + 1; int size = 1 * nc; assert(size > 0); - TXshCell *cells = new TXshCell[size]; + std::unique_ptr cells(new TXshCell[size]); assert(cells); //in cells copio il contenuto delle celle che mi interessano @@ -1033,10 +1021,6 @@ void TXsheet::rolldownCells(int r0, int c0, int r1, int c1) insertCells(r0, k, 1); setCell(r0, k, cells[k - c0]); //setto le celle } - - if (cells) - delete[] cells; - cells = 0; } //----------------------------------------------------------------------------- @@ -1051,9 +1035,9 @@ void TXsheet::timeStretch(int r0, int c0, int r1, int c1, int nr) for (c = c0; c <= c1; c++) { int dn = nr - oldNr; assert(oldNr > 0); - TXshCell *cells = new TXshCell[oldNr]; + std::unique_ptr cells(new TXshCell[oldNr]); assert(cells); - getCells(r0, c, oldNr, cells); + getCells(r0, c, oldNr, cells.get()); insertCells(r0 + 1, c, dn); int i; for (i = nr - 1; i >= 0; i--) { @@ -1061,18 +1045,15 @@ void TXsheet::timeStretch(int r0, int c0, int r1, int c1, int nr) if (j < i) setCell(i + r0, c, cells[j]); } - if (cells) - delete[] cells; - cells = 0; } } else /* rimpicciolisce */ { int c; for (c = c0; c <= c1; c++) { int dn = oldNr - nr; - TXshCell *cells = new TXshCell[oldNr]; + std::unique_ptr cells(new TXshCell[oldNr]); assert(cells); - getCells(r0, c, oldNr, cells); + getCells(r0, c, oldNr, cells.get()); int i; for (i = 0; i < nr; i++) { int j = i * double(oldNr) / double(nr); @@ -1080,9 +1061,6 @@ void TXsheet::timeStretch(int r0, int c0, int r1, int c1, int nr) setCell(i + r0, c, cells[j]); } removeCells(r1 - dn + 1, c, dn); - if (cells) - delete[] cells; - cells = 0; } } } diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index de6ac66..b031098 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -1489,7 +1489,7 @@ void TXshSimpleLevel::save(const TFilePath &fp, const TFilePath &oldFp, bool ove sl->setPath(getScene()->codeFilePath(app)); sl->setType(getType()); - set::iterator eft, efEnd; + std::set::iterator eft, efEnd; for (eft = m_editableRange.begin(); eft != efEnd; ++eft) { const TFrameId &fid = *eft; sl->setFrame(fid, getFrame(fid, false)); @@ -1510,7 +1510,7 @@ void TXshSimpleLevel::save(const TFilePath &fp, const TFilePath &oldFp, bool ove // Copy mesh level sl->save(app); -#ifdef WIN32 +#ifdef _WIN32 //hides files oldFilePaths.clear(); @@ -1767,7 +1767,7 @@ void TXshSimpleLevel::saveSimpleLevel(const TFilePath &decodedFp, bool overwrite hookSet = getHookSet(); } -#ifdef WIN32 +#ifdef _WIN32 // Remove the hidden attribute (since TOStream's fopen fails on hidden files) if (getType() == OVL_XSHLEVEL && !m_editableRange.empty()) SetFileAttributesW(hookFile.getWideString().c_str(), FILE_ATTRIBUTE_NORMAL); @@ -1785,7 +1785,7 @@ void TXshSimpleLevel::saveSimpleLevel(const TFilePath &decodedFp, bool overwrite } } -#ifdef WIN32 +#ifdef _WIN32 if (getType() == OVL_XSHLEVEL && !m_editableRange.empty()) TSystem::hideFileOrLevel(hookFile); #endif diff --git a/toonz/sources/toonzqt/camerasettingswidget.cpp b/toonz/sources/toonzqt/camerasettingswidget.cpp index 1a57b12..320cb80 100644 --- a/toonz/sources/toonzqt/camerasettingswidget.cpp +++ b/toonz/sources/toonzqt/camerasettingswidget.cpp @@ -199,8 +199,8 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) m_arFld = new SimpleExpField(this); - m_xResFld = new IntLineEdit(); - m_yResFld = new IntLineEdit(); + m_xResFld = new DVGui::IntLineEdit(); + m_yResFld = new DVGui::IntLineEdit(); m_xDpiFld = new DoubleLineEdit(); m_yDpiFld = new DoubleLineEdit(); @@ -1024,7 +1024,7 @@ void CameraSettingsWidget::removePreset() return; // confirmation dialog - int ret = MsgBox(QObject::tr("Deleting \"%1\".\nAre you sure?").arg(m_presetListOm->currentText()), + int ret = DVGui::MsgBox(QObject::tr("Deleting \"%1\".\nAre you sure?").arg(m_presetListOm->currentText()), QObject::tr("Delete"), QObject::tr("Cancel")); if (ret == 0 || ret == 2) return; diff --git a/toonz/sources/toonzqt/colorfield.cpp b/toonz/sources/toonzqt/colorfield.cpp index 9f18c28..171dfb4 100644 --- a/toonz/sources/toonzqt/colorfield.cpp +++ b/toonz/sources/toonzqt/colorfield.cpp @@ -183,7 +183,7 @@ ChannelField::ChannelField(QWidget *parent, assert(0 <= value && value <= m_maxValue); QLabel *channelName = new QLabel(string, this); - m_channelEdit = new IntLineEdit(this, value, 0, maxValue); + m_channelEdit = new DVGui::IntLineEdit(this, value, 0, maxValue); m_channelSlider = new QSlider(Qt::Horizontal, this); channelName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); diff --git a/toonz/sources/toonzqt/dvdialog.cpp b/toonz/sources/toonzqt/dvdialog.cpp index 1fb34b9..0900b16 100644 --- a/toonz/sources/toonzqt/dvdialog.cpp +++ b/toonz/sources/toonzqt/dvdialog.cpp @@ -42,16 +42,16 @@ QPixmap getMsgBoxPixmap(MsgType type) QIcon msgBoxIcon; switch (type) { - case INFORMATION: + case DVGui::INFORMATION: msgBoxIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); break; - case WARNING: + case DVGui::WARNING: msgBoxIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); break; - case CRITICAL: + case DVGui::CRITICAL: msgBoxIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); break; - case QUESTION: + case DVGui::QUESTION: msgBoxIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion); break; default: @@ -70,16 +70,16 @@ QString getMsgBoxTitle(MsgType type) QString title = DialogTitle + " - "; switch (type) { - case INFORMATION: + case DVGui::INFORMATION: title.append(QObject::tr("Information")); break; - case WARNING: + case DVGui::WARNING: title.append(QObject::tr("Warning")); break; - case CRITICAL: + case DVGui::CRITICAL: title.append(QObject::tr("Critical")); break; - case QUESTION: + case DVGui::QUESTION: title.append(QObject::tr("Question")); break; default: @@ -781,7 +781,7 @@ int DVGui::RadioButtonMsgBox(MsgType type, const QString &labelText, const QList &radioButtonList, QWidget *parent) { RadioButtonDialog *dialog = new RadioButtonDialog(labelText, radioButtonList, parent); - QString msgBoxTitle = getMsgBoxTitle(WARNING); + QString msgBoxTitle = getMsgBoxTitle(DVGui::WARNING); dialog->setWindowTitle(msgBoxTitle); return dialog->exec(); } @@ -1086,7 +1086,7 @@ int DVGui::MsgBox(const QString &text, std::vector buttons; buttons.push_back(button1); buttons.push_back(button2); - return MsgBox(QUESTION, text, buttons, defaultButtonIndex, parent); + return DVGui::MsgBox(DVGui::QUESTION, text, buttons, defaultButtonIndex, parent); } //----------------------------------------------------------------------------- @@ -1259,8 +1259,8 @@ int DVGui::eraseStylesInDemand(TPalette *palette, std::vector styleIds, std::vector buttons(2); buttons[0] = QObject::tr("Ok"), buttons[1] = QObject::tr("Cancel"); - if (DVGui::MsgBox(DVGui::WARNING, QObject::tr("Deletion of Lines and Areas from raster-based levels is not undoable.\n" - "Are you sure?"), + if (DVGui::MsgBox(DVGui::WARNING, + QObject::tr("Deletion of Lines and Areas from raster-based levels is not undoable.\n""Are you sure?"), buttons) != 1) return 0; } @@ -1286,7 +1286,7 @@ void DVGui::featureNotAvelaible(QString webSiteName, QString url) Dialog dialog(0, true); dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint); dialog.setAlignment(Qt::AlignLeft); - QString msgBoxTitle = getMsgBoxTitle(WARNING); + QString msgBoxTitle = getMsgBoxTitle(DVGui::WARNING); dialog.setWindowTitle(msgBoxTitle); QVBoxLayout *mainLayout = new QVBoxLayout; @@ -1296,7 +1296,7 @@ void DVGui::featureNotAvelaible(QString webSiteName, QString url) QString msg = QObject::tr("This feature is not available in the demo version.\nFor more information visit the %1 site:").arg(webSiteName); QLabel *mainTextLabel = new QLabel(msg, &dialog); - QPixmap iconPixmap = getMsgBoxPixmap(WARNING); + QPixmap iconPixmap = getMsgBoxPixmap(DVGui::WARNING); if (!iconPixmap.isNull()) { QLabel *iconLabel = new QLabel(&dialog); iconLabel->setPixmap(iconPixmap); @@ -1338,7 +1338,7 @@ void DVGui::requestTrialLicense(QString url, QString mail) Dialog dialog(0, true); dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint); dialog.setAlignment(Qt::AlignLeft); - QString msgBoxTitle = getMsgBoxTitle(WARNING); + QString msgBoxTitle = getMsgBoxTitle(DVGui::WARNING); dialog.setWindowTitle(msgBoxTitle); QVBoxLayout *mainLayout = new QVBoxLayout; diff --git a/toonz/sources/toonzqt/flipconsole.cpp b/toonz/sources/toonzqt/flipconsole.cpp index 873a549..3056e69 100644 --- a/toonz/sources/toonzqt/flipconsole.cpp +++ b/toonz/sources/toonzqt/flipconsole.cpp @@ -1334,7 +1334,7 @@ void FlipConsole::onLoadBox(bool isDefine) Preferences::instance()->getViewValues(shrink, dummy); if (shrink != 1) { -#ifdef WIN32 +#ifdef _WIN32 MessageBox(0, "Cannot use loading box with a shrink factor! ", "Warning", MB_OK); #endif setChecked(eUseLoadBox, false); @@ -1545,7 +1545,7 @@ QFrame *FlipConsole::createFrameSlider() { QFrame *frameSliderFrame = new QFrame(this); - m_editCurrFrame = new IntLineEdit(frameSliderFrame, m_currentFrame); + m_editCurrFrame = new DVGui::IntLineEdit(frameSliderFrame, m_currentFrame); m_editCurrFrame->setToolTip(tr("Set the current frame")); m_editCurrFrame->setFixedWidth(40); @@ -1595,7 +1595,7 @@ QFrame *FlipConsole::createFpsSlider() //frame per second m_fpsLabel = new QLabel(QString(" FPS -- /"), fpsSliderFrame); m_fpsSlider = new QScrollBar(Qt::Horizontal, fpsSliderFrame); - m_fpsField = new IntLineEdit(fpsSliderFrame, m_fps, -60, 60); + m_fpsField = new DVGui::IntLineEdit(fpsSliderFrame, m_fps, -60, 60); m_fpsField->setFixedWidth(40); m_fpsLabel->setMinimumWidth(m_fpsLabel->fontMetrics().width("_FPS_24___")); diff --git a/toonz/sources/toonzqt/framenavigator.cpp b/toonz/sources/toonzqt/framenavigator.cpp index 78db5ed..9447a6b 100644 --- a/toonz/sources/toonzqt/framenavigator.cpp +++ b/toonz/sources/toonzqt/framenavigator.cpp @@ -25,7 +25,7 @@ FrameNavigator::FrameNavigator(QWidget *parent) connect(prevButton, SIGNAL(triggered()), this, SLOT(prevFrame())); addAction(prevButton); - m_lineEdit = new IntLineEdit(this); + m_lineEdit = new DVGui::IntLineEdit(this); m_lineEdit->setFixedHeight(16); bool ret = connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); diff --git a/toonz/sources/toonzqt/functionpanel.cpp b/toonz/sources/toonzqt/functionpanel.cpp index 3a0b21f..833ac0a 100644 --- a/toonz/sources/toonzqt/functionpanel.cpp +++ b/toonz/sources/toonzqt/functionpanel.cpp @@ -29,6 +29,8 @@ #include #include +#include + namespace { diff --git a/toonz/sources/toonzqt/functionsegmentviewer.cpp b/toonz/sources/toonzqt/functionsegmentviewer.cpp index 2e7fe8c..a674e64 100644 --- a/toonz/sources/toonzqt/functionsegmentviewer.cpp +++ b/toonz/sources/toonzqt/functionsegmentviewer.cpp @@ -607,7 +607,7 @@ void FunctionExpressionSegmentPage::apply() expr.setGrammar(curve->getGrammar()); expr.setText(expressionText); if (dependsOn(expr, curve)) { - DVGui::MsgBox(DVGui::WARNING, tr("There is a circular reference in the definition of the interpolation.")); + DVGui::warning(tr("There is a circular reference in the definition of the interpolation.")); return; } @@ -656,7 +656,7 @@ bool FunctionExpressionSegmentPage::getGuiValues(std::string &expressionText, expr.setGrammar(curve->getGrammar()); expr.setText(expressionText); if (dependsOn(expr, curve)) { - DVGui::MsgBox(DVGui::WARNING, tr("There is a circular reference in the definition of the interpolation.")); + DVGui::warning(tr("There is a circular reference in the definition of the interpolation.")); return false; } @@ -884,11 +884,11 @@ void SimilarShapeSegmentPage::apply() expr.setGrammar(curve->getGrammar()); expr.setText(expressionText); if (!expr.isValid()) { - DVGui::MsgBox(DVGui::WARNING, tr("There is a syntax error in the definition of the interpolation.")); + DVGui::warning(tr("There is a syntax error in the definition of the interpolation.")); return; } if (dependsOn(expr, curve)) { - DVGui::MsgBox(DVGui::WARNING, tr("There is a circular reference in the definition of the interpolation.")); + DVGui::warning(tr("There is a circular reference in the definition of the interpolation.")); return; } KeyframeSetter setter(curve, kIndex); diff --git a/toonz/sources/toonzqt/functionselection.cpp b/toonz/sources/toonzqt/functionselection.cpp index da71db1..883a76b 100644 --- a/toonz/sources/toonzqt/functionselection.cpp +++ b/toonz/sources/toonzqt/functionselection.cpp @@ -558,7 +558,7 @@ void FunctionSelection::doPaste() /*--- カーブの貼り付け時に循環参照をチェックして、駄目ならアラートを返す ---*/ for (int c = 0; c < columnCount; c++) { if (!data->isCircularReferenceFree(c, params[c])) { - DVGui::MsgBox(DVGui::WARNING, tr("There is a circular reference in the definition of the interpolation.")); + DVGui::warning(tr("There is a circular reference in the definition of the interpolation.")); return; } } diff --git a/toonz/sources/toonzqt/functionsheet.cpp b/toonz/sources/toonzqt/functionsheet.cpp index ef49b13..3635b39 100644 --- a/toonz/sources/toonzqt/functionsheet.cpp +++ b/toonz/sources/toonzqt/functionsheet.cpp @@ -664,7 +664,7 @@ void FunctionSheetCellViewer::drawCells(QPainter &painter, int r0, int c0, int r text.append("~"); } -#ifdef WIN32 +#ifdef _WIN32 static QFont font("Arial", 9, QFont::Normal); #else static QFont font("Helvetica", 9, QFont::Normal); @@ -712,7 +712,7 @@ void FunctionSheetCellViewer::mouseDoubleClickEvent(QMouseEvent *e) } else m_lineEdit->setText(""); -#ifdef WIN32 +#ifdef _WIN32 static QFont font("Arial", 9, QFont::Normal); #else static QFont font("Helvetica", 9, QFont::Normal); diff --git a/toonz/sources/toonzqt/gutil.cpp b/toonz/sources/toonzqt/gutil.cpp index e44f932..be5687c 100644 --- a/toonz/sources/toonzqt/gutil.cpp +++ b/toonz/sources/toonzqt/gutil.cpp @@ -264,7 +264,7 @@ bool isValidFileName(const QString &fileName) bool isValidFileName_message(const QString &fileName) { - return isValidFileName(fileName) ? true : (MsgBox(CRITICAL, QObject::tr("The file name cannot be empty or contain any of the following " + return isValidFileName(fileName) ? true : (DVGui::error(QObject::tr("The file name cannot be empty or contain any of the following " "characters: (new line) \\ / : * ? \" |")), false); } diff --git a/toonz/sources/toonzqt/imageutils.cpp b/toonz/sources/toonzqt/imageutils.cpp index 2ef497e..c18ed89 100644 --- a/toonz/sources/toonzqt/imageutils.cpp +++ b/toonz/sources/toonzqt/imageutils.cpp @@ -14,7 +14,7 @@ #include "toonz/tproject.h" #include "toonz/Naa2TlvConverter.h" -#ifdef WIN32 +#ifdef _WIN32 #include "avicodecrestrictions.h" #endif @@ -143,7 +143,7 @@ TFilePath duplicate(const TFilePath &levelPath) return TFilePath(); if (!TSystem::doesExistFileOrLevel(levelPath)) { - MsgBox(WARNING, QObject::tr("It is not possible to find the %1 level.").arg(QString::fromStdWString(levelPath.getWideString()))); + DVGui::warning(QObject::tr("It is not possible to find the %1 level.").arg(QString::fromStdWString(levelPath.getWideString()))); return TFilePath(); } @@ -168,7 +168,7 @@ TFilePath duplicate(const TFilePath &levelPath) } } catch (...) { QString msg = QObject::tr("There was an error copying %1").arg(toQString(levelPath)); - MsgBox(CRITICAL, msg); + DVGui::error(msg); return TFilePath(); } @@ -176,7 +176,7 @@ TFilePath duplicate(const TFilePath &levelPath) // QString::fromStdWString(levelPath.withoutParentDir().getWideString()) + // QString(" to " + // QString::fromStdWString(levelPathOut.withoutParentDir().getWideString())); - // MsgBox(INFORMATION,msg); + // DVGui::info(msg); return levelPathOut; } @@ -189,21 +189,21 @@ void premultiply(const TFilePath &levelPath) return; if (!TSystem::doesExistFileOrLevel(levelPath)) { - MsgBox(WARNING, QObject::tr("It is not possible to find the level %1").arg(QString::fromStdWString(levelPath.getWideString()))); + DVGui::warning(QObject::tr("It is not possible to find the level %1").arg(QString::fromStdWString(levelPath.getWideString()))); return; } TFileType::Type type = TFileType::getInfo(levelPath); if (type == TFileType::CMAPPED_LEVEL) { - MsgBox(WARNING, QObject::tr("Cannot premultiply the selected file.")); + DVGui::warning(QObject::tr("Cannot premultiply the selected file.")); return; } if (type == TFileType::VECTOR_LEVEL || type == TFileType::VECTOR_IMAGE) { - MsgBox(WARNING, QObject::tr("Cannot premultiply a vector-based level.")); + DVGui::warning(QObject::tr("Cannot premultiply a vector-based level.")); return; } if (type != TFileType::RASTER_LEVEL && type != TFileType::RASTER_IMAGE) { - MsgBox(INFORMATION, QObject::tr("Cannot premultiply the selected file.")); + DVGui::info(QObject::tr("Cannot premultiply the selected file.")); return; } @@ -267,14 +267,14 @@ void premultiply(const TFilePath &levelPath) lw->save(level); } } catch (...) { - MsgBox(WARNING, QObject::tr("Cannot premultiply the selected file.")); + DVGui::warning(QObject::tr("Cannot premultiply the selected file.")); QApplication::restoreOverrideCursor(); return; } QApplication::restoreOverrideCursor(); QString msg = QObject::tr("Level %1 premultiplied.").arg(QString::fromStdString(levelPath.getLevelName())); - MsgBox(INFORMATION, msg); + DVGui::info(msg); } //----------------------------------------------------------------------------- @@ -405,7 +405,7 @@ void convertFromCM(const TLevelReaderP &lr, const TPaletteP &plt, const TLevelWr } } catch (...) { //QString msg=QObject::tr("Frame %1 : conversion failed!").arg(QString::number(i+1)); - // MsgBox(INFORMATION,msg); + // DVGui::info(msg); } /*-- これはプログレスバーを進めるものなので、動画番号ではなく、完了したフレームの枚数を投げる --*/ frameNotifier->notifyFrameCompleted(100 * (i + 1) / frames.size()); @@ -429,8 +429,7 @@ void convertFromVI(const TLevelReaderP &lr, const TPaletteP &plt, const TLevelWr maxBbox += img->getBBox(); } catch (...) { msg = QObject::tr("Frame %1 : conversion failed!").arg(QString::fromStdString(frames[i].expand())); - MsgBox(INFORMATION, msg); - ; + DVGui::info(msg); } } maxBbox = maxBbox.enlarge(2); @@ -458,7 +457,7 @@ void convertFromVI(const TLevelReaderP &lr, const TPaletteP &plt, const TLevelWr } } catch (...) { msg = QObject::tr("Frame %1 : conversion failed!").arg(QString::fromStdString(frames[i].expand())); - MsgBox(INFORMATION, msg); + DVGui::info(msg); } frameNotifier->notifyFrameCompleted(100 * (i + 1) / frames.size()); } @@ -534,7 +533,7 @@ void convertFromFullRaster(const TLevelReaderP &lr, const TLevelWriterP &lw, con } } catch (...) { //QString msg=QObject::tr("Frame %1 : conversion failed!").arg(QString::number(i+1)); - //MsgBox(INFORMATION,msg); + //DVGui::info(msg); } /*-- これはプログレスバーを進めるものなので、動画番号ではなく、完了したフレームの枚数を投げる --*/ frameNotifier->notifyFrameCompleted(100 * (i + 1) / frames.size()); @@ -579,7 +578,7 @@ void convertFromVector(const TLevelReaderP &lr, const TLevelWriterP &lw, const v } } catch (...) { //QString msg=QObject::tr("Frame %1 : conversion failed!").arg(QString::number(i+1)); - //MsgBox(INFORMATION,msg); + //DVGui::info(msg); } frameNotifier->notifyFrameCompleted(100 * (i + 1) / frames.size()); } @@ -602,7 +601,7 @@ void convert(const TFilePath &source, const TFilePath &dest, TLevelReaderP lr(source); TLevelP level = lr->loadInfo(); -#ifdef WIN32 +#ifdef _WIN32 if (dstExt == "avi") { TDimension res(0, 0); @@ -614,7 +613,7 @@ void convert(const TFilePath &source, const TFilePath &dest, if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { return; //QString msg=QObject::tr("The image resolution does not fit the chosen output file format."); - //MsgBox(WARNING,msg); + //DVGui::MsgBox(DVGui::WARNING,msg); } } #endif; @@ -697,7 +696,7 @@ void convertNaa2Tlv( TImageWriterP iw = lw->getFrameWriter(frames[f]); iw->save(dstImg); } else { - MsgBox(DVGui::WARNING, QObject::tr( + DVGui::warning(QObject::tr( "The source image seems not suitable for this kind of conversion")); frameNotifier->notifyError(); } diff --git a/toonz/sources/toonzqt/infoviewer.cpp b/toonz/sources/toonzqt/infoviewer.cpp index 6eaf529..14635e9 100644 --- a/toonz/sources/toonzqt/infoviewer.cpp +++ b/toonz/sources/toonzqt/infoviewer.cpp @@ -584,7 +584,7 @@ bool InfoViewerImp::setItem(const TLevelP &level, TPalette *palette, const TFile assert(!m_level); if (!TSystem::doesExistFileOrLevel(m_path)) { - MsgBox(WARNING, QObject::tr("The file %1 does not exist.").arg(QString::fromStdWString(path.getWideString()))); + DVGui::warning(QObject::tr("The file %1 does not exist.").arg(QString::fromStdWString(path.getWideString()))); return false; } diff --git a/toonz/sources/toonzqt/intfield.cpp b/toonz/sources/toonzqt/intfield.cpp index 344b8f0..147929b 100644 --- a/toonz/sources/toonzqt/intfield.cpp +++ b/toonz/sources/toonzqt/intfield.cpp @@ -248,7 +248,7 @@ IntField::IntField(QWidget *parent, bool isMaxRangeLimited, bool isRollerHide) vLayout->setMargin(0); vLayout->setSpacing(0); - m_lineEdit = new IntLineEdit(field); + m_lineEdit = new DVGui::IntLineEdit(field); bool ret = connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); vLayout->addWidget(m_lineEdit); diff --git a/toonz/sources/toonzqt/intpairfield.cpp b/toonz/sources/toonzqt/intpairfield.cpp index 2f55da4..8ee766e 100644 --- a/toonz/sources/toonzqt/intpairfield.cpp +++ b/toonz/sources/toonzqt/intpairfield.cpp @@ -31,10 +31,10 @@ IntPairField::IntPairField(QWidget *parent, bool isMaxRangeLimited) setFixedHeight(WidgetHeight); m_leftLabel = new QLabel("", this); - m_leftLineEdit = new IntLineEdit(this); + m_leftLineEdit = new DVGui::IntLineEdit(this); m_rightLabel = new QLabel("", this); - m_rightLineEdit = new IntLineEdit(this); + m_rightLineEdit = new DVGui::IntLineEdit(this); m_leftLineEdit->setFixedWidth(40); m_rightLineEdit->setFixedWidth(40); diff --git a/toonz/sources/toonzqt/keyframenavigator.cpp b/toonz/sources/toonzqt/keyframenavigator.cpp index 1666a22..d8431cd 100644 --- a/toonz/sources/toonzqt/keyframenavigator.cpp +++ b/toonz/sources/toonzqt/keyframenavigator.cpp @@ -19,7 +19,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #pragma warning(disable : 4251) #endif diff --git a/toonz/sources/toonzqt/lineedit.cpp b/toonz/sources/toonzqt/lineedit.cpp index 8c1c34b..debde80 100644 --- a/toonz/sources/toonzqt/lineedit.cpp +++ b/toonz/sources/toonzqt/lineedit.cpp @@ -45,7 +45,7 @@ void LineEdit::keyPressEvent(QKeyEvent *event) switch (event->key()) { CASE Qt::Key_Backslash : __OR Qt::Key_Slash : __OR Qt::Key_Colon : __OR Qt::Key_Asterisk : __OR Qt::Key_Question : __OR Qt::Key_QuoteDbl : __OR Qt::Key_Greater : __OR Qt::Key_Less : __OR Qt::Key_Bar : __OR Qt::Key_Period: { - DVGui::MsgBox(INFORMATION, tr("A file name cannot contains any of the following chracters: /\\:*?\"<>|.")); + DVGui::info(tr("A file name cannot contains any of the following chracters: /\\:*?\"<>|.")); return; } default: diff --git a/toonz/sources/toonzqt/menubarcommand.cpp b/toonz/sources/toonzqt/menubarcommand.cpp index eea1883..6592ebf 100644 --- a/toonz/sources/toonzqt/menubarcommand.cpp +++ b/toonz/sources/toonzqt/menubarcommand.cpp @@ -317,7 +317,7 @@ void CommandManager::setShortcut(QAction *action, std::string shortcutString) assert(ks.count() == 1 || ks.count() == 0 && shortcut == ""); if (node->m_type == ZoomCommandType && ks.count() > 1) { - MsgBox(WARNING, QObject::tr("It is not possible to assing a shortcut with modifiers to the visualization commands.")); + DVGui::warning(QObject::tr("It is not possible to assing a shortcut with modifiers to the visualization commands.")); return; } // lo shortcut e' gia' assegnato? diff --git a/toonz/sources/toonzqt/palettesscanpopup.cpp b/toonz/sources/toonzqt/palettesscanpopup.cpp index 2c3a6f9..e9f3852 100644 --- a/toonz/sources/toonzqt/palettesscanpopup.cpp +++ b/toonz/sources/toonzqt/palettesscanpopup.cpp @@ -27,7 +27,7 @@ PalettesScanPopup::PalettesScanPopup() setWindowTitle(tr("Search for Palettes")); setFixedWidth(250); - m_field = new FileField(); + m_field = new DVGui::FileField(); addWidget(m_field); m_label = new QLabel(); diff --git a/toonz/sources/toonzqt/palettesscanpopup.h b/toonz/sources/toonzqt/palettesscanpopup.h index 33c5785..abd46d7 100644 --- a/toonz/sources/toonzqt/palettesscanpopup.h +++ b/toonz/sources/toonzqt/palettesscanpopup.h @@ -18,17 +18,15 @@ #define DVVAR DV_IMPORT_VAR #endif -using namespace DVGui; - //============================================================================= // PalettesScanPopup //----------------------------------------------------------------------------- -class DVAPI PalettesScanPopup : public Dialog +class DVAPI PalettesScanPopup : public DVGui::Dialog { Q_OBJECT - FileField *m_field; + DVGui::FileField *m_field; QLabel *m_label; TFilePath m_folderPath; diff --git a/toonz/sources/toonzqt/paletteviewer.cpp b/toonz/sources/toonzqt/paletteviewer.cpp index a82c788..2e488fa 100644 --- a/toonz/sources/toonzqt/paletteviewer.cpp +++ b/toonz/sources/toonzqt/paletteviewer.cpp @@ -866,19 +866,19 @@ void PaletteViewer::saveStudioPalette() StudioPalette *sp = StudioPalette::instance(); TPalette *palette = getPalette(); if (!palette) { - DVGui::MsgBox(DVGui::WARNING, "No current palette"); + DVGui::warning("No current palette"); return; } wstring gname = palette->getGlobalName(); if (gname.empty()) { StudioPaletteViewer *parentSPV = qobject_cast(parentWidget()); if (!parentSPV) { - DVGui::MsgBox(DVGui::WARNING, "No GlobalName"); + DVGui::warning("No GlobalName"); return; } else { TFilePath palettePath = parentSPV->getCurrentItemPath(); if (palettePath.isEmpty()) - DVGui::MsgBox(DVGui::WARNING, "No GlobalName, No Filepath"); + DVGui::warning("No GlobalName, No Filepath"); else { QString question; question = "Do you want to overwrite current palette to " + toQString(palettePath) + " ?"; diff --git a/toonz/sources/toonzqt/pluginhost.cpp b/toonz/sources/toonzqt/pluginhost.cpp index 714d8df..4cd67ff 100644 --- a/toonz/sources/toonzqt/pluginhost.cpp +++ b/toonz/sources/toonzqt/pluginhost.cpp @@ -1,6 +1,3 @@ -#ifdef _MSC_VER -#define NOMINMAX -#endif #include #include #include @@ -132,7 +129,6 @@ PluginInformation::~PluginInformation() fin_(); } } - delete[] param_pages_; } void PluginInformation::add_ref() @@ -818,7 +814,7 @@ bool RasterFxPluginHost::setParamStructure(int n, toonz_param_page_t *p, int &er param_resources.clear(); - toonz_param_page_t *origin_pages = new toonz_param_page_t[n]; + std::unique_ptr origin_pages(new toonz_param_page_t[n]); for (int i = 0; i < n; i++) { toonz_param_page_t &dst_page = origin_pages[i]; const toonz_param_page_t &src_page = p[i]; @@ -876,7 +872,7 @@ bool RasterFxPluginHost::setParamStructure(int n, toonz_param_page_t *p, int &er } pi_->param_page_num_ = n; - pi_->param_pages_ = origin_pages; + pi_->param_pages_ = std::move(origin_pages); return true; } return false; diff --git a/toonz/sources/toonzqt/pluginhost.h b/toonz/sources/toonzqt/pluginhost.h index ccbdab9..d3dfd28 100644 --- a/toonz/sources/toonzqt/pluginhost.h +++ b/toonz/sources/toonzqt/pluginhost.h @@ -86,7 +86,7 @@ public: void (*fin_)(void); int ref_count_; int param_page_num_; - toonz_param_page_t *param_pages_; + std::unique_ptr param_pages_; std::vector ui_pages_; std::vector param_views_; @@ -96,7 +96,7 @@ public: std::vector> param_string_tbl_; /* shared_ptr< void > では non-virtual destructor が呼ばれないので */ public: - PluginInformation() : desc_(NULL), library_(NULL), handler_(NULL), host_(NULL), ini_(NULL), fin_(NULL), ref_count_(1), param_page_num_(0), param_pages_(NULL) + PluginInformation() : desc_(NULL), library_(NULL), handler_(NULL), host_(NULL), ini_(NULL), fin_(NULL), ref_count_(1), param_page_num_(0) { } diff --git a/toonz/sources/toonzqt/spreadsheetviewer.cpp b/toonz/sources/toonzqt/spreadsheetviewer.cpp index 7a9a4c1..06bf19e 100644 --- a/toonz/sources/toonzqt/spreadsheetviewer.cpp +++ b/toonz/sources/toonzqt/spreadsheetviewer.cpp @@ -285,7 +285,7 @@ DragTool *RowPanel::createDragTool(QMouseEvent *) void RowPanel::drawRows(QPainter &p, int r0, int r1) { -#ifdef WIN32 +#ifdef _WIN32 static QFont font("Arial", 9, QFont::Bold); #else static QFont font("Helvetica", 9, QFont::Bold); diff --git a/toonz/sources/toonzqt/stageschematicscene.cpp b/toonz/sources/toonzqt/stageschematicscene.cpp index 12d334c..7408a84 100644 --- a/toonz/sources/toonzqt/stageschematicscene.cpp +++ b/toonz/sources/toonzqt/stageschematicscene.cpp @@ -1021,7 +1021,7 @@ void StageSchematicScene::onSaveSpline() os << p.x << p.y << p.thick; } } catch (...) { - DVGui::MsgBox(DVGui::WARNING, QObject::tr("It is not possible to save the motion path.")); + DVGui::warning(QObject::tr("It is not possible to save the motion path.")); } #endif } @@ -1043,7 +1043,7 @@ void StageSchematicScene::onLoadSpline() if (!TFileStatus(fp).doesExist()) { QString msg; msg = "Motion path " + toQString(fp) + " doesn't exists."; - MsgBox(DVGui::INFORMATION, msg); + DVGui::info(msg); return; } assert(m_objHandle->isSpline()); @@ -1063,7 +1063,7 @@ void StageSchematicScene::onLoadSpline() IconGenerator::instance()->invalidate(spline); } } catch (...) { - DVGui::MsgBox(DVGui::WARNING, QObject::tr("It is not possible to load the motion path.")); + DVGui::warning(QObject::tr("It is not possible to load the motion path.")); } } diff --git a/toonz/sources/toonzqt/studiopaletteviewer.cpp b/toonz/sources/toonzqt/studiopaletteviewer.cpp index a8b4052..e29dbb1 100644 --- a/toonz/sources/toonzqt/studiopaletteviewer.cpp +++ b/toonz/sources/toonzqt/studiopaletteviewer.cpp @@ -482,7 +482,7 @@ void StudioPaletteTreeViewer::onCurrentItemChanged(QTreeWidgetItem *current, QTr wstring gname = m_currentPalette->getGlobalName(); QString question; question = "The current palette " + QString::fromStdWString(oldPath.getWideString()) + " \nin the studio palette has been modified. Do you want to save your changes?"; - int ret = MsgBox(question, QObject::tr("Save"), QObject::tr("Discard"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Save"), QObject::tr("Discard"), QObject::tr("Cancel"), 0); if (ret == 3) { setCurrentItem(getItem(oldPath)); return; @@ -564,7 +564,7 @@ void StudioPaletteTreeViewer::convertToStudioPalette() QString question; question = QString::fromStdWString(L"Convert " + path.getWideString() + L" to Studio Palette and Overwrite. \nAre you sure ?"); - int ret = MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); + int ret = DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); if (ret == 0 || ret == 2) return; @@ -594,7 +594,7 @@ void StudioPaletteTreeViewer::deleteItem(QTreeWidgetItem *item) if (item->childCount() > 0) { QString question; question = tr("This folder is not empty. Delete anyway?"); - int ret = MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); + int ret = DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); if (ret == 0 || ret == 2) return; } @@ -688,7 +688,7 @@ public: //----------------------------------------------------------------------------- -class AdjustPaletteDialog : public Dialog +class AdjustPaletteDialog : public DVGui::Dialog { private: IntField *m_tolerance; @@ -771,7 +771,7 @@ void StudioPaletteTreeViewer::loadInCurrentPalette() return; if (palette->isLocked()) { - MsgBox(WARNING, "Palette is Locked!"); + DVGui::warning("Palette is Locked!"); return; } @@ -828,7 +828,7 @@ void StudioPaletteTreeViewer::replaceCurrentPalette() label = QString::fromStdWString(L"Replacing the palette \"" + dstPalette->getPaletteName() + L"\" with the palette \"" + current->getPaletteName() + L"\". \nAre you sure ?"); } - int ret = MsgBox(label, QObject::tr("Replace"), QObject::tr("Cancel"), 1); + int ret = DVGui::MsgBox(label, QObject::tr("Replace"), QObject::tr("Cancel"), 1); if (ret == 0 || ret == 2) return; diff --git a/toonz/sources/toonzqt/styleeditor.cpp b/toonz/sources/toonzqt/styleeditor.cpp index d3d93ad..955aeed 100644 --- a/toonz/sources/toonzqt/styleeditor.cpp +++ b/toonz/sources/toonzqt/styleeditor.cpp @@ -2883,7 +2883,7 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent) TFilePath libraryPath = ToonzFolder::getLibraryFolder(); setRootPath(libraryPath); - m_styleBar = new TabBar(this); + m_styleBar = new DVGui::TabBar(this); m_styleBar->setDrawBase(false); m_styleBar->setObjectName("StyleEditorTabBar"); @@ -3004,8 +3004,8 @@ QFrame *StyleEditor::createBottomWidget() { QFrame *bottomWidget = new QFrame(this); m_autoButton = new QPushButton(tr("Auto \nApply")); - m_oldColor = new StyleSample(this, 42, 20); - m_newColor = new StyleSample(this, 42, 20); + m_oldColor = new DVGui::StyleSample(this, 42, 20); + m_newColor = new DVGui::StyleSample(this, 42, 20); m_applyButton = new QPushButton(tr("Apply")); bottomWidget->setFrameStyle(QFrame::StyledPanel); diff --git a/toonz/sources/toonzqt/styleselection.cpp b/toonz/sources/toonzqt/styleselection.cpp index e757c27..2eb7e7a 100644 --- a/toonz/sources/toonzqt/styleselection.cpp +++ b/toonz/sources/toonzqt/styleselection.cpp @@ -1093,7 +1093,7 @@ void TStyleSelection::pasteStylesValues(bool pasteName, bool pasteColor) int dataStyleCount = data->getStyleCount(); if (dataStyleCount > (int)m_styleIndicesInPage.size()) { QString question = QObject::tr("There are more cut/copied styles than selected. Paste anyway (adding styles)?"); - int ret = MsgBox(question, QObject::tr("Paste"), QObject::tr("Cancel"), 0); + int ret = DVGui::MsgBox(question, QObject::tr("Paste"), QObject::tr("Cancel"), 0); if (ret == 2 || ret == 0) return; } diff --git a/toonz/sources/toonzqt/tmessageviewer.cpp b/toonz/sources/toonzqt/tmessageviewer.cpp index 489fab5..3a4c773 100644 --- a/toonz/sources/toonzqt/tmessageviewer.cpp +++ b/toonz/sources/toonzqt/tmessageviewer.cpp @@ -118,15 +118,15 @@ void TMessageRepository::messageReceived(int type, const QString &message) } switch (type) { - case INFORMATION: + case DVGui::INFORMATION: m_sim->appendRow(new QStandardItem(gGreenIcon, message)); - CASE WARNING : m_sim->appendRow(new QStandardItem(gYellowIcon, message)); - CASE CRITICAL : m_sim->appendRow(new QStandardItem(gRedIcon, message)); + CASE DVGui::WARNING : m_sim->appendRow(new QStandardItem(gYellowIcon, message)); + CASE DVGui::CRITICAL : m_sim->appendRow(new QStandardItem(gRedIcon, message)); DEFAULT:; } - if (type == CRITICAL || (type == WARNING && !TMessageViewer::isTMsgVisible())) - MsgBoxInPopup(MsgType(type), message); + if (type == DVGui::CRITICAL || (type == DVGui::WARNING && !TMessageViewer::isTMsgVisible())) + DVGui::MsgBoxInPopup(DVGui::MsgType(type), message); } //---------------------------------------------------------------------------------