Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Added tool deactivation during undo to avoid tool on nonexistent layer crash

Dennis Lam3fbd10700da3
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index 821c8df22..102c1d43e 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -934,6 +934,13 @@ Room *MainWindow::getCurrentRoom() const {
//-----------------------------------------------------------------------------
void MainWindow::onUndo() {
+ ToolHandle *toolH = TApp::instance()->getCurrentTool();
+
+ // end tool use to avoid applying tool on removed layer on undo
+ if (toolH->isToolBusy()) {
+ toolH->getTool()->onDeactivate();
+ }
+
bool ret = TUndoManager::manager()->undo();
if (!ret) DVGui::error(QObject::tr("No more Undo operations available."));
}