Another List
bites the dust...
This commit is contained in:
@ -453,7 +453,6 @@ FltkPlatform::FltkPlatform ()
|
||||
DBG_OBJ_CREATE ("dw::fltk::FltkPlatform");
|
||||
|
||||
layout = NULL;
|
||||
idleQueue = new container::typed::List <IdleFunc> (true);
|
||||
idleFuncRunning = false;
|
||||
idleFuncId = 0;
|
||||
|
||||
@ -467,7 +466,6 @@ FltkPlatform::~FltkPlatform ()
|
||||
{
|
||||
if (idleFuncRunning)
|
||||
Fl::remove_idle (generalStaticIdle, (void*)this);
|
||||
delete idleQueue;
|
||||
delete resources;
|
||||
|
||||
DBG_OBJ_DELETE ();
|
||||
@ -623,18 +621,16 @@ void FltkPlatform::generalStaticIdle (void *data)
|
||||
|
||||
void FltkPlatform::generalIdle ()
|
||||
{
|
||||
IdleFunc *idleFunc;
|
||||
|
||||
if (!idleQueue->isEmpty ()) {
|
||||
if (!idleQueue.empty ()) {
|
||||
/* Execute the first function in the list. */
|
||||
idleFunc = idleQueue->getFirst ();
|
||||
auto &idleFunc = idleQueue.front();
|
||||
(layout->*(idleFunc->func)) ();
|
||||
|
||||
/* Remove this function. */
|
||||
idleQueue->removeRef(idleFunc);
|
||||
idleQueue.remove(idleFunc);
|
||||
}
|
||||
|
||||
if (idleQueue->isEmpty()) {
|
||||
if (idleQueue.empty()) {
|
||||
idleFuncRunning = false;
|
||||
Fl::remove_idle (generalStaticIdle, (void*)this);
|
||||
}
|
||||
@ -656,29 +652,21 @@ int FltkPlatform::addIdle (void (core::Layout::*func) ())
|
||||
|
||||
idleFuncId++;
|
||||
|
||||
IdleFunc *idleFunc = new IdleFunc();
|
||||
auto idleFunc = std::make_unique< IdleFunc >();
|
||||
idleFunc->id = idleFuncId;
|
||||
idleFunc->func = func;
|
||||
idleQueue->append (idleFunc);
|
||||
idleQueue.push_back( std::move( idleFunc ) );
|
||||
|
||||
return idleFuncId;
|
||||
}
|
||||
|
||||
void FltkPlatform::removeIdle (int idleId)
|
||||
{
|
||||
bool found;
|
||||
container::typed::Iterator <IdleFunc> it;
|
||||
IdleFunc *idleFunc;
|
||||
const auto found= std::find_if( begin( idleQueue ), end( idleQueue ),
|
||||
[&]( const auto &idleFunc ) { return idleFunc->id == idleId; } );
|
||||
if( found != end( idleQueue ) ) idleQueue.erase( found );
|
||||
|
||||
for (found = false, it = idleQueue->iterator(); !found && it.hasNext(); ) {
|
||||
idleFunc = it.getNext();
|
||||
if (idleFunc->id == idleId) {
|
||||
idleQueue->removeRef (idleFunc);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (idleFuncRunning && idleQueue->isEmpty())
|
||||
if (idleFuncRunning && idleQueue.empty())
|
||||
Fl::remove_idle (generalStaticIdle, (void*)this);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ private:
|
||||
|
||||
core::Layout *layout;
|
||||
|
||||
lout::container::typed::List <IdleFunc> *idleQueue;
|
||||
std::list< std::unique_ptr< IdleFunc > > idleQueue;
|
||||
bool idleFuncRunning;
|
||||
int idleFuncId;
|
||||
|
||||
|
Reference in New Issue
Block a user