@@ -66,6 +66,7 @@ ofxVisualProgramming::ofxVisualProgramming(){
6666    lastAddedObjectID       = -1 ;
6767    bLoadingNewObject       = false ;
6868    bLoadingNewPatch        = false ;
69+     bPopulatingObjectsMap   = false ;
6970    clearingObjectsMap      = false ;
7071
7172    livePatchingObiID       = -1 ;
@@ -225,7 +226,9 @@ void ofxVisualProgramming::update(){
225226    }
226227
227228    //  Clear map from deleted objects
228-     clearObjectsMap ();
229+     if (!bPopulatingObjectsMap){
230+         clearObjectsMap ();
231+     }
229232
230233    //  update patch objects
231234    if (!bLoadingNewPatch && !patchObjects.empty ()){
@@ -622,7 +625,9 @@ void ofxVisualProgramming::audioProcess(float *input, int bufferSize, int nChann
622625            //  compute audio input
623626            if (!inputBuffer.getBuffer ().empty ()){
624627                for (map<int ,shared_ptr<PatchObject>>::iterator it = patchObjects.begin (); it != patchObjects.end (); it++ ){
625-                     it->second ->audioIn (inputBuffer);
628+                     if (!it->second ->getWillErase ()){
629+                         it->second ->audioIn (inputBuffer);
630+                     }
626631                }
627632
628633                lastInputBuffer = inputBuffer;
@@ -632,7 +637,9 @@ void ofxVisualProgramming::audioProcess(float *input, int bufferSize, int nChann
632637        if (audioGUIOUTChannels > 0 ){
633638            //  compute audio output
634639            for (map<int ,shared_ptr<PatchObject>>::iterator it = patchObjects.begin (); it != patchObjects.end (); it++ ){
635-                 it->second ->audioOut (emptyBuffer);
640+                 if (!it->second ->getWillErase ()){
641+                     it->second ->audioOut (emptyBuffer);
642+                 }
636643            }
637644        }
638645
@@ -660,6 +667,18 @@ void ofxVisualProgramming::addObject(string name,ofVec2f pos){
660667
661668    shared_ptr<PatchObject> tempObj = selectObject (name);
662669
670+     //  selectObject can return nullptr !
671+     if ( tempObj.get () == nullptr  ){
672+         ofLogWarning (" ofxVisualProgramming::addObject" " The requested object « " "  » is not available !" 
673+     #ifdef  OFXVP_BUILD_WITH_MINIMAL_OBJECTS
674+             << " \n (note: ofxVisualProgramming is compiling with OFXVP_BUILD_WITH_MINIMAL_OBJECTS enabled.)" 
675+     #else 
676+             ;
677+     #endif 
678+         bLoadingNewObject = false ;
679+         return ;
680+     }
681+ 
663682    tempObj->newObject ();
664683    tempObj->setPatchfile (currentPatchFile);
665684    tempObj->setup (mainWindow);
@@ -1449,7 +1468,7 @@ void ofxVisualProgramming::loadPatch(string patchFile){
14491468                if (!audioDevicesID_IN.empty ()){
14501469                    isInputDeviceAvailable = true ;
14511470                    //  select the first one available
1452-                     audioGUIINIndex = audioDevicesID_IN. at ( 0 ) ;
1471+                     audioGUIINIndex = 0 ;
14531472                    audioINDev = audioDevicesID_IN.at (audioGUIINIndex);
14541473                }else {
14551474                    isInputDeviceAvailable = false ;
@@ -1474,7 +1493,7 @@ void ofxVisualProgramming::loadPatch(string patchFile){
14741493                if (!audioDevicesID_OUT.empty ()){
14751494                    isOutputDeviceAvailable = true ;
14761495                    //  select the first one available
1477-                     audioGUIOUTIndex = audioDevicesID_OUT. at ( 0 ) ;
1496+                     audioGUIOUTIndex = 0 ;
14781497                    audioOUTDev = audioDevicesID_OUT.at (audioGUIOUTIndex);
14791498                }else {
14801499                    isOutputDeviceAvailable = false ;
@@ -1556,6 +1575,8 @@ void ofxVisualProgramming::loadPatch(string patchFile){
15561575            XML.popTag ();
15571576        }
15581577
1578+         bPopulatingObjectsMap   = true ;
1579+ 
15591580        int  totalObjects = XML.getNumTags (" object" 
15601581
15611582        if (totalObjects > 0 ){
@@ -1633,6 +1654,8 @@ void ofxVisualProgramming::loadPatch(string patchFile){
16331654            }
16341655        }
16351656
1657+         bPopulatingObjectsMap   = false ;
1658+ 
16361659        activateDSP ();
16371660
16381661    }
0 commit comments