Recent

Author Topic: 'fake' generation of function prototypes in IDE  (Read 9477 times)

aducom

  • Full Member
  • ***
  • Posts: 155
    • http://www.aducom.com
'fake' generation of function prototypes in IDE
« on: January 04, 2018, 11:43:54 am »
I'm not sure if it's only me but on a regular basis in lazarus 32 as lazarus 64 as well the IDE generates function prototypes of some functions that already exists in my code. Perhaps I'm using some odd key combination that causes this as I work on a laptop and the touchpad sometimes fools me. But it could also be an issue that needs to be reported in the bugtracker. It's not a real big deal as te compiler ends in error and removing the function prototypes will solve the issue, but as it happens pretty often it is annoying. I had no such behaviour in 1.6, only in 1.8. Anybody experiencing the same problem or has a solution? If there are more I will post this to the bug tracker.


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: 'fake' generation of function prototypes in IDE
« Reply #1 on: January 04, 2018, 01:21:30 pm »
Anybody experiencing the same problem or has a solution?
Difficult to say without more information. Attach a minimal project to reproduce the problem.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: 'fake' generation of function prototypes in IDE
« Reply #2 on: January 04, 2018, 04:08:55 pm »
I too; have had this and still do; but mainly on large projects, it is frustrating and annoying.
I have not been able to pin point the cause; but is more prone when I have lots of nested {$ifdef}, that have the defines in the project options/custom defines section. If I add the defines as source code in the all units ir {$define xxx} then the errors are a lot less more unlikely to happen.

This started in 1.8 and is still in svn, as I have not been able to produce a sample project that exhibits the behaviour, unfortuanetly I cannot upload the projects that may exhibit this behavious for various reasons.

When it starts to happen, I find that doing a re-scan of sources will help for a while, but what does last much longer is exit lazarus; restart lazarus and rebuild lazarus. This seems to help but not eleminate it, as it will come back.
I have noticed that just prior to it doing this, I also get one or both of the following happening.
1)Clicking an existing  components event; produces an error along the longs of tform not found, and does not locate you the event code.
2)The autocomplete of code stops working. ie typing "form1." does not bring up a list of proc/funcs. record variables does not bring up popup of variables. ie "my3dobj." will not bring up variables of record like, x,y,z,s etc that are defined in its record.

It is worth noting that it does not matter if you compile you project during your lazarus session as it can happen before you have even compiled your project for the first time in the session.

Hopefully some of the observations I have found will be useful.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: 'fake' generation of function prototypes in IDE
« Reply #3 on: January 04, 2018, 04:36:36 pm »
I believe I answered that already last month: remove empty methods
Specialize a type, not a var.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: 'fake' generation of function prototypes in IDE
« Reply #4 on: January 05, 2018, 10:51:31 pm »
When it starts to happen, I find that doing a re-scan of sources will help for a while, but what does last much longer is exit lazarus; restart lazarus and rebuild lazarus. This seems to help but not eleminate it, as it will come back.
That suggests some memory corruption or uninitialized variable issue. Strange. Anyway rebuilding Lazarus should not be needed, restarting it resets the situation.

Quote
It is worth noting that it does not matter if you compile you project during your lazarus session as it can happen before you have even compiled your project for the first time in the session.
Naturally because Codetools and FPC are separate and independent.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

aducom

  • Full Member
  • ***
  • Posts: 155
    • http://www.aducom.com
Re: 'fake' generation of function prototypes in IDE
« Reply #5 on: January 12, 2018, 11:56:12 am »
@thaddy, yes it generates empty methods of methods that already exists (and are not empty). To solve it, you remove the empty methods. Not sure if it's only in large projects, but mine is pretty large.

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: 'fake' generation of function prototypes in IDE
« Reply #6 on: January 17, 2018, 12:17:47 am »
I too have also seen this I earlier versions of laz to the present..

 I have one app that I ported from an old D1 source code (16 bit), most of which I simply used the
original files.. I also have the original files in a sub directory of that ported project folder.

 The project I have that does this is also  rather large and what I do now is go into the Tools, and
set the Code completion to delete empty methods..

 How I get it to trigger is when ever I add something to the class, it generates two empty method
blocks that already exist. So I end up with a two duplicated methods.

 The strange thing is I have other large projects and they don't do this. The only other difference is that
this project just happens to have some Message Handlers declared just below the two Methods that get
duplicated. I can't say if that has anything to do with it, it could just be coincidence.
   
The only true wisdom is knowing you know nothing

aducom

  • Full Member
  • ***
  • Posts: 155
    • http://www.aducom.com
Re: 'fake' generation of function prototypes in IDE
« Reply #7 on: January 18, 2018, 10:09:43 pm »
"and set the Code completion to delete empty methods.."

How do you do that? I see a macro option, but what do I need to do to remove empty methods automatically?

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: 'fake' generation of function prototypes in IDE
« Reply #8 on: January 18, 2018, 10:30:17 pm »
Well the option is difficult to find.
For some reason in the IDE Options dialog (Tools->Options...) the setting you want is under the Editor node, Completion and Hints subnode.
The first checkbox on that page is Auto remove empty methods.

I think it would be more logical to have it under CodeTools.

aducom

  • Full Member
  • ***
  • Posts: 155
    • http://www.aducom.com
Re: 'fake' generation of function prototypes in IDE
« Reply #9 on: January 19, 2018, 11:28:54 am »
Tnx, found it!



aducom

  • Full Member
  • ***
  • Posts: 155
    • http://www.aducom.com
Re: 'fake' generation of function prototypes in IDE
« Reply #10 on: January 26, 2018, 09:46:15 am »
Unfortunately, this is not always working. It helped (a lot) but sometimes the problem still occurs.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: 'fake' generation of function prototypes in IDE
« Reply #11 on: January 26, 2018, 10:07:24 am »
Indeed, there is a bug in CodeTools that causes unwanted production of multiple empty method headers at times.
Unfortunately no one has so far been able to pin down exactly what circumstances give rise to this, or to offer a patch that would correct it.
It is annoying (especially if you have a large class with many methods) and unpredictable, but not the end of the world.
I suspect it has something to do with CodeTools' caching mechanism, but I may be completely wrong about that.

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: 'fake' generation of function prototypes in IDE
« Reply #12 on: February 02, 2018, 12:16:55 am »
I would be willing to bet a "Application.ProcesseMessages" is being called in there somewhere, that can
cause unpredictable things to happen if code is responding to message events.

 I really dislike the use of doing that and have seen it in many cases... its bad practice.
The only true wisdom is knowing you know nothing

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: 'fake' generation of function prototypes in IDE
« Reply #13 on: February 02, 2018, 01:33:46 am »
I would be willing to bet a "Application.ProcesseMessages" is being called in there somewhere
Where in there somewhere do you mean?
At least Codetools does not call Application.ProcessMessages. It does not even depend on LCL.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

aducom

  • Full Member
  • ***
  • Posts: 155
    • http://www.aducom.com
Re: 'fake' generation of function prototypes in IDE
« Reply #14 on: June 03, 2018, 08:26:18 am »
It's been a while, but I don't want to start another topic in this case. It still happens, but for some reason I have the feeling that cutting and pasting components on the form triggers this somehow. Not sure how this could be related, but it's something I noticed and I hope it helps tracking down this annoying bug. Not a showstopper but still...

 

TinyPortal © 2005-2018