Skip to content

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

C

fix crash on launch with shrinked imageviewer

shun-iwasawa034d1756591f
diff --git a/toonz/sources/toonz/imageviewer.cpp b/toonz/sources/toonz/imageviewer.cpp
index 7820a2354..85f390268 100644
--- a/toonz/sources/toonz/imageviewer.cpp
+++ b/toonz/sources/toonz/imageviewer.cpp
@@ -1345,6 +1345,8 @@ void ImageViewer::onContextAboutToBeDestroyed() {
makeCurrent();
m_lutCalibrator->cleanup();
doneCurrent();
+ disconnect(context(), SIGNAL(aboutToBeDestroyed()), this,
+ SLOT(onContextAboutToBeDestroyed()));
}
//-----------------------------------------------------------------------------
@@ -1352,6 +1354,9 @@ void ImageViewer::onContextAboutToBeDestroyed() {
void ImageViewer::onPreferenceChanged(const QString &prefName) {
if (prefName == "ColorCalibration") {
if (Preferences::instance()->isColorCalibrationEnabled()) {
+ // if the window is so shriked that the gl widget is empty,
+ // showEvent can be called before creating the context.
+ if (!context()) return;
makeCurrent();
if (!m_lutCalibrator)
m_lutCalibrator = new LutCalibrator();
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index 0a58169dd..799d42ffb 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -1201,6 +1201,9 @@ void SceneViewer::onStopMotionLiveViewStopped() {
void SceneViewer::onPreferenceChanged(const QString &prefName) {
if (prefName == "ColorCalibration") {
if (Preferences::instance()->isColorCalibrationEnabled()) {
+ // if the window is so shriked that the gl widget is empty,
+ // showEvent can be called before creating the context.
+ if (!context()) return;
makeCurrent();
if (!m_lutCalibrator)
m_lutCalibrator = new LutCalibrator();
@@ -3271,6 +3274,8 @@ void SceneViewer::onContextAboutToBeDestroyed() {
makeCurrent();
m_lutCalibrator->cleanup();
doneCurrent();
+ disconnect(context(), SIGNAL(aboutToBeDestroyed()), this,
+ SLOT(onContextAboutToBeDestroyed()));
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonzqt/styleeditor.cpp b/toonz/sources/toonzqt/styleeditor.cpp
index 4d01f35c9..e05508a22 100644
--- a/toonz/sources/toonzqt/styleeditor.cpp
+++ b/toonz/sources/toonzqt/styleeditor.cpp
@@ -900,6 +900,8 @@ void HexagonalColorWheel::onContextAboutToBeDestroyed() {
makeCurrent();
m_lutCalibrator->cleanup();
doneCurrent();
+ disconnect(context(), SIGNAL(aboutToBeDestroyed()), this,
+ SLOT(onContextAboutToBeDestroyed()));
}
//*****************************************************************************