@@ -111,7 +111,8 @@ SceneCacheReader::SceneCacheReader( Node *node )
111
111
m_tagFilterKnob( NULL ),
112
112
m_sceneFilterKnob( NULL ),
113
113
m_rootKnob( NULL ),
114
- m_scriptLoaded( false )
114
+ m_scriptFinishedLoading( false ),
115
+ m_isFirstRun( true )
115
116
{
116
117
m_baseParentMatrix.makeIdentity ();
117
118
}
@@ -123,16 +124,25 @@ SceneCacheReader::~SceneCacheReader()
123
124
void SceneCacheReader::_validate ( bool forReal )
124
125
{
125
126
m_evaluatedFilePath = filePath ();
126
-
127
- if ( !m_scriptLoaded )
127
+
128
+ if ( m_scriptFinishedLoading )
128
129
{
129
- knob (" loadAll" )->set_value ( true );
130
- m_scriptLoaded = true ;
131
- loadAllFromKnobs ();
132
- }
130
+ if ( m_isFirstRun )
131
+ {
132
+ Knob *k = knob (" loadAll" );
133
+ if ( k != NULL )
134
+ {
135
+ k->set_value ( true );
136
+ }
133
137
134
- filterScene ( m_filterText, m_filterTagText );
135
- rebuildSelection ();
138
+ m_isFirstRun = false ;
139
+ m_scriptFinishedLoading = true ;
140
+ loadAllFromKnobs ();
141
+ }
142
+
143
+ filterScene ( m_filterText, m_filterTagText );
144
+ rebuildSelection ();
145
+ }
136
146
137
147
SourceGeo::_validate ( forReal );
138
148
}
@@ -154,7 +164,7 @@ void SceneCacheReader::knobs( DD::Image::Knob_Callback f )
154
164
);
155
165
156
166
int p = 0 ;
157
- const char * tagNames[4 ] = { " None" , 0 };
167
+ const char * tagNames[2 ] = { " None" , 0 };
158
168
m_tagFilterKnob = Enumeration_knob ( f, &p, tagNames, " filterByTag" , " Filter Tag" );
159
169
SetFlags ( f, DD::Image::Knob::ALWAYS_SAVE | DD::Image::Knob::KNOB_CHANGED_ALWAYS );
160
170
Tooltip ( f,
@@ -322,12 +332,9 @@ int SceneCacheReader::knob_changed(Knob* k)
322
332
// structures.
323
333
else if ( knob (" loadAll" ) == k )
324
334
{
325
- return 1 ;
326
- if ( !m_scriptLoaded )
335
+ if ( !m_scriptFinishedLoading )
327
336
{
328
- knob (" loadAll" )->set_value ( true );
329
- m_scriptLoaded = true ;
330
- loadAllFromKnobs ();
337
+ m_scriptFinishedLoading = true ;
331
338
}
332
339
333
340
return 1 ;
@@ -339,7 +346,7 @@ int SceneCacheReader::knob_changed(Knob* k)
339
346
340
347
void SceneCacheReader::loadAllFromKnobs ()
341
348
{
342
- if ( !m_scriptLoaded )
349
+ if ( !m_scriptFinishedLoading )
343
350
{
344
351
throw IECore::Exception ( " SceneCacheReader: Cannot load item as the script hasn't finished loading." );
345
352
}
@@ -350,7 +357,8 @@ void SceneCacheReader::loadAllFromKnobs()
350
357
351
358
std::vector<unsigned int > selectionIndices;
352
359
sceneView->getSelectedItems ( selectionIndices );
353
-
360
+
361
+
354
362
std::vector<unsigned int > filterIndices;
355
363
sceneView->getImportedItems ( filterIndices );
356
364
@@ -396,7 +404,15 @@ void SceneCacheReader::loadAllFromKnobs()
396
404
397
405
void SceneCacheReader::rebuildSelection ()
398
406
{
399
- if ( !m_scriptLoaded ) return ;
407
+ if ( !m_scriptFinishedLoading )
408
+ {
409
+ return ;
410
+ }
411
+
412
+ if ( m_isFirstRun )
413
+ {
414
+ validate ( false );
415
+ }
400
416
401
417
// We require an up-to-date scene so rebuild it if necessary.
402
418
rebuildSceneView ();
@@ -461,7 +477,15 @@ void SceneCacheReader::rebuildSceneView()
461
477
{
462
478
m_evaluatedFilePath = filePath ();
463
479
464
- if ( !m_scriptLoaded ) return ;
480
+ if ( !m_scriptFinishedLoading )
481
+ {
482
+ return ;
483
+ }
484
+
485
+ if ( m_isFirstRun )
486
+ {
487
+ validate ( false );
488
+ }
465
489
466
490
Hash newSceneHash ( sceneHash () );
467
491
@@ -530,7 +554,15 @@ const std::string &SceneCacheReader::itemName( int index ) const
530
554
// There LUTs are the m_itemToFiltered and m_filteredToItem maps.
531
555
void SceneCacheReader::filterScene ( const std::string &filterText, const std::string &filterTag )
532
556
{
533
- if ( !m_scriptLoaded ) return ;
557
+ if ( !m_scriptFinishedLoading )
558
+ {
559
+ return ;
560
+ }
561
+
562
+ if ( m_isFirstRun )
563
+ {
564
+ validate ( false );
565
+ }
534
566
535
567
Hash newFilterHash ( sceneHash () );
536
568
newFilterHash.append ( filterText );
0 commit comments