From b8f11a5590d96615235aa96e064e661275c63693 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Dec 16 2020 09:21:40 +0000 Subject: take another way for the level strip crash on quit --- diff --git a/toonz/sources/toonz/filmstrip.cpp b/toonz/sources/toonz/filmstrip.cpp index 34ccd67..8fad7c6 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 fb3cb97..57a4416 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 edfbd25..4316da2 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 c52d8e3..d200041 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