Skip to content

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

C

Fix loading preset switching back to custom

manongjohn5a22686c0a05
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cpp
index 1d013008c..95a4e57dc 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.cpp
+++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp
@@ -578,6 +578,8 @@ void FullColorBrushTool::setWorkAndBackupImages() {
//------------------------------------------------------------------
bool FullColorBrushTool::onPropertyChanged(std::string propertyName) {
+ if (m_propertyUpdating) return true;
+
updateCurrentStyle();
if (propertyName == "Preset:") {
@@ -587,7 +589,9 @@ bool FullColorBrushTool::onPropertyChanged(std::string propertyName) {
loadLastBrush();
FullcolorBrushPreset = m_preset.getValueAsString();
+ m_propertyUpdating = true;
getApplication()->getCurrentTool()->notifyToolChanged();
+ m_propertyUpdating = false;
return true;
}
@@ -605,7 +609,9 @@ bool FullColorBrushTool::onPropertyChanged(std::string propertyName) {
if (m_preset.getValue() != CUSTOM_WSTR) {
m_preset.setValue(CUSTOM_WSTR);
FullcolorBrushPreset = m_preset.getValueAsString();
+ m_propertyUpdating = true;
getApplication()->getCurrentTool()->notifyToolChanged();
+ m_propertyUpdating = false;
}
return true;
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.h b/toonz/sources/tnztools/fullcolorbrushtool.h
index b4df3c93a..414aff9c7 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.h
+++ b/toonz/sources/tnztools/fullcolorbrushtool.h
@@ -122,6 +122,8 @@ protected:
bool m_firstTime;
bool m_mousePressed = false;
TMouseEvent m_mouseEvent;
+
+ bool m_propertyUpdating = false;
};
//------------------------------------------------------------
diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp
index ffb70f37d..3009998a6 100644
--- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp
+++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp
@@ -1936,14 +1936,18 @@ void ToonzRasterBrushTool::setWorkAndBackupImages() {
//------------------------------------------------------------------
bool ToonzRasterBrushTool::onPropertyChanged(std::string propertyName) {
+ if (m_propertyUpdating) return true;
+
if (propertyName == m_preset.getName()) {
if (m_preset.getValue() != CUSTOM_WSTR)
loadPreset();
else // Chose <custom>, go back to last saved brush settings
loadLastBrush();
- RasterBrushPreset = m_preset.getValueAsString();
+ RasterBrushPreset = m_preset.getValueAsString();
+ m_propertyUpdating = true;
getApplication()->getCurrentTool()->notifyToolChanged();
+ m_propertyUpdating = false;
return true;
}
@@ -1980,8 +1984,10 @@ bool ToonzRasterBrushTool::onPropertyChanged(std::string propertyName) {
if (m_preset.getValue() != CUSTOM_WSTR) {
m_preset.setValue(CUSTOM_WSTR);
- RasterBrushPreset = m_preset.getValueAsString();
+ RasterBrushPreset = m_preset.getValueAsString();
+ m_propertyUpdating = true;
getApplication()->getCurrentTool()->notifyToolChanged();
+ m_propertyUpdating = false;
}
return true;
diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.h b/toonz/sources/tnztools/toonzrasterbrushtool.h
index ece7ca3d6..0e8eaeff5 100644
--- a/toonz/sources/tnztools/toonzrasterbrushtool.h
+++ b/toonz/sources/tnztools/toonzrasterbrushtool.h
@@ -223,6 +223,8 @@ protected:
QElapsedTimer m_brushTimer;
int m_minCursorThick, m_maxCursorThick;
+ bool m_propertyUpdating = false;
+
protected:
static void drawLine(const TPointD &point, const TPointD &centre,
bool horizontal, bool isDecimal);
diff --git a/toonz/sources/tnztools/toonzvectorbrushtool.cpp b/toonz/sources/tnztools/toonzvectorbrushtool.cpp
index bfaee3674..2653acbe0 100644
--- a/toonz/sources/tnztools/toonzvectorbrushtool.cpp
+++ b/toonz/sources/tnztools/toonzvectorbrushtool.cpp
@@ -1438,6 +1438,8 @@ void ToonzVectorBrushTool::resetFrameRange() {
//------------------------------------------------------------------
bool ToonzVectorBrushTool::onPropertyChanged(std::string propertyName) {
+ if (m_propertyUpdating) return true;
+
// Set the following to true whenever a different piece of interface must
// be refreshed - done once at the end.
bool notifyTool = false;
@@ -1449,7 +1451,9 @@ bool ToonzVectorBrushTool::onPropertyChanged(std::string propertyName) {
loadLastBrush();
V_VectorBrushPreset = m_preset.getValueAsString();
+ m_propertyUpdating = true;
getApplication()->getCurrentTool()->notifyToolChanged();
+ m_propertyUpdating = false;
return true;
}
@@ -1505,7 +1509,11 @@ bool ToonzVectorBrushTool::onPropertyChanged(std::string propertyName) {
notifyTool = true;
}
- if (notifyTool) getApplication()->getCurrentTool()->notifyToolChanged();
+ if (notifyTool) {
+ m_propertyUpdating = true;
+ getApplication()->getCurrentTool()->notifyToolChanged();
+ m_propertyUpdating = false;
+ }
return true;
}
diff --git a/toonz/sources/tnztools/toonzvectorbrushtool.h b/toonz/sources/tnztools/toonzvectorbrushtool.h
index 8978d8c9f..ea531828f 100644
--- a/toonz/sources/tnztools/toonzvectorbrushtool.h
+++ b/toonz/sources/tnztools/toonzvectorbrushtool.h
@@ -197,6 +197,8 @@ protected:
TPointD m_lastDragPos; //!< Position where mouse was last dragged.
TMouseEvent m_lastDragEvent; //!< Previous mouse-drag event.
+
+ bool m_propertyUpdating = false;
};
#endif // TOONZVECTORBRUSHTOOL_H