From 3e5bb9d0450255d63debe62612886761f7fd25e1 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Mar 19 2021 15:03:04 +0000 Subject: fix pasting raster to cell --- diff --git a/toonz/sources/toonz/cellselection.cpp b/toonz/sources/toonz/cellselection.cpp index a05078c..608fce3 100644 --- a/toonz/sources/toonz/cellselection.cpp +++ b/toonz/sources/toonz/cellselection.cpp @@ -639,6 +639,8 @@ bool pasteRasterImageInCellWithoutUndo(int row, int col, app->getCurrentLevel()->setLevel(sl); app->getCurrentLevel()->notifyLevelChange(); sl->save(); + // after saving you need to obtain the image again + img = sl->getFrame(fid, true); } else { img = sl->createEmptyFrame(); assert(img); @@ -648,6 +650,8 @@ bool pasteRasterImageInCellWithoutUndo(int row, int col, sl->setFrame(fid, img); } xsh->setCell(row, col, TXshCell(sl, fid)); + // to let the undo to know which frame is edited + TTool::m_cellsData.push_back({row, row, TTool::CellOps::BlankToNew}); } else { sl = cell.getSimpleLevel(); fid = cell.getFrameId(); @@ -1630,6 +1634,9 @@ static void pasteStrokesInCell(int row, int col, static void pasteRasterImageInCell(int row, int col, const RasterImageData *rasterImageData) { + // to let the undo to know which frame is edited + TTool::m_cellsData.clear(); + TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); TXshCell cell = xsh->getCell(row, col); bool createdFrame = false; diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index 1bc2edd..ac8e1e6 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -1964,7 +1964,7 @@ TImageP TXshSimpleLevel::createEmptyFrame() { // manner as createNewLevel() in order to avoid crash. This can be happened if // the level was not saved after creating and being placed in the xsheet. if (isEmpty()) { - initializePalette(); + if (!getPalette()) initializePalette(); initializeResolutionAndDpi(); }