diff --git a/Engine/OfxParamInstance.cpp b/Engine/OfxParamInstance.cpp index 52ee4b557b..628e0a21d7 100644 --- a/Engine/OfxParamInstance.cpp +++ b/Engine/OfxParamInstance.cpp @@ -579,14 +579,22 @@ void OfxPushButtonInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } void OfxPushButtonInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } @@ -595,21 +603,33 @@ void OfxPushButtonInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } void OfxPushButtonInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxPushButtonInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -617,14 +637,22 @@ void OfxPushButtonInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void OfxPushButtonInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } KnobPtr @@ -704,7 +732,11 @@ void OfxIntegerInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -712,7 +744,11 @@ void OfxIntegerInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -720,14 +756,22 @@ void OfxIntegerInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxIntegerInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -735,28 +779,44 @@ void OfxIntegerInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void OfxIntegerInstance::setDefault() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setDefaultValueWithoutApplying(_properties.getIntProperty(kOfxParamPropDefault, 0), 0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValueWithoutApplying(_properties.getIntProperty(kOfxParamPropDefault, 0), 0); } void OfxIntegerInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void OfxIntegerInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } KnobPtr @@ -815,8 +875,12 @@ OfxIntegerInstance::setDisplayRange() int displayMin = getProperties().getIntProperty(kOfxParamPropDisplayMin); int displayMax = getProperties().getIntProperty(kOfxParamPropDisplayMax); - _knob.lock()->setDisplayMinimum(displayMin); - _knob.lock()->setDisplayMaximum(displayMax); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDisplayMinimum(displayMin); + knob->setDisplayMaximum(displayMax); } void @@ -826,8 +890,12 @@ OfxIntegerInstance::setRange() int mini = getProperties().getIntProperty(kOfxParamPropMin); int maxi = getProperties().getIntProperty(kOfxParamPropMax); - _knob.lock()->setMinimum(mini); - _knob.lock()->setMaximum(maxi); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setMinimum(mini); + knob->setMaximum(maxi); } ////////////////////////// OfxDoubleInstance ///////////////////////////////////////////////// @@ -963,21 +1031,33 @@ void OfxDoubleInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } void OfxDoubleInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void OfxDoubleInstance::setDefault() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setDefaultValueWithoutApplying(_properties.getDoubleProperty(kOfxParamPropDefault, 0), 0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValueWithoutApplying(_properties.getDoubleProperty(kOfxParamPropDefault, 0), 0); } // callback which should set secret state as appropriate @@ -985,7 +1065,11 @@ void OfxDoubleInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -993,14 +1077,22 @@ void OfxDoubleInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxDoubleInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -1008,14 +1100,22 @@ void OfxDoubleInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void OfxDoubleInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } void @@ -1025,8 +1125,12 @@ OfxDoubleInstance::setDisplayRange() double displayMin = getProperties().getDoubleProperty(kOfxParamPropDisplayMin); double displayMax = getProperties().getDoubleProperty(kOfxParamPropDisplayMax); - _knob.lock()->setDisplayMinimum(displayMin); - _knob.lock()->setDisplayMaximum(displayMax); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDisplayMinimum(displayMin); + knob->setDisplayMaximum(displayMax); } void @@ -1036,8 +1140,12 @@ OfxDoubleInstance::setRange() double mini = getProperties().getDoubleProperty(kOfxParamPropMin); double maxi = getProperties().getDoubleProperty(kOfxParamPropMax); - _knob.lock()->setMinimum(mini); - _knob.lock()->setMaximum(maxi); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setMinimum(mini); + knob->setMaximum(maxi); } KnobPtr @@ -1161,7 +1269,11 @@ void OfxBooleanInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -1169,7 +1281,11 @@ void OfxBooleanInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -1177,14 +1293,22 @@ void OfxBooleanInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxBooleanInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -1192,28 +1316,44 @@ void OfxBooleanInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void OfxBooleanInstance::setDefault() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setDefaultValueWithoutApplying(_properties.getIntProperty(kOfxParamPropDefault, 0), 0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValueWithoutApplying(_properties.getIntProperty(kOfxParamPropDefault, 0), 0); } void OfxBooleanInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void OfxBooleanInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } KnobPtr @@ -1378,7 +1518,11 @@ void OfxChoiceInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } @@ -1386,7 +1530,11 @@ void OfxChoiceInstance::setDefault() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setDefaultValueWithoutApplying(_properties.getIntProperty(kOfxParamPropDefault, 0), 0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValueWithoutApplying(_properties.getIntProperty(kOfxParamPropDefault, 0), 0); } // callback which should set enabled state as appropriate @@ -1394,7 +1542,11 @@ void OfxChoiceInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -1402,7 +1554,11 @@ void OfxChoiceInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -1410,14 +1566,22 @@ void OfxChoiceInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxChoiceInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -1425,14 +1589,22 @@ void OfxChoiceInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void OfxChoiceInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } void @@ -1660,7 +1832,11 @@ void OfxRGBAInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -1668,7 +1844,11 @@ void OfxRGBAInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -1676,14 +1856,22 @@ void OfxRGBAInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxRGBAInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -1691,14 +1879,22 @@ void OfxRGBAInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void OfxRGBAInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void @@ -1707,14 +1903,22 @@ OfxRGBAInstance::setDefault() DYNAMIC_PROPERTY_CHECK(); double def[4]; _properties.getDoublePropertyN(kOfxParamPropDefault, def, 4); - _knob.lock()->setDefaultValuesWithoutApplying(def[0], def[1], def[2], def[3]); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValuesWithoutApplying(def[0], def[1], def[2], def[3]); } void OfxRGBAInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } void @@ -1725,7 +1929,11 @@ OfxRGBAInstance::setDisplayRange() std::vector displayMaxs(4); _properties.getDoublePropertyN(kOfxParamPropDisplayMin, &displayMins[0], displayMins.size()); _properties.getDoublePropertyN(kOfxParamPropDisplayMax, &displayMaxs[0], displayMaxs.size()); - _knob.lock()->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); } void @@ -1736,7 +1944,11 @@ OfxRGBAInstance::setRange() std::vector maxs(4); _properties.getDoublePropertyN(kOfxParamPropMin, &mins[0], mins.size()); _properties.getDoublePropertyN(kOfxParamPropMax, &maxs[0], maxs.size()); - _knob.lock()->setMinimumsAndMaximums(mins, maxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setMinimumsAndMaximums(mins, maxs); } KnobPtr @@ -1925,7 +2137,11 @@ void OfxRGBInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void @@ -1934,7 +2150,11 @@ OfxRGBInstance::setDefault() DYNAMIC_PROPERTY_CHECK(); double def[3]; _properties.getDoublePropertyN(kOfxParamPropDefault, def, 3); - _knob.lock()->setDefaultValuesWithoutApplying(def[0], def[1], def[2]); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValuesWithoutApplying(def[0], def[1], def[2]); } // callback which should set enabled state as appropriate @@ -1942,7 +2162,11 @@ void OfxRGBInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -1950,7 +2174,11 @@ void OfxRGBInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -1958,14 +2186,22 @@ void OfxRGBInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxRGBInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -1973,14 +2209,22 @@ void OfxRGBInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void OfxRGBInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } void @@ -1991,7 +2235,11 @@ OfxRGBInstance::setDisplayRange() std::vector displayMaxs(3); _properties.getDoublePropertyN(kOfxParamPropDisplayMin, &displayMins[0], displayMins.size()); _properties.getDoublePropertyN(kOfxParamPropDisplayMax, &displayMaxs[0], displayMaxs.size()); - _knob.lock()->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); } void @@ -2002,7 +2250,11 @@ OfxRGBInstance::setRange() std::vector maxs(3); _properties.getDoublePropertyN(kOfxParamPropMin, &mins[0], mins.size()); _properties.getDoublePropertyN(kOfxParamPropMax, &maxs[0], maxs.size()); - _knob.lock()->setMinimumsAndMaximums(mins, maxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setMinimumsAndMaximums(mins, maxs); } KnobPtr @@ -2256,7 +2508,11 @@ void OfxDouble2DInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void @@ -2265,7 +2521,11 @@ OfxDouble2DInstance::setDefault() DYNAMIC_PROPERTY_CHECK(); double def[2]; _properties.getDoublePropertyN(kOfxParamPropDefault, def, 2); - _knob.lock()->setDefaultValuesWithoutApplying(def[0], def[1]); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValuesWithoutApplying(def[0], def[1]); } // callback which should set enabled state as appropriate @@ -2273,7 +2533,11 @@ void OfxDouble2DInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -2281,7 +2545,11 @@ void OfxDouble2DInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -2289,14 +2557,22 @@ void OfxDouble2DInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxDouble2DInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -2304,14 +2580,22 @@ void OfxDouble2DInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void OfxDouble2DInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } void @@ -2322,7 +2606,11 @@ OfxDouble2DInstance::setDisplayRange() std::vector displayMaxs(2); _properties.getDoublePropertyN(kOfxParamPropDisplayMin, &displayMins[0], displayMins.size()); _properties.getDoublePropertyN(kOfxParamPropDisplayMax, &displayMaxs[0], displayMaxs.size()); - _knob.lock()->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); } void @@ -2333,7 +2621,11 @@ OfxDouble2DInstance::setRange() std::vector maxs(2); _properties.getDoublePropertyN(kOfxParamPropMin, &mins[0], mins.size()); _properties.getDoublePropertyN(kOfxParamPropMax, &maxs[0], maxs.size()); - _knob.lock()->setMinimumsAndMaximums(mins, maxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setMinimumsAndMaximums(mins, maxs); } KnobPtr @@ -2514,7 +2806,11 @@ void OfxInteger2DInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -2522,7 +2818,11 @@ void OfxInteger2DInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -2530,14 +2830,22 @@ void OfxInteger2DInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxInteger2DInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -2545,7 +2853,11 @@ void OfxInteger2DInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void @@ -2556,7 +2868,11 @@ OfxInteger2DInstance::setDisplayRange() std::vector displayMaxs(2); getProperties().getIntPropertyN(kOfxParamPropDisplayMin, &displayMins[0], displayMins.size()); getProperties().getIntPropertyN(kOfxParamPropDisplayMax, &displayMaxs[0], displayMaxs.size()); - _knob.lock()->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); } void @@ -2568,14 +2884,22 @@ OfxInteger2DInstance::setRange() std::vector maxs(2); _properties.getIntPropertyN(kOfxParamPropMin, &mins[0], mins.size()); _properties.getIntPropertyN(kOfxParamPropMax, &maxs[0], maxs.size()); - _knob.lock()->setMinimumsAndMaximums(mins, maxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setMinimumsAndMaximums(mins, maxs); } void OfxInteger2DInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void @@ -2584,14 +2908,22 @@ OfxInteger2DInstance::setDefault() DYNAMIC_PROPERTY_CHECK(); int def[2]; _properties.getIntPropertyN(kOfxParamPropDefault, def, 2); - _knob.lock()->setDefaultValuesWithoutApplying(def[0], def[1]); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValuesWithoutApplying(def[0], def[1]); } void OfxInteger2DInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } KnobPtr @@ -2802,14 +3134,22 @@ void OfxDouble3DInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void OfxDouble3DInstance::setDefault() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setDefaultValuesWithoutApplying(_properties.getDoubleProperty(kOfxParamPropDefault, 0), _properties.getDoubleProperty(kOfxParamPropDefault, 1), _properties.getDoubleProperty(kOfxParamPropDefault, 2)); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValuesWithoutApplying(_properties.getDoubleProperty(kOfxParamPropDefault, 0), _properties.getDoubleProperty(kOfxParamPropDefault, 1), _properties.getDoubleProperty(kOfxParamPropDefault, 2)); } // callback which should set enabled state as appropriate @@ -2817,7 +3157,11 @@ void OfxDouble3DInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -2825,7 +3169,11 @@ void OfxDouble3DInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -2833,14 +3181,22 @@ void OfxDouble3DInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxDouble3DInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -2848,7 +3204,11 @@ void OfxDouble3DInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void @@ -2859,7 +3219,11 @@ OfxDouble3DInstance::setDisplayRange() std::vector displayMaxs(3); _properties.getDoublePropertyN(kOfxParamPropDisplayMin, &displayMins[0], displayMins.size()); _properties.getDoublePropertyN(kOfxParamPropDisplayMax, &displayMaxs[0], displayMaxs.size()); - _knob.lock()->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); } void @@ -2870,14 +3234,22 @@ OfxDouble3DInstance::setRange() std::vector maxs(3); _properties.getDoublePropertyN(kOfxParamPropMin, &mins[0], mins.size()); _properties.getDoublePropertyN(kOfxParamPropMax, &maxs[0], maxs.size()); - _knob.lock()->setMinimumsAndMaximums(mins, maxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setMinimumsAndMaximums(mins, maxs); } void OfxDouble3DInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } KnobPtr @@ -3038,14 +3410,22 @@ void OfxInteger3DInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } void OfxInteger3DInstance::setDefault() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setDefaultValuesWithoutApplying(_properties.getIntProperty(kOfxParamPropDefault, 0), _properties.getIntProperty(kOfxParamPropDefault, 1), _properties.getIntProperty(kOfxParamPropDefault, 2)); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultValuesWithoutApplying(_properties.getIntProperty(kOfxParamPropDefault, 0), _properties.getIntProperty(kOfxParamPropDefault, 1), _properties.getIntProperty(kOfxParamPropDefault, 2)); } // callback which should set enabled state as appropriate @@ -3053,7 +3433,11 @@ void OfxInteger3DInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -3061,7 +3445,11 @@ void OfxInteger3DInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -3069,14 +3457,22 @@ void OfxInteger3DInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxInteger3DInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -3084,7 +3480,11 @@ void OfxInteger3DInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void @@ -3095,7 +3495,11 @@ OfxInteger3DInstance::setDisplayRange() std::vector displayMaxs(3); getProperties().getIntPropertyN(kOfxParamPropDisplayMin, &displayMins[0], displayMins.size()); getProperties().getIntPropertyN(kOfxParamPropDisplayMax, &displayMaxs[0], displayMaxs.size()); - _knob.lock()->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); } void @@ -3106,14 +3510,22 @@ OfxInteger3DInstance::setRange() std::vector maxs(3); _properties.getIntPropertyN(kOfxParamPropMin, &mins[0], mins.size()); _properties.getIntPropertyN(kOfxParamPropMax, &maxs[0], maxs.size()); - _knob.lock()->setMinimumsAndMaximums(mins, maxs); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setMinimumsAndMaximums(mins, maxs); } void OfxInteger3DInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } KnobPtr @@ -4130,7 +4542,7 @@ OfxParametricInstance::OfxParametricInstance(const boost::shared_ptrsetDimensionName(i, curveName); + knob->setDimensionName(i, curveName); } } @@ -4144,7 +4556,11 @@ OfxParametricInstance::getCustomOverlayInteractEntryPoint(const OFX::Host::Param void OfxParametricInstance::onCurvesDefaultInitialized() { - _knob.lock()->setDefaultCurvesFromCurves(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setDefaultCurvesFromCurves(); } OfxParametricInstance::~OfxParametricInstance() @@ -4162,7 +4578,11 @@ void OfxParametricInstance::setEnabled() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setAllDimensionsEnabled( getEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setAllDimensionsEnabled( getEnabled() ); } // callback which should set secret state as appropriate @@ -4170,7 +4590,11 @@ void OfxParametricInstance::setSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setSecret( getSecret() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setSecret( getSecret() ); } @@ -4178,14 +4602,22 @@ void OfxParametricInstance::setInViewportSecret() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextSecret( getProperties().getIntProperty(kNatronOfxParamPropInViewerContextSecret) ); } void OfxParametricInstance::setInViewportLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setInViewerContextLabel(QString::fromUtf8(getProperties().getStringProperty(kNatronOfxParamPropInViewerContextLabel).c_str())); } @@ -4193,7 +4625,11 @@ void OfxParametricInstance::setHint() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setHintToolTip(getHint()); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setHintToolTip(getHint()); } @@ -4201,7 +4637,11 @@ void OfxParametricInstance::setEvaluateOnChange() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setEvaluateOnChange( getEvaluateOnChange() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setEvaluateOnChange( getEvaluateOnChange() ); } /// callback which should update label @@ -4209,7 +4649,11 @@ void OfxParametricInstance::setLabel() { DYNAMIC_PROPERTY_CHECK(); - _knob.lock()->setLabel( getParamLabel(this) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->setLabel( getParamLabel(this) ); } void @@ -4228,7 +4672,7 @@ OfxParametricInstance::setDisplayRange() std::vector displayMaxs(dims); _properties.getDoublePropertyN(kOfxParamPropDisplayMin, &displayMins[0], displayMins.size()); _properties.getDoublePropertyN(kOfxParamPropDisplayMax, &displayMaxs[0], displayMaxs.size()); - _knob.lock()->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); + knob->setDisplayMinimumsAndMaximums(displayMins, displayMaxs); } void @@ -4247,7 +4691,7 @@ OfxParametricInstance::setRange() std::vector maxs(dims); _properties.getDoublePropertyN(kOfxParamPropMin, &mins[0], mins.size()); _properties.getDoublePropertyN(kOfxParamPropMax, &maxs[0], maxs.size()); - _knob.lock()->setMinimumsAndMaximums(mins, maxs); + knob->setMinimumsAndMaximums(mins, maxs); } @@ -4257,7 +4701,11 @@ OfxParametricInstance::getValue(int curveIndex, double parametricPosition, double *returnValue) { - StatusEnum stat = _knob.lock()->getValue(curveIndex, parametricPosition, returnValue); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return kOfxStatFailed; + } + StatusEnum stat = knob->getValue(curveIndex, parametricPosition, returnValue); if (stat == eStatusOK) { return kOfxStatOK; @@ -4271,7 +4719,11 @@ OfxParametricInstance::getNControlPoints(int curveIndex, double /*time*/, int *returnValue) { - StatusEnum stat = _knob.lock()->getNControlPoints(curveIndex, returnValue); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return kOfxStatFailed; + } + StatusEnum stat = knob->getNControlPoints(curveIndex, returnValue); if (stat == eStatusOK) { return kOfxStatOK; @@ -4287,7 +4739,11 @@ OfxParametricInstance::getNthControlPoint(int curveIndex, double *key, double *value) { - StatusEnum stat = _knob.lock()->getNthControlPoint(curveIndex, nthCtl, key, value); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return kOfxStatFailed; + } + StatusEnum stat = knob->getNthControlPoint(curveIndex, nthCtl, key, value); if (stat == eStatusOK) { return kOfxStatOK; @@ -4305,7 +4761,11 @@ OfxParametricInstance::setNthControlPoint(int curveIndex, double value, bool /*addAnimationKey*/) { - StatusEnum stat = _knob.lock()->setNthControlPoint(eValueChangedReasonPluginEdited, curveIndex, nthCtl, key, value); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return kOfxStatFailed; + } + StatusEnum stat = knob->setNthControlPoint(eValueChangedReasonPluginEdited, curveIndex, nthCtl, key, value); if (stat == eStatusOK) { return kOfxStatOK; @@ -4331,8 +4791,12 @@ OfxParametricInstance::addControlPoint(int curveIndex, return kOfxStatFailed; } + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return kOfxStatFailed; + } StatusEnum stat; - EffectInstance* effect = dynamic_cast( _knob.lock()->getHolder() ); + EffectInstance* effect = dynamic_cast( knob->getHolder() ); KeyframeTypeEnum interpolation = eKeyframeTypeSmooth; // a reasonable default // The initial curve for some plugins may be better with a specific interpolation. Unfortunately, the kOfxParametricSuiteV1 doesn't offer different interpolation methods #ifdef DEBUG @@ -4345,7 +4809,7 @@ OfxParametricInstance::addControlPoint(int curveIndex, interpolation = eKeyframeTypeCubic; } } - stat = _knob.lock()->addControlPoint(eValueChangedReasonPluginEdited, curveIndex, key, value, interpolation); + stat = knob->addControlPoint(eValueChangedReasonPluginEdited, curveIndex, key, value, interpolation); if (stat == eStatusOK) { return kOfxStatOK; @@ -4358,7 +4822,11 @@ OfxStatus OfxParametricInstance::deleteControlPoint(int curveIndex, int nthCtl) { - StatusEnum stat = _knob.lock()->deleteControlPoint(eValueChangedReasonPluginEdited, curveIndex, nthCtl); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return kOfxStatFailed; + } + StatusEnum stat = knob->deleteControlPoint(eValueChangedReasonPluginEdited, curveIndex, nthCtl); if (stat == eStatusOK) { return kOfxStatOK; @@ -4370,7 +4838,11 @@ OfxParametricInstance::deleteControlPoint(int curveIndex, OfxStatus OfxParametricInstance::deleteAllControlPoints(int curveIndex) { - StatusEnum stat = _knob.lock()->deleteAllControlPoints(eValueChangedReasonPluginEdited, curveIndex); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return kOfxStatFailed; + } + StatusEnum stat = knob->deleteAllControlPoints(eValueChangedReasonPluginEdited, curveIndex); if (stat == eStatusOK) { return kOfxStatOK; diff --git a/Gui/Gui20.cpp b/Gui/Gui20.cpp index a47fa8ad86..2508abb648 100644 --- a/Gui/Gui20.cpp +++ b/Gui/Gui20.cpp @@ -480,6 +480,9 @@ Gui::removeViewerTab(ViewerTab* tab, bool deleteData) { assert(tab); + if (!tab) { + throw std::logic_error(""); + } unregisterTab(tab); if (tab == _imp->_activeViewer) { diff --git a/Gui/KnobGuiBool.cpp b/Gui/KnobGuiBool.cpp index 5bdaf8aace..37108f2569 100644 --- a/Gui/KnobGuiBool.cpp +++ b/Gui/KnobGuiBool.cpp @@ -237,7 +237,11 @@ KnobGuiBool::removeSpecificGui() void KnobGuiBool::updateGUI(int /*dimension*/) { - _checkBox->setChecked( _knob.lock()->getValue(0) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + _checkBox->setChecked( knob->getValue(0) ); } void @@ -268,7 +272,11 @@ KnobGuiBool::reflectAnimationLevel(int /*dimension*/, void KnobGuiBool::onLabelChangedInternal() { - const std::string& label = _knob.lock()->getLabel(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + const std::string& label = knob->getLabel(); if ( (label == "R") || (label == "r") || (label == "red") ) { QColor color; @@ -298,13 +306,21 @@ KnobGuiBool::onLabelClicked(bool b) return; } _checkBox->setChecked(b); - pushUndoCommand( new KnobUndoCommand(shared_from_this(), _knob.lock()->getValue(0), b, 0, false) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + pushUndoCommand( new KnobUndoCommand(shared_from_this(), knob->getValue(0), b, 0, false) ); } void KnobGuiBool::onCheckBoxStateChanged(bool b) { - pushUndoCommand( new KnobUndoCommand(shared_from_this(), _knob.lock()->getValue(0), b, 0, false) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + pushUndoCommand( new KnobUndoCommand(shared_from_this(), knob->getValue(0), b, 0, false) ); } void @@ -351,7 +367,11 @@ void KnobGuiBool::reflectExpressionState(int /*dimension*/, bool hasExpr) { - bool isEnabled = _knob.lock()->isEnabled(0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool isEnabled = knob->isEnabled(0); _checkBox->setAnimation(3); _checkBox->setReadOnly(hasExpr || !isEnabled); @@ -362,7 +382,11 @@ KnobGuiBool::updateToolTip() { if ( hasToolTip() ) { QString tt = toolTip(); - for (int i = 0; i < _knob.lock()->getDimension(); ++i) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + for (int i = 0; i < knob->getDimension(); ++i) { _checkBox->setToolTip( tt ); } } diff --git a/Gui/KnobGuiButton.cpp b/Gui/KnobGuiButton.cpp index 2f77d837e4..af4222b37c 100644 --- a/Gui/KnobGuiButton.cpp +++ b/Gui/KnobGuiButton.cpp @@ -183,7 +183,7 @@ KnobGuiButton::emitValueChanged(bool clicked) _button->setDown(clicked); _button->setChecked(clicked); - pushUndoCommand( new KnobUndoCommand(shared_from_this(), _knob.lock()->getValue(), clicked, 0, false) ); + pushUndoCommand( new KnobUndoCommand(shared_from_this(), k->getValue(), clicked, 0, false) ); } else { k->trigger(); } diff --git a/Gui/KnobGuiChoice.cpp b/Gui/KnobGuiChoice.cpp index 58b9b81e0f..5b91f1eb69 100644 --- a/Gui/KnobGuiChoice.cpp +++ b/Gui/KnobGuiChoice.cpp @@ -229,7 +229,11 @@ void KnobGuiChoice::createWidget(QHBoxLayout* layout) { _comboBox = new KnobComboBox( shared_from_this(), 0, layout->parentWidget() ); - _comboBox->setCascading( _knob.lock()->isCascading() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + _comboBox->setCascading( knob->isCascading() ); onEntriesPopulated(); QObject::connect( _comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)) ); @@ -244,7 +248,11 @@ void KnobGuiChoice::onCurrentIndexChanged(int i) { setWarningValue( KnobGui::eKnobWarningChoiceMenuOutOfDate, QString() ); - pushUndoCommand( new KnobUndoCommand(shared_from_this(), _knob.lock()->getValue(0), i, 0, false, 0) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + pushUndoCommand( new KnobUndoCommand(shared_from_this(), knob->getValue(0), i, 0, false, 0) ); } void @@ -367,7 +375,11 @@ KnobGuiChoice::onItemNewSelected() return; } - KnobHolder* holder = _knob.lock()->getHolder(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + KnobHolder* holder = knob->getHolder(); assert(holder); EffectInstance* effect = dynamic_cast(holder); assert(effect); @@ -385,7 +397,11 @@ KnobGuiChoice::reflectExpressionState(int /*dimension*/, bool hasExpr) { _comboBox->setAnimation(3); - bool isEnabled = _knob.lock()->isEnabled(0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool isEnabled = knob->isEnabled(0); _comboBox->setEnabled_natron(!hasExpr && isEnabled); } @@ -491,7 +507,11 @@ KnobGuiChoice::getKnob() const void KnobGuiChoice::reflectModificationsState() { - bool hasModif = _knob.lock()->hasModifications(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool hasModif = knob->hasModifications(); _comboBox->setAltered(!hasModif); } diff --git a/Gui/KnobGuiColor.cpp b/Gui/KnobGuiColor.cpp index d61fbb55b6..bc312a79ed 100644 --- a/Gui/KnobGuiColor.cpp +++ b/Gui/KnobGuiColor.cpp @@ -208,8 +208,12 @@ KnobGuiColor::KnobGuiColor(KnobPtr knob, , _colorLabel(0) , _colorDialogButton(0) , _lastColor( knob->getDimension() ) - , _useSimplifiedUI( isViewerUIKnob() || _knob.lock()->isSimplified() ) + , _useSimplifiedUI(true) { + if (knob) { + boost::shared_ptr k = _knob.lock(); + _useSimplifiedUI = isViewerUIKnob() || ( k && k->isSimplified() ); + } } void @@ -224,7 +228,11 @@ KnobGuiColor::connectKnobSignalSlots() void KnobGuiColor::getIncrements(std::vector* increments) const { - int nDims = _knob.lock()->getDimension(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + int nDims = knob->getDimension(); increments->resize(nDims); for (int i = 0; i < nDims; ++i) { @@ -235,7 +243,11 @@ KnobGuiColor::getIncrements(std::vector* increments) const void KnobGuiColor::getDecimals(std::vector* decimals) const { - int nDims = _knob.lock()->getDimension(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + int nDims = knob->getDimension(); decimals->resize(nDims); for (int i = 0; i < nDims; ++i) { @@ -524,7 +536,11 @@ KnobGuiColor::showColorDialog() bool KnobGuiColor::isAutoFoldDimensionsEnabled() const { - return _knob.lock()->getDimension() == 3; + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } + return knob->getDimension() == 3; } NATRON_NAMESPACE_EXIT; diff --git a/Gui/KnobGuiFile.cpp b/Gui/KnobGuiFile.cpp index 3faefdfec5..23c53f9bdd 100644 --- a/Gui/KnobGuiFile.cpp +++ b/Gui/KnobGuiFile.cpp @@ -452,7 +452,11 @@ void KnobGuiFile::reflectExpressionState(int /*dimension*/, bool hasExpr) { - bool isEnabled = _knob.lock()->isEnabled(0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool isEnabled = knob->isEnabled(0); _lineEdit->setAnimation(3); _lineEdit->setReadOnly_NoFocusRect(hasExpr || !isEnabled); @@ -538,7 +542,11 @@ KnobGuiOutputFile::createWidget(QHBoxLayout* layout) void KnobGuiOutputFile::onButtonClicked() { - open_file( _knob.lock()->isSequencesDialogEnabled() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + open_file( knob->isSequencesDialogEnabled() ); } void @@ -555,9 +563,13 @@ KnobGuiOutputFile::onRewriteClicked() void KnobGuiOutputFile::open_file(bool openSequence) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } std::vector filters; - if ( !_knob.lock()->isOutputImageFile() ) { + if ( !knob->isOutputImageFile() ) { filters.push_back("*"); } else { appPTR->getSupportedWriterFileFormats(&filters); @@ -585,7 +597,11 @@ KnobGuiOutputFile::updateLastOpened(const QString &str) void KnobGuiOutputFile::updateGUI(int /*dimension*/) { - _lineEdit->setText( QString::fromUtf8( _knob.lock()->getValue().c_str() ) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + _lineEdit->setText( QString::fromUtf8( knob->getValue().c_str() ) ); } void @@ -720,7 +736,11 @@ void KnobGuiOutputFile::reflectExpressionState(int /*dimension*/, bool hasExpr) { - bool isEnabled = _knob.lock()->isEnabled(0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool isEnabled = knob->isEnabled(0); _lineEdit->setAnimation(3); _lineEdit->setReadOnly_NoFocusRect(hasExpr || !isEnabled); @@ -810,7 +830,11 @@ KnobGuiPath::onOpenFileButtonClicked() std::string dirPath = dialog.selectedDirectory(); updateLastOpened( QString::fromUtf8( dirPath.c_str() ) ); - std::string oldValue = _knob.lock()->getValue(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + std::string oldValue = knob->getValue(); pushUndoCommand( new KnobUndoCommand( shared_from_this(), oldValue, dirPath ) ); } @@ -974,7 +998,11 @@ KnobGuiPath::_show() void KnobGuiPath::setEnabled() { - if ( _knob.lock()->isMultiPath() ) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + if ( knob->isMultiPath() ) { KnobGuiTable::setEnabled(); } else { bool enabled = getKnob()->isEnabled(0); @@ -987,7 +1015,11 @@ void KnobGuiPath::setReadOnly(bool readOnly, int dimension) { - if ( _knob.lock()->isMultiPath() ) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + if ( knob->isMultiPath() ) { KnobGuiTable::setReadOnly(readOnly, dimension); } else { _lineEdit->setReadOnly_NoFocusRect(readOnly); @@ -1009,7 +1041,11 @@ KnobGuiPath::getKnob() const void KnobGuiPath::addRightClickMenuEntries(QMenu* menu) { - if ( !_knob.lock()->isMultiPath() ) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + if ( !knob->isMultiPath() ) { QAction* makeAbsoluteAction = new QAction(tr("Make absolute"), menu); QObject::connect( makeAbsoluteAction, SIGNAL(triggered()), this, SLOT(onMakeAbsoluteTriggered()) ); makeAbsoluteAction->setToolTip( tr("Make the file-path absolute if it was previously relative to any project path") ); @@ -1074,7 +1110,11 @@ void KnobGuiPath::reflectAnimationLevel(int /*dimension*/, AnimationLevelEnum /*level*/) { - if ( !_knob.lock()->isMultiPath() ) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + if ( !knob->isMultiPath() ) { _lineEdit->setAnimation(0); } } @@ -1086,7 +1126,7 @@ KnobGuiPath::reflectExpressionState(int /*dimension*/, boost::shared_ptr knob = _knob.lock(); if ( !knob->isMultiPath() ) { - bool isEnabled = _knob.lock()->isEnabled(0); + bool isEnabled = knob->isEnabled(0); _lineEdit->setAnimation(3); _lineEdit->setReadOnly_NoFocusRect(hasExpr || !isEnabled); _openFileButton->setEnabled(!hasExpr || isEnabled); @@ -1098,7 +1138,11 @@ KnobGuiPath::updateToolTip() { if ( hasToolTip() ) { QString tt = toolTip(); - if ( !_knob.lock()->isMultiPath() ) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + if ( !knob->isMultiPath() ) { _lineEdit->setToolTip(tt); } else { KnobGuiTable::updateToolTip(); diff --git a/Gui/KnobGuiGroup.cpp b/Gui/KnobGuiGroup.cpp index 91f5049cb1..ce70dd7fa2 100644 --- a/Gui/KnobGuiGroup.cpp +++ b/Gui/KnobGuiGroup.cpp @@ -146,7 +146,11 @@ KnobGuiGroup::createWidget(QHBoxLayout* layout) if ( hasToolTip() ) { _button->setToolTip( toolTip() ); } - _checked = _knob.lock()->getValue(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + _checked = knob->getValue(); _button->setFixedSize(NATRON_MEDIUM_BUTTON_SIZE, NATRON_MEDIUM_BUTTON_SIZE); _button->setChecked(_checked); QObject::connect( _button, SIGNAL(checked(bool)), this, SLOT(onCheckboxChecked(bool)) ); @@ -215,7 +219,11 @@ KnobGuiGroup::eventFilter(QObject */*target*/, void KnobGuiGroup::updateGUI(int /*dimension*/) { - bool b = _knob.lock()->getValue(0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool b = knob->getValue(0); setCheckedInternal(b, false); if (_button) { diff --git a/Gui/KnobGuiParametric.cpp b/Gui/KnobGuiParametric.cpp index 45fadf2934..95a9f656ed 100644 --- a/Gui/KnobGuiParametric.cpp +++ b/Gui/KnobGuiParametric.cpp @@ -184,7 +184,11 @@ KnobGuiParametric::onColorChanged(int dimension) return; } double r, g, b; - _knob.lock()->getCurveColor(dimension, &r, &g, &b); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->getCurveColor(dimension, &r, &g, &b); CurveDescriptor& found = _curves[dimension]; QColor c; diff --git a/Gui/KnobGuiString.cpp b/Gui/KnobGuiString.cpp index d3b2e43c07..cbe9b6b2f4 100644 --- a/Gui/KnobGuiString.cpp +++ b/Gui/KnobGuiString.cpp @@ -540,7 +540,11 @@ KnobGuiString::onLineChanged() if ( !_lineEdit->isEnabled() || _lineEdit->isReadOnly() ) { return; } - std::string oldText = _knob.lock()->getValue(0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + std::string oldText = knob->getValue(0); std::string newText = _lineEdit->text().toStdString(); if (oldText != newText) { @@ -585,10 +589,14 @@ KnobGuiString::onTextChanged() QString txt = _textEdit->toPlainText(); //txt = stripWhitespaces(txt); - if ( _knob.lock()->usesRichText() ) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + if ( knob->usesRichText() ) { txt = addHtmlTags(txt); } - pushUndoCommand( new KnobUndoCommand( shared_from_this(), _knob.lock()->getValue(0), txt.toStdString() ) ); + pushUndoCommand( new KnobUndoCommand( shared_from_this(), knob->getValue(0), txt.toStdString() ) ); } QString @@ -609,7 +617,11 @@ KnobGuiString::addHtmlTags(QString text) const } ///if the knob had custom data, set them - QString knobOldtext = QString::fromUtf8( _knob.lock()->getValue(0).c_str() ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return text; + } + QString knobOldtext = QString::fromUtf8( knob->getValue(0).c_str() ); QString startCustomTag( QString::fromUtf8(NATRON_CUSTOM_HTML_TAG_START) ); int startCustomData = knobOldtext.indexOf(startCustomTag); if (startCustomData != -1) { @@ -1129,7 +1141,7 @@ KnobGuiString::updateGUI(int /*dimension*/) int selectionStart = cursor.selectionStart(); int selectionEnd = cursor.selectionEnd(); QString txt = QString::fromUtf8( value.c_str() ); - if ( _knob.lock()->usesRichText() ) { + if ( knob->usesRichText() ) { txt = removeAutoAddedHtmlTags(txt); } @@ -1267,12 +1279,16 @@ void KnobGuiString::setReadOnly(bool readOnly, int /*dimension*/) { + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } if (_textEdit) { - if ( !_knob.lock()->isCustomHTMLText() ) { + if ( !knob->isCustomHTMLText() ) { _textEdit->setReadOnlyNatron(readOnly); } } else if (_lineEdit) { - if ( !_knob.lock()->isCustomKnob() ) { + if ( !knob->isCustomKnob() ) { _lineEdit->setReadOnly_NoFocusRect(readOnly); } } @@ -1298,11 +1314,15 @@ void KnobGuiString::reflectExpressionState(int /*dimension*/, bool hasExpr) { - bool isEnabled = _knob.lock()->isEnabled(0); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool isEnabled = knob->isEnabled(0); if (_textEdit) { _textEdit->setAnimation(3); - if ( !_knob.lock()->isCustomHTMLText() ) { + if ( !knob->isCustomHTMLText() ) { _textEdit->setReadOnlyNatron(hasExpr || !isEnabled); } } else if (_lineEdit) { @@ -1317,7 +1337,11 @@ KnobGuiString::updateToolTip() if ( hasToolTip() ) { QString tt = toolTip(); if (_textEdit) { - bool useRichText = _knob.lock()->usesRichText(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool useRichText = knob->usesRichText(); if (useRichText) { tt += tr("This text area supports html encoding. " "Please check Qt website for more info."); @@ -1336,7 +1360,11 @@ KnobGuiString::updateToolTip() void KnobGuiString::reflectModificationsState() { - bool hasModif = _knob.lock()->hasModifications(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + bool hasModif = knob->hasModifications(); if (_lineEdit) { _lineEdit->setAltered(!hasModif); diff --git a/Gui/KnobGuiTable.cpp b/Gui/KnobGuiTable.cpp index 522de17594..0d6e55e521 100644 --- a/Gui/KnobGuiTable.cpp +++ b/Gui/KnobGuiTable.cpp @@ -663,7 +663,11 @@ KnobGuiLayers::addNewUserEntry(QStringList& row) row.push_back( QString::fromUtf8( comps.getLayerName().c_str() ) ); std::list > table; - _knob.lock()->getTable(&table); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + knob->getTable(&table); for (std::list >::iterator it = table.begin(); it != table.end(); ++it) { if ( (*it)[0] == comps.getLayerName() ) { Dialogs::errorDialog( tr("Layer").toStdString(), tr("A Layer with the same name already exists").toStdString() ); @@ -711,8 +715,12 @@ KnobGuiLayers::editUserEntry(QStringList& row) std::string oldLayerName = row[0].toStdString(); row[0] = ( QString::fromUtf8( comps.getLayerName().c_str() ) ); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } std::list > table; - _knob.lock()->getTable(&table); + knob->getTable(&table); for (std::list >::iterator it = table.begin(); it != table.end(); ++it) { if ( ( (*it)[0] == comps.getLayerName() ) && ( (*it)[0] != oldLayerName ) ) { Dialogs::errorDialog( tr("Layer").toStdString(), tr("A Layer with the same name already exists").toStdString() ); diff --git a/Gui/KnobGuiValue.cpp b/Gui/KnobGuiValue.cpp index dcc787fdd5..db8cb65cba 100644 --- a/Gui/KnobGuiValue.cpp +++ b/Gui/KnobGuiValue.cpp @@ -1186,31 +1186,51 @@ KnobGuiDouble::KnobGuiDouble(KnobPtr knob, bool KnobGuiDouble::isSliderDisabled() const { - return _knob.lock()->isSliderDisabled(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } + return knob->isSliderDisabled(); } bool KnobGuiDouble::isAutoFoldDimensionsEnabled() const { - return _knob.lock()->isAutoFoldDimensionsEnabled(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } + return knob->isAutoFoldDimensionsEnabled(); } bool KnobGuiDouble::isRectangleType() const { - return _knob.lock()->isRectangle(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } + return knob->isRectangle(); } bool KnobGuiDouble::isSpatialType() const { - return _knob.lock()->getIsSpatial(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } + return knob->getIsSpatial(); } ValueIsNormalizedEnum KnobGuiDouble::getNormalizationPolicy(int dimension) const { - return _knob.lock()->getValueIsNormalized(dimension); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return eValueIsNormalizedNone; + } + return knob->getValueIsNormalized(dimension); } double @@ -1218,7 +1238,11 @@ KnobGuiDouble::denormalize(int dimension, double time, double value) const { - return _knob.lock()->denormalize(dimension, time, value); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return value; + } + return knob->denormalize(dimension, time, value); } double @@ -1226,7 +1250,11 @@ KnobGuiDouble::normalize(int dimension, double time, double value) const { - return _knob.lock()->normalize(dimension, time, value); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return value; + } + return knob->normalize(dimension, time, value); } void @@ -1240,19 +1268,31 @@ KnobGuiDouble::connectKnobSignalSlots() void KnobGuiDouble::disableSlider() { - return _knob.lock()->disableSlider(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + return knob->disableSlider(); } void KnobGuiDouble::getIncrements(std::vector* increments) const { - *increments = _knob.lock()->getIncrements(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + *increments = knob->getIncrements(); } void KnobGuiDouble::getDecimals(std::vector* decimals) const { - *decimals = _knob.lock()->getDecimals(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + *decimals = knob->getDecimals(); } KnobGuiInt::KnobGuiInt(KnobPtr knob, @@ -1265,19 +1305,31 @@ KnobGuiInt::KnobGuiInt(KnobPtr knob, bool KnobGuiInt::isSliderDisabled() const { - return _knob.lock()->isSliderDisabled(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } + return knob->isSliderDisabled(); } bool KnobGuiInt::isAutoFoldDimensionsEnabled() const { - return _knob.lock()->isAutoFoldDimensionsEnabled(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } + return knob->isAutoFoldDimensionsEnabled(); } bool KnobGuiInt::isRectangleType() const { - return _knob.lock()->isRectangle(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return false; + } + return knob->isRectangle(); } void @@ -1290,13 +1342,21 @@ KnobGuiInt::connectKnobSignalSlots() void KnobGuiInt::disableSlider() { - return _knob.lock()->disableSlider(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + return knob->disableSlider(); } void KnobGuiInt::getIncrements(std::vector* increments) const { - const std::vector& incr = _knob.lock()->getIncrements(); + boost::shared_ptr knob = _knob.lock(); + if (!knob) { + return; + } + const std::vector& incr = knob->getIncrements(); increments->resize( incr.size() ); for (std::size_t i = 0; i < incr.size(); ++i) { diff --git a/Gui/ViewerGL.cpp b/Gui/ViewerGL.cpp index de5d83cfa4..9d596b9141 100644 --- a/Gui/ViewerGL.cpp +++ b/Gui/ViewerGL.cpp @@ -3675,7 +3675,7 @@ ViewerGL::removeGUI() { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); - if ( _imp->viewerTab->getGui() ) { + if ( _imp->viewerTab && _imp->viewerTab->getGui() ) { _imp->viewerTab->discardInternalNodePointer(); _imp->viewerTab->getGui()->removeViewerTab(_imp->viewerTab, true, true); }