Skip to content

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

C

fix crash on setting negative frame

shun_iwasawaf507ce9c582b
diff --git a/toonz/sources/toonz/previewer.cpp b/toonz/sources/toonz/previewer.cpp
index 738bfb274..5ee810c1c 100644
--- a/toonz/sources/toonz/previewer.cpp
+++ b/toonz/sources/toonz/previewer.cpp
@@ -1139,6 +1139,7 @@ void Previewer::saveRenderedFrames() {
/*! Restituisce un puntatore al raster randerizzato se il frame e' disponibile,
altrimenti comincia a calcolarlo*/
TRasterP Previewer::getRaster(int frame, bool renderIfNeeded) const {
+ if (frame < 0) return TRasterP();
std::map<int, Imp::FrameInfo>::iterator it = m_imp->m_frames.find(frame);
if (it != m_imp->m_frames.end()) {
if (frame < m_imp->m_pbStatus.size()) {
@@ -1183,7 +1184,7 @@ TRasterP Previewer::getRaster(int frame, bool renderIfNeeded) const {
//! Verifica se \b frame e' nella cache, cioe' se il frame e' disponibile
bool Previewer::isFrameReady(int frame) const {
- if (frame >= (int)m_imp->m_pbStatus.size()) return false;
+ if (frame < 0 || frame >= (int)m_imp->m_pbStatus.size()) return false;
return m_imp->m_pbStatus[frame] == FlipSlider::PBFrameFinished;
}
diff --git a/toonz/sources/toonz/viewerpane.cpp b/toonz/sources/toonz/viewerpane.cpp
index da1bfa94c..316976cba 100644
--- a/toonz/sources/toonz/viewerpane.cpp
+++ b/toonz/sources/toonz/viewerpane.cpp
@@ -205,7 +205,7 @@ void SceneViewerPanel::onDrawFrame(
}
}
- assert(frame >= 0);
+ // assert(frame >= 0); // frame can be negative in rare cases
if (frame != frameHandle->getFrameIndex() + 1) {
int oldFrame = frameHandle->getFrame();
frameHandle->setCurrentFrame(frame);