Skip to content

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

C

take another way for the level strip crash on quit

shun-iwasawab8f11a5590d9
diff --git a/toonz/sources/toonz/filmstrip.cpp b/toonz/sources/toonz/filmstrip.cpp
index 34ccd674b..8fad7c6e1 100644
--- a/toonz/sources/toonz/filmstrip.cpp
+++ b/toonz/sources/toonz/filmstrip.cpp
@@ -486,11 +486,7 @@ void FilmstripFrames::hideEvent(QHideEvent *) {
// active viewer change
disconnect(app, SIGNAL(activeViewerChanged()), this, SLOT(getViewer()));
- // if the level strip is floating during shutting down Tahoma2D
- // it can cause a crash disconnecting from the viewer which was already
- // destroyed. Checking the fps is a janky way to ensure the viewer is
- // stil relevant.
- if (m_viewer && m_viewer->getFPS() > -100) {
+ if (m_viewer) {
disconnect(m_viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
disconnect(m_viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
m_viewer = nullptr;
@@ -505,6 +501,8 @@ void FilmstripFrames::getViewer() {
if (m_viewer) {
disconnect(m_viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
disconnect(m_viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
+ disconnect(m_viewer, SIGNAL(aboutToBeDestroyed()), this,
+ SLOT(onViewerAboutToBeDestroyed()));
}
viewerChanged = true;
}
@@ -514,6 +512,8 @@ void FilmstripFrames::getViewer() {
if (m_viewer && viewerChanged) {
connect(m_viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
connect(m_viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
+ connect(m_viewer, SIGNAL(aboutToBeDestroyed()), this,
+ SLOT(onViewerAboutToBeDestroyed()));
update();
}
}
@@ -1495,6 +1495,16 @@ void FilmstripFrames::inbetween() {
FilmstripCmd::inbetween(getLevel(), range.first, range.second, interpolation);
}
+//-----------------------------------------------------------------------------
+
+void FilmstripFrames::onViewerAboutToBeDestroyed() {
+ if (m_viewer) {
+ disconnect(m_viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
+ disconnect(m_viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
+ m_viewer = nullptr;
+ }
+}
+
//=============================================================================
// Filmstrip
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonz/filmstrip.h b/toonz/sources/toonz/filmstrip.h
index fb3cb97d0..57a4416d0 100644
--- a/toonz/sources/toonz/filmstrip.h
+++ b/toonz/sources/toonz/filmstrip.h
@@ -172,6 +172,7 @@ protected slots:
void comboBoxToggled(bool);
void navigatorToggled(bool);
void levelSelected(int);
+ void onViewerAboutToBeDestroyed();
private:
// QSS Properties
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index edfbd25f8..4316da227 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -831,6 +831,9 @@ void SceneViewer::setVisual(const ImagePainter::VisualSettings &settings) {
//-----------------------------------------------------------------------------
SceneViewer::~SceneViewer() {
+ // notify FilmStripFrames and safely disconnect with this
+ emit aboutToBeDestroyed();
+
if (m_fbo) delete m_fbo;
// release all the registered context (once when exit the software)
diff --git a/toonz/sources/toonz/sceneviewer.h b/toonz/sources/toonz/sceneviewer.h
index c52d8e385..d2000419b 100644
--- a/toonz/sources/toonz/sceneviewer.h
+++ b/toonz/sources/toonz/sceneviewer.h
@@ -460,6 +460,8 @@ signals:
void refreshNavi();
// for updating the titlebar
void previewToggled();
+ // to notify FilmStripFrames and safely disconnect with this
+ void aboutToBeDestroyed();
};
// Functions