View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0025666 | Lazarus | LCL | public | 2014-02-03 12:36 | 2016-12-25 15:20 |
Reporter | Sergey Bulba | Assigned To | Bart Broersma | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | win32 | OS | Windows | ||
Product Version | 1.2.0RC2 | ||||
Summary | 0025666: Wrong TEdit.Modified behavior? | ||||
Description | In my old programs on Delphi I'd used "TEdit.Modified" property to detect kind of changing: manual (typing from keyboard) or run-time (Edit1.Text := 'some text'). | ||||
Steps To Reproduce | Place Edit1 on Form1 in new project and write OnChange handler like: procedure TForm1.Edit1Change(Sender: TObject); begin if Edit1.Modified then begin //Section1: do analysis of manual Edit1.Text changing end else begin //Section2: was programmatic changing like Edit1.Text := 'some text' end; end; to ensure, that Section2 is never run in Lazarus, only in Delphi | ||||
Additional Information | Of course, it can be Delphi bug, and I must fix my old programs instead of Lazarus-bug reporting :) Sorry, if it is... | ||||
Tags | No tags attached. | ||||
Fixed in Revision | r45617 | ||||
LazTarget | - | ||||
Widgetset | Win32/Win64 | ||||
Attached Files |
|
|
You might be right. http://docwiki.embarcadero.com/VCL/2010/en/StdCtrls.TCustomEdit.Modified "Use Modified to determine whether the user changed the Text property of the edit control. Modified is only reset to False when you assign a value to the Text property. In particular, it is not reset when the control receives focus." Text := SomeText -> RealSetText -> triggers TextChanged -> sets Modified to True -> after that Modified is set to False in RealSetText. Maybe need to set a flag in RealSetText, so we can set Modified to false in TextChanged? Feels a bit hackish to me. |
|
This bug can cause a stack overflow because of recursive calls of TEdit.OnChange. For example, if we want modify user input "on the fly", due Modified is always True, recursive calls can stop only after new and old Text of TEdit will be identical, it is work in most cases, except like this: procedure TForm1.Edit1Change(Sender: TObject); begin if Edit1.Modified then Edit1.Text := IntToStr(StrToInt(Edit1.Text) + 1); end; If you press any number key in Edit1, you'll see overflow error. In Delphi 7 this example works as expected (without error). |
|
I understand it is a bug, no need to keep pointing it out. Just not sure what is the best way to solve it. If you desperately need it NOW, then do something like this: (file /lcl/customedit.inc) In TCustomEdit.RealSetText: Set a boolean flag (first declare it as a private field of TCustomEdit in stdctrls.pp) Set modified := False _before_ the call to inherited RealSetText In TCustomEdit TextChanged: Do not set Modified to True if the flag is True Reset the flag to False. Rebuild your app, it'll rebuild the lcl. This should (in theory) fix it. |
|
> Maybe need to set a flag in RealSetText, so we can set Modified to false in > TextChanged? This will make Modified = False in TMaskEdit always, so that won't do. |
|
Unassigning, don't see a quick solution. |
|
Please test and close if OK. |
|
Thanks, just tested |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-02-03 12:36 | Sergey Bulba | New Issue | |
2014-02-03 19:01 | Bart Broersma | Note Added: 0072836 | |
2014-02-03 19:25 | Bart Broersma | Note Edited: 0072836 | View Revisions |
2014-02-03 19:27 | Bart Broersma | Note Edited: 0072836 | View Revisions |
2014-02-03 19:28 | Bart Broersma | LazTarget | => - |
2014-02-03 19:28 | Bart Broersma | Status | new => confirmed |
2014-02-05 10:36 | Sergey Bulba | Note Added: 0072854 | |
2014-02-05 10:59 | Bart Broersma | Note Added: 0072855 | |
2014-02-05 16:58 | Bart Broersma | Assigned To | => Bart Broersma |
2014-02-05 16:58 | Bart Broersma | Status | confirmed => assigned |
2014-02-09 17:12 | Bart Broersma | Note Added: 0072969 | |
2014-02-20 18:44 | Bart Broersma | Note Added: 0073178 | |
2014-02-20 18:44 | Bart Broersma | Assigned To | Bart Broersma => |
2014-02-20 18:44 | Bart Broersma | Status | assigned => acknowledged |
2014-06-22 18:39 | Bart Broersma | Fixed in Revision | => r45617 |
2014-06-22 18:39 | Bart Broersma | Note Added: 0075849 | |
2014-06-22 18:39 | Bart Broersma | Status | acknowledged => resolved |
2014-06-22 18:39 | Bart Broersma | Resolution | open => fixed |
2014-06-22 18:39 | Bart Broersma | Assigned To | => Bart Broersma |
2016-12-25 15:20 | Sergey Bulba | Note Added: 0097075 | |
2016-12-25 15:20 | Sergey Bulba | Status | resolved => closed |