Skip to content

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

C

fix tapetool crash (#2352)

shun-iwasawa102e06551577
diff --git a/toonz/sources/include/toonzqt/styleindexlineedit.h b/toonz/sources/include/toonzqt/styleindexlineedit.h
index 7dd843801..f746286cd 100644
--- a/toonz/sources/include/toonzqt/styleindexlineedit.h
+++ b/toonz/sources/include/toonzqt/styleindexlineedit.h
@@ -25,6 +25,8 @@ class TPaletteHandle;
namespace DVGui {
class DVAPI StyleIndexLineEdit : public LineEdit {
+ Q_OBJECT
+
TPaletteHandle *m_pltHandle;
public:
diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cpp
index b34af7d83..bee24dc2b 100644
--- a/toonz/sources/tnztools/tooloptionscontrols.cpp
+++ b/toonz/sources/tnztools/tooloptionscontrols.cpp
@@ -868,15 +868,16 @@ void StyleIndexFieldAndChip::onValueChanged(const QString &changedText) {
// Aware of both "current" and translated string
if (!QString("current").contains(changedText) &&
!StyleIndexLineEdit::tr("current").contains(changedText)) {
- int index = changedText.toInt();
- TPalette *plt = m_pltHandle->getPalette();
- int indexCount = plt->getStyleCount();
- if (index > indexCount)
- style = QString::number(indexCount - 1);
+ int index = changedText.toInt();
+ TPalette *plt = m_pltHandle->getPalette();
+ if (plt && index > plt->getStyleCount())
+ style = QString::number(plt->getStyleCount() - 1);
else
style = text();
- }
- m_property->setValue(style.toStdWString());
+ m_property->setValue(style.toStdWString());
+ } else
+ m_property->setValue(changedText.toStdWString());
+
repaint();
// synchronize the state with the same widgets in other tool option bars
if (m_toolHandle) m_toolHandle->notifyToolChanged();
diff --git a/toonz/sources/toonzqt/styleindexlineedit.cpp b/toonz/sources/toonzqt/styleindexlineedit.cpp
index e2a67fb63..f294d58ce 100644
--- a/toonz/sources/toonzqt/styleindexlineedit.cpp
+++ b/toonz/sources/toonzqt/styleindexlineedit.cpp
@@ -30,6 +30,8 @@ StyleIndexLineEdit::~StyleIndexLineEdit() {}
void StyleIndexLineEdit::paintEvent(QPaintEvent *pe) {
QLineEdit::paintEvent(pe);
+ if (!m_pltHandle->getPalette()) return;
+
TColorStyle *style;
// Aware of both "current" and translated string
if (QString("current").contains(text()) || tr("current").contains(text()))