Changeset 362 in flair-src


Ignore:
Timestamp:
Jul 23, 2020, 4:45:20 PM (17 months ago)
Author:
Sanahuja Guillaume
Message:

stop all threads then delete them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/FrameworkManager.cpp

    r217 r362  
    7575    getUiCom()->Join();
    7676  }
    77 
     77/*
     78//stop and delete each thread has been changed to stop all thread, then delete all threads
     79//seems ok but needs more testing
     80 *
    7881  // we start by deleting threads (except pimpl which must be deleted at last)
    7982  // (before deleting objects that could be used by the threads)
     
    97100    }
    98101  }
    99 
     102*/
     103  // we start by stopping threads (except pimpl which must be deleted at last)
     104  // (before deleting objects that could be used by the threads)
     105  //Printf("stop Threads\n");
     106  for (vector<const Object *>::iterator it = Childs()->begin();it < Childs()->end(); it++) {
     107     //Printf("child %i %s %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str());
     108    if ((*it)->ObjectType() == "Thread") {
     109      if (*it != pimpl_) {
     110         //Printf("stop\n");
     111        ((Thread *)(*it))->SafeStop();
     112        ((Thread *)(*it))->Join();
     113         //Printf("stop ok\n");
     114      }
     115    }
     116  }
     117  //then delete threads
     118    //Printf("del Threads\n");
     119  for (vector<const Object *>::iterator it = Childs()->begin();it < Childs()->end(); it++) {
     120     //Printf("child %i %s %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str());
     121    if ((*it)->ObjectType() == "Thread") {
     122      if (*it != pimpl_) {
     123        // Printf("del\n");
     124        delete (Thread *)(*it);
     125        // Childs() vector has been modified, we start from beginning again
     126        // it will be incremented by the loop, so in fact we start again at
     127        // begin()+1
     128        // it is not a problem since begin is pimpl
     129        it = Childs()->begin();
     130        //Printf("del ok\n");
     131      }
     132    }
     133  }
     134 
    100135  // next we delete IODevice
    101136  // (before deleting objects that could be used by the IODevice)
Note: See TracChangeset for help on using the changeset viewer.