Fons N 17 Posted September 12, 2022 Delphi Pro 11.2 Sometimes, you accidently click on the wrong event, it's automatically created but also automatically deleted when building and/or saving the code. This is still the case. But if you put in some code, but afterwards you changed your mind and delete all code between begin and end, then in past versions is would also delete the (now) empty event. It no longer does this. Unfortunately. Can anyone conform this? Share this post Link to post
Stano 143 Posted September 12, 2022 It happens to me with some. Typically FormCreate... Share this post Link to post
Davide Angeli 44 Posted September 12, 2022 (edited) Just update to 11.2 and also for me works as aspected. I experienced too this problem in some forms in the previous versions (very rare). When happen I cut/paste the event piece of source at the unit end, then save and the empty event disappear as aspected. Edited September 12, 2022 by Davide Angeli Share this post Link to post
Uwe Raabe 2057 Posted September 12, 2022 If anyone experiences this, it would be helpful to capture the current state of the unit. Then we can inspect these units to detect similarities. I remember a case when Code Insight breaks after static string array declaration. It can be that we have something similar causing the behavior seen sometimes. Share this post Link to post
Fons N 17 Posted September 12, 2022 The good news... it seems to be an isolated incident, because I cannot reproduce it. 1 hour ago, Uwe Raabe said: If anyone experiences this, it would be helpful to capture the current state of the unit. Then we can inspect these units to detect similarities. If it happens again, I will save the pas and dfm files and report it here. Depending on the outcome, will then file a QR. Share this post Link to post
Philipp Hess 0 Posted April 20, 2023 (edited) Delphi 11.3 Patch 1 Can confirm the problem. Seems to happen if the the genereated methode is in a compiler directive. Can anyone confirm this? Is there already an open QR for it? Edited April 20, 2023 by Philipp Hess Added Question Share this post Link to post
Uwe Raabe 2057 Posted April 20, 2023 This highly depends on the actual code. Without one can hardly reproduce. Share this post Link to post
Anders Melander 1784 Posted April 20, 2023 procedure TFormFooBar.FormClick(Sender: TObject); begin end; { this comment prevents FormClick from being automatically removed } procedure TFormFooBar.FormCreate(Sender: TObject); begin // Blah end; Share this post Link to post
Philipp Hess 0 Posted April 20, 2023 procedure TFormFoo.FormClose(Sender: TObject; var Action: TCloseAction); begin end; procedure TFormFoo.FormCreate(Sender: TObject); begin end; // procedure TFormFoo.FormDblClick(Sender: TObject); begin end; {} I've testet a bit further. FormCreate and FormDblClick would stay and Form Close would be removed. Share this post Link to post
Uwe Raabe 2057 Posted April 20, 2023 So it boils down to adding a comment after the event body prohibits the deletion. This sound like a valid bug report. 1 Share this post Link to post
programmerdelphi2k 237 Posted April 20, 2023 On 9/12/2022 at 6:00 AM, Fons N said: Unfortunately. Can anyone conform this? Did you try delete the "event line in Form definition" like this: Quote Form1 :TForm1; ... public procedure MyEventRebeld(....); <---- detele this line, and try save again... the IDE will try "remove it" for Form DFM, then, you'll can delete the event-body in "implementation section" Share this post Link to post
Anders Melander 1784 Posted April 20, 2023 6 hours ago, Uwe Raabe said: So it boils down to adding a comment after the event body prohibits the deletion. This sound like a valid bug report. It's always been this way. It would actually annoy me if they spent time fixing this instead of some of the more important stuff. Defeatism, I know. Share this post Link to post
Fr0sT.Brutal 900 Posted April 21, 2023 This feature causes me more troubles than good. From time to time I add methods manually (important) to a form, write down name and args, generate method body, then go to somewhere else, do something and automatically hit Ctrl-S. Ouch, all my crafted declaration is gone! If only that removal could be undone! Share this post Link to post
Uwe Raabe 2057 Posted April 21, 2023 1 hour ago, Fr0sT.Brutal said: From time to time I add methods manually (important) to a form, write down name and args, generate method body, then go to somewhere else, do something and automatically hit Ctrl-S. Ouch, all my crafted declaration is gone! Usually this will only happen to published event handlers with empty var and code (except inherited) sections. A simple line comment in the code section prohibits it. Also, if the method is created manually it probably shouldn't reside in the published section, unless it is meant to be wired automatically on load. In that case it is questionable why it is created manually in the first place. Share this post Link to post
Fr0sT.Brutal 900 Posted April 21, 2023 (edited) 3 hours ago, Uwe Raabe said: A simple line comment in the code section prohibits it. Of course I'm aware. But these comments must be added manually which I forget to do from time to time. As for the section, these methods are event handlers that couldn't be added via clicking for some reasons. Anyway if any code changes were considered ordinary text edits and added to undo log, life would be much easier Edited April 21, 2023 by Fr0sT.Brutal Share this post Link to post
Uwe Raabe 2057 Posted April 21, 2023 13 minutes ago, Fr0sT.Brutal said: But these comments must be added manually which I forget to do from time to time. Perhaps I am too used to add methods with MMX Code Explorer, which inserts a TODO to each method by default. Share this post Link to post
Anders Melander 1784 Posted April 21, 2023 6 hours ago, Fr0sT.Brutal said: As for the section, these methods are event handlers that couldn't be added via clicking for some reasons. Only empty, published methods are removed. Are you saying that you manually add published event handlers? Share this post Link to post
programmerdelphi2k 237 Posted April 21, 2023 (edited) here I have: type TForm1 = class(TForm) procedure Button1Click(Sender: TObject); ... PUBLISHED // without it and "empty" method = will be removed! else any other combination, not! procedure Hello(const a: string); private // public // ... procedure TForm1.Hello(const a: string); begin // with this, dont will be removed! // else, if "empty" and "dont using "PUBLISHED" above = it will be removed end; Edited April 21, 2023 by programmerdelphi2k Share this post Link to post
Attila Kovacs 629 Posted April 21, 2023 (edited) *changed my mind* Edited April 21, 2023 by Attila Kovacs Share this post Link to post
Fr0sT.Brutal 900 Posted April 27, 2023 On 4/21/2023 at 10:32 PM, Anders Melander said: Only empty, published methods are removed. Are you saying that you manually add published event handlers? Yep, I rarely care about this. Handlers go to handlers. On 4/21/2023 at 3:46 PM, Uwe Raabe said: Perhaps I am too used to add methods with MMX Code Explorer, which inserts a TODO to each method by default. Nice feature! Share this post Link to post