Skip to content

Commit d4e8e89

Browse files
committed
Fixed bug #4837: "Knobs not found" warning messages.
The bug only appears when loading the LensDistort node UI for the first time with a file sequence specified. The cause was the early termination of the knob_changed() method before an update to the dynamic knobs was made. The fix also the code simpler to read.
1 parent 802a780 commit d4e8e89

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

include/IECoreNuke/LensDistort.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ class LensDistort : public DD::Image::Iop
144144

145145
/// Iterates over all of the lens model's attributes and if they are associated with a knob, retrieves the information from the knob.
146146
void updatePluginAttributesFromKnobs();
147+
148+
/// Updates the dynamic knobs. This method should be called whenever a knob is changed or an event happens that requires
149+
/// the dynamic knobs to be recreated or their enabled state changed.
150+
void updateUI();
147151

148152
/// The maximum number of threads that we are going to use in parallel.
149153
const int m_nThreads;

src/IECoreNuke/LensDistort.cpp

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -486,32 +486,38 @@ void LensDistort::updatePluginAttributesFromKnobs()
486486

487487
int LensDistort::knob_changed(Knob* k)
488488
{
489-
bool updateUI = false;
490-
491489
// If the lensFileSequence knob just changed then we need to check if it is valid and load it.
492-
// Once loaded then we set the updateUI flag to trigger a UI update.
493490
if ( k->is( "lensFileSequence" ) )
494491
{
492+
bool updateRequired = false;
493+
495494
std::string path;
496495
bool oldValue = m_useFileSequence;
497496
m_useFileSequence = getFileSequencePath( path );
498-
updateUI |= oldValue != m_useFileSequence;
497+
updateRequired |= oldValue != m_useFileSequence;
499498

500499
if ( m_useFileSequence )
501500
{
502501
bool oldValue = m_hasValidFileSequence;
503502
std::string path;
504503
m_hasValidFileSequence = setLensFromFile( path );
505-
updateUI |= m_hasValidFileSequence != oldValue;
504+
updateRequired |= m_hasValidFileSequence != oldValue;
505+
}
506+
507+
if( updateRequired )
508+
{
509+
updateUI();
506510
}
507511

512+
return true;
508513
}
509514

510515
// If the lens model was just changed then we need to set it internally and then update the UI.
511516
if ( k->is( "model" ) )
512517
{
513518
setLensModel( modelNames()[getLensModel()] );
514-
updateUI = true;
519+
updateUI();
520+
return true;
515521
}
516522

517523
// Update our internal reference of the knob value that just changed...
@@ -531,27 +537,28 @@ int LensDistort::knob_changed(Knob* k)
531537
}
532538
}
533539

534-
if ( k->is( "lensFileSequence" ) ) return true;
535-
536540
// Do we need to update the UI?
537-
if ( k == &Knob::showPanel || updateUI )
541+
if ( k == &Knob::showPanel )
538542
{
539-
m_numNewKnobs = replace_knobs( m_lastStaticKnob, m_numNewKnobs, addDynamicKnobs, this->firstOp() );
540-
541-
// Handle the knobs state.
542-
if ( knob("model" ) != NULL) knob("model")->enable( !m_useFileSequence );
543-
for ( PluginAttributeList::iterator it = m_pluginAttributes.begin(); it != m_pluginAttributes.end(); it++ )
544-
{
545-
if ( it->m_knob != NULL) it->m_knob->enable( !m_useFileSequence );
546-
}
547-
543+
updateUI();
548544
return true;
549545
}
550546

551-
552547
return Iop::knob_changed(k);
553548
}
554549

550+
void LensDistort::updateUI()
551+
{
552+
m_numNewKnobs = replace_knobs( m_lastStaticKnob, m_numNewKnobs, addDynamicKnobs, this->firstOp() );
553+
554+
// Handle the knobs state.
555+
if ( knob("model" ) != NULL) knob("model")->enable( !m_useFileSequence );
556+
for ( PluginAttributeList::iterator it = m_pluginAttributes.begin(); it != m_pluginAttributes.end(); it++ )
557+
{
558+
if ( it->m_knob != NULL) it->m_knob->enable( !m_useFileSequence );
559+
}
560+
}
561+
555562
void LensDistort::buildDynamicKnobs(void* p, DD::Image::Knob_Callback f)
556563
{
557564
PluginAttributeList& attributeList( ((LensDistort*)p)->attributeList() );

0 commit comments

Comments
 (0)