Skip to content

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

C

Fix crash by catching exceptions and skipping frames with bad names. Show warning with skips to message center (#966)

jabarrera96d45ce5a195
diff --git a/toonz/sources/common/timage_io/tlevel_io.cpp b/toonz/sources/common/timage_io/tlevel_io.cpp
index 7d5666b1b..0a4ba5e31 100644
--- a/toonz/sources/common/timage_io/tlevel_io.cpp
+++ b/toonz/sources/common/timage_io/tlevel_io.cpp
@@ -5,6 +5,7 @@
#include "tiio.h"
#include "tcontenthistory.h"
#include "tconvert.h"
+#include "tmsgcore.h"
// STD includes
#include <map>
@@ -118,8 +119,13 @@ TLevelP TLevelReader::loadInfo() {
try {
level->setFrame(it->getFrame(), TImageP());
data.push_back(*it);
- } catch (string msg) {
- throw msg;
+ } catch (TMalformedFrameException tmfe) {
+ // skip frame named incorrectly warning to the user in the message
+ // center.
+ DVGui::warning(QString::fromStdWString(
+ tmfe.getMessage() + L": " +
+ QObject::tr("Skipping frame.").toStdWString()));
+ continue;
}
}
}
diff --git a/toonz/sources/common/tsystem/tfilepath.cpp b/toonz/sources/common/tsystem/tfilepath.cpp
index d16a1a324..37afe9724 100644
--- a/toonz/sources/common/tsystem/tfilepath.cpp
+++ b/toonz/sources/common/tsystem/tfilepath.cpp
@@ -24,6 +24,9 @@ const char wauxslash = '\\';
#include <cctype>
#include <sstream>
+// QT
+#include <QObject>
+
bool TFilePath::m_underscoreFormatAllowed = true;
namespace {
@@ -634,7 +637,10 @@ TFrameId TFilePath::getFrame() const {
if (iswalpha(str[k])) letter = str[k++] + ('a' - L'a');
if (number == 0 || k < i) // || letter!='\0')
- throw(::to_string(m_path) + ": malformed frame name.");
+ throw TMalformedFrameException(
+ *this,
+ str + L": " + QObject::tr("Malformed frame name").toStdWString());
+
return TFrameId(number, letter);
}
diff --git a/toonz/sources/toonz/filebrowser.cpp b/toonz/sources/toonz/filebrowser.cpp
index 73f7f9a80..86ddcd7be 100644
--- a/toonz/sources/toonz/filebrowser.cpp
+++ b/toonz/sources/toonz/filebrowser.cpp
@@ -599,6 +599,18 @@ void FileBrowser::refreshCurrentFolderItems() {
m_multiFileItemMap.clear();
for (it = all_files.begin(); it != all_files.end(); it++) {
+ TFrameId tFrameId;
+ try {
+ tFrameId = it->getFrame();
+ } catch (TMalformedFrameException tmfe) {
+ // Incorrect frame name sequence. Warning to the user in the message
+ // center.
+ DVGui::warning(QString::fromStdWString(
+ tmfe.getMessage() + L": " +
+ QObject::tr("Skipping frame.").toStdWString()));
+ continue;
+ }
+
TFilePath levelName(it->getLevelName());
if (levelName.isLevelName()) {
@@ -618,7 +630,7 @@ void FileBrowser::refreshCurrentFolderItems() {
levelItem.m_fileSize += fileInfo.size();
// store frameId
- levelItem.m_frameIds.push_back(it->getFrame());
+ levelItem.m_frameIds.push_back(tFrameId);
levelItem.m_frameCount++;
}