Another List bites the dust...

This commit is contained in:
2025-08-09 11:30:10 -04:00
parent 4ce4fac659
commit 73df5edac6
2 changed files with 11 additions and 23 deletions

View File

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

View File

@ -133,7 +133,7 @@ private:
core::Layout *layout; core::Layout *layout;
lout::container::typed::List <IdleFunc> *idleQueue; std::list< std::unique_ptr< IdleFunc > > idleQueue;
bool idleFuncRunning; bool idleFuncRunning;
int idleFuncId; int idleFuncId;