From db07e6fcb00f93592fcb78e91184a887daded231 Mon Sep 17 00:00:00 2001 From: Mienek Date: Tue, 28 Jan 2020 11:52:15 +0100 Subject: [PATCH 1/2] first fix history works again, can load deleted layer --- knownBugs.txt | 2 +- src/GUI/IntelliPhotoGui.cpp | 1 + src/Layer/PaintingArea.cpp | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/knownBugs.txt b/knownBugs.txt index 824bf08..791709e 100644 --- a/knownBugs.txt +++ b/knownBugs.txt @@ -1,4 +1,4 @@ history tool doesnt load polygon data on undo iff project was loaded -history tool doesnt save delete Layer +history tool doesnt save delete Layer - done Gradient breaks Heap Size, when big Witdh and Height (appeared on 1280x720) Heap block at 0000000025422990 modified at 0000000025422A28 past requested size of 88 \ No newline at end of file diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index d3ab832..a5fed3d 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -158,6 +158,7 @@ void IntelliPhotoGui::slotDeleteLayer(){ // Create New Layer if(ok1) { paintingArea->deleteLayer(layerNumber - 1); + paintingArea->historyadd(); UpdateGui(); } } diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 1b4236b..79e3cae 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -524,6 +524,10 @@ void PaintingArea::historyGoBack(){ if (historyPresent != historyMaxPast) { if (--historyPresent == -1) historyPresent = 99; + if (layerBundle.size() > history[static_cast(historyPresent)].size()) + activeLayer--; + if ((layerBundle.size() == 0) && (layerBundle.size() < history[static_cast(historyPresent)].size())) + activeLayer++; layerBundle = history[static_cast(historyPresent)]; } this->guiReference->UpdateGui(); @@ -533,6 +537,10 @@ void PaintingArea::historyGoForward(){ if (historyPresent != historyMaxFuture) { if (++historyPresent == 100) historyPresent = 0; + if (layerBundle.size() > history[static_cast(historyPresent)].size()) + activeLayer--; + if ((layerBundle.size() == 0) && (layerBundle.size() < history[static_cast(historyPresent)].size())) + activeLayer++; layerBundle = history[static_cast(historyPresent)]; } this->guiReference->UpdateGui(); From 3eb61abb94c7e77b8823ee7d408512c8949c85cf Mon Sep 17 00:00:00 2001 From: Mienek Date: Thu, 30 Jan 2020 12:17:28 +0100 Subject: [PATCH 2/2] second fix all kown bugs according to history, fixed --- src/GUI/IntelliPhotoGui.cpp | 2 ++ src/IntelliHelper/IntelliDatamanager.cpp | 1 + src/Layer/PaintingArea.cpp | 17 ++++++++++------- src/Layer/PaintingArea.h | 3 +-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index a5fed3d..e199057 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -103,6 +103,7 @@ void IntelliPhotoGui::slotCreateNewRasterLayer(){ // Create New Layer if (ok1&&ok2) { paintingArea->addLayer(width,height,0,0,255,ImageType::RASTERIMAGE); + paintingArea->historyadd(); UpdateGui(); } } @@ -122,6 +123,7 @@ void IntelliPhotoGui::slotCreateNewShapedLayer(){ // Create New Layer if (ok1&&ok2) { paintingArea->addLayer(width, height, 0, 0,255, ImageType::SHAPEDIMAGE); + paintingArea->historyadd(); UpdateGui(); } } diff --git a/src/IntelliHelper/IntelliDatamanager.cpp b/src/IntelliHelper/IntelliDatamanager.cpp index a704f64..828c0ee 100644 --- a/src/IntelliHelper/IntelliDatamanager.cpp +++ b/src/IntelliHelper/IntelliDatamanager.cpp @@ -94,6 +94,7 @@ bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){ } Canvas->setRenderSettings(static_cast(rendersetting)); openFile.close(); + Canvas->historyadd(); return true; } diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 79e3cae..ff8696a 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -106,7 +106,6 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff } this->layerBundle.push_back(newLayer); activeLayer = static_cast(layerBundle.size()) - 1; - historyadd(); return activeLayer; } @@ -524,10 +523,12 @@ void PaintingArea::historyGoBack(){ if (historyPresent != historyMaxPast) { if (--historyPresent == -1) historyPresent = 99; + if (activeLayer == -1) + activeLayer = 0; if (layerBundle.size() > history[static_cast(historyPresent)].size()) - activeLayer--; - if ((layerBundle.size() == 0) && (layerBundle.size() < history[static_cast(historyPresent)].size())) - activeLayer++; + activeLayer = static_cast(history[static_cast(historyPresent)].size())-1; + if (history[static_cast(historyPresent)].size() == 0) + activeLayer = -1; layerBundle = history[static_cast(historyPresent)]; } this->guiReference->UpdateGui(); @@ -537,10 +538,12 @@ void PaintingArea::historyGoForward(){ if (historyPresent != historyMaxFuture) { if (++historyPresent == 100) historyPresent = 0; + if (activeLayer == -1) + activeLayer = 0; if (layerBundle.size() > history[static_cast(historyPresent)].size()) - activeLayer--; - if ((layerBundle.size() == 0) && (layerBundle.size() < history[static_cast(historyPresent)].size())) - activeLayer++; + activeLayer = static_cast(history[static_cast(historyPresent)].size())-1; + if (history[static_cast(historyPresent)].size() == 0) + activeLayer = -1; layerBundle = history[static_cast(historyPresent)]; } this->guiReference->UpdateGui(); diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 6aafff1..03dfc79 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -223,6 +223,7 @@ std::vector* getLayerBundle(); IntelliToolsettings Toolsettings; IntelliColorPicker colorPicker; +void historyadd(); void historyGoBack(); void historyGoForward(); @@ -285,8 +286,6 @@ int historyMaxPast = 0; int historyMaxFuture = 0; int historyPresent = 0; -void historyadd(); - }; #endif