From: beware Date: Thu, 19 Sep 2019 13:07:07 +0000 (+0000) Subject: fixed repeating the same task if processmessages inside handler X-Git-Url: http://www.lcore.org/git/lcore.git/commitdiff_plain/ac385c745f6e299bea549eb2006b803e3885c916 fixed repeating the same task if processmessages inside handler git-svn-id: file:///svnroot/lcore/trunk@154 b1de8a11-f9be-4011-bde0-cc7ace90066a --- diff --git a/lcore.pas b/lcore.pas index 097ea79..109f4d7 100644 --- a/lcore.pas +++ b/lcore.pas @@ -812,27 +812,17 @@ end; {$endif} procedure processtasks;//inline; -var - temptask : tltask ; - begin - if not assigned(currenttask) then begin + while assigned(firsttask) do begin currenttask := firsttask; - firsttask := nil; - lasttask := nil; - end; - while assigned(currenttask) do begin + firsttask := firsttask.nexttask; + if not assigned(firsttask) then lasttask := nil; if assigned(currenttask.handler) then currenttask.handler(currenttask.wparam,currenttask.lparam); - if assigned(currenttask) then begin - temptask := currenttask; - currenttask := currenttask.nexttask; - temptask.free; - end; - //writeln('processed a task'); - end; + end; + currenttask := nil; end; @@ -841,23 +831,18 @@ end; procedure disconnecttasks(aobj:tobject); var currenttasklocal : tltask ; - counter : byte ; + begin - for counter := 0 to 1 do begin - if counter = 0 then begin - currenttasklocal := firsttask; //main list of tasks - end else begin - currenttasklocal := currenttask; //needed in case called from a task - end; - // note i don't bother to destroy the links here as that will happen when - // the list of tasks is processed anyway - while assigned(currenttasklocal) do begin - if currenttasklocal.obj = aobj then begin - currenttasklocal.obj := nil; - currenttasklocal.handler := nil; - end; - currenttasklocal := currenttasklocal.nexttask; + currenttasklocal := firsttask; //main list of tasks + + // note i don't bother to destroy the links here as that will happen when + // the list of tasks is processed anyway + while assigned(currenttasklocal) do begin + if currenttasklocal.obj = aobj then begin + currenttasklocal.obj := nil; + currenttasklocal.handler := nil; end; + currenttasklocal := currenttasklocal.nexttask; end; end;