Bonjour à tous et toutes,
Voilà, je me retrouve avec une "access violation" quand je tente d'utiliser un TTimer.
J'ai vu sur la toile qu'il y avait un bug concernant le TTimer pour la version 2.2.0 de FPC mais que ce bug aurait été corrigé dans la version 2.2.2...
Qu'en est-il ?
En attendant je me retrouve coincé car j'ai besoin d'un timer dans un de mes projets et pour l'instant, le projet est mort
Voilà un exemple du code qui conduit à cet "access violation" chez moi:
Le TestTimer.lpr
Le Timer.pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 program TestTimer; {$mode objfpc}{$H+} uses Classes, Timer; var PU_Classe: TMyClass; begin PU_Classe := TMyClass.Create; repeat // Ne fait rien until PU_Classe.Count = 5; PU_Classe.Free; end.
Si quelqu'un à une idée, voir une solution je suis prenneur !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 unit Timer; {$mode objfpc}{$H+} interface uses Classes, SysUtils, ExtCtrls; type TMyClass = class private PR_Count: Byte; PR_Timer: TTimer; procedure MyOnTimer(Sender: TObject); public constructor Create; destructor Destroy; override; property Count: Byte read PR_Count; end; implementation procedure TMyClass.MyOnTimer(Sender: TObject); begin Inc(PR_Count); Write(PR_Count); end; constructor TMyClass.Create; begin PR_Count := 0; PR_Timer := TTimer.Create(nil); PR_Timer.Interval := 1000; PR_Timer.OnTimer := @MyOnTimer; // Si je ne mets pas le timer en route le programme ne génère aucune erreur // Le problème viendrait donc de là... PR_Timer.Enabled := True; end; destructor TMyClass.Destroy; begin PR_Timer.Free; end; end.
Quelques infos:
- Lazarus v0.9.26 beta
- FPC v2.2.2
- OS Linux (32 bits)
L'erreur générée:
Bonne journée à tous et toutes,[slander@localhost TestTimer]$ ./TestTimer
[FORMS.PP] ExceptionOccurred
Sender=EAccessViolation
Exception=Access violation
Stack trace:
$0811107A TCUSTOMTIMER__UPDATETIMER, line 136 of customtimer.pas
$08111172 TCUSTOMTIMER__SETONTIMER, line 172 of customtimer.pas
$080799C3 TMYCLASS__CREATE, line 37 of Timer.pas
$08048537 main, line 15 of TestTimer.lpr
TApplication.HandleException Access violation
Stack trace:
$0811107A TCUSTOMTIMER__UPDATETIMER, line 136 of customtimer.pas
$08111172 TCUSTOMTIMER__SETONTIMER, line 172 of customtimer.pas
$080799C3 TMYCLASS__CREATE, line 37 of Timer.pas
$08048537 main, line 15 of TestTimer.lpr
[FORMS.PP] ExceptionOccurred
Slander
Partager