[Lazarus] TTimer on design time

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] TTimer on design time

Fabio Luis Girardi
I'm doing some some controls that uses TTimer. I don't know why, but from some time ago, TTimer don't fire the OnTimer procedure. I see in their source and is wrote:


procedure TCustomTimer.UpdateTimer;
begin
  KillTimer;
  if (FEnabled) and (FInterval > 0)
  and (([CSDESIGNING,csLoading,csDestroying]*ComponentState=[]))
  and Assigned (FOnTimer) then begin
    //DebugLn(['TCustomTimer.UpdateTimer ',dbgsName(Self),' WidgetSet.CreateTimer']);
    FTimerHandle := WidgetSet.CreateTimer(FInterval, @Timer);
    if FTimerHandle=0 then begin
      FTimerHandle:=cIdNoTimer;
      raise EOutOfResources.Create(SNoTimers);
    end;
    if Assigned(OnStartTimer) then OnStartTimer(Self);
  end;
end;

So, what's the problem of fire OnTimer on Design time? Maybe I'm wrong, but at least version 0.9.29 fires this event at design time.


Regards,

Fabio

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TTimer on design time

Vincent Snijders
2011/4/19 [hidden email] <[hidden email]>:

> I'm doing some some controls that uses TTimer. I don't know why, but from
> some time ago, TTimer don't fire the OnTimer procedure. I see in their
> source and is wrote:
>
> procedure TCustomTimer.UpdateTimer;
> begin
>   KillTimer;
>   if (FEnabled) and (FInterval > 0)
>   and (([CSDESIGNING,csLoading,csDestroying]*ComponentState=[]))
>   and Assigned (FOnTimer) then begin
>     //DebugLn(['TCustomTimer.UpdateTimer ',dbgsName(Self),'
> WidgetSet.CreateTimer']);
>     FTimerHandle := WidgetSet.CreateTimer(FInterval, @Timer);
>     if FTimerHandle=0 then begin
>       FTimerHandle:=cIdNoTimer;
>       raise EOutOfResources.Create(SNoTimers);
>     end;
>     if Assigned(OnStartTimer) then OnStartTimer(Self);
>   end;
> end;
> So, what's the problem of fire OnTimer on Design time? Maybe I'm wrong, but
> at least version 0.9.29 fires this event at design time.

I am not sure, but
Assigned (FOnTimer) returns always false at design time. But this is
from before 0.9.28, with the removal of JitForms, see
http://wiki.lazarus.freepascal.org/Lazarus_0.9.28_release_notes#IDE_changes

See also the code change in TCustomTimer.SetOnTimer.

Vincent

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus