Recent

Author Topic: What is the best strategy for developing / testing a new component?  (Read 5354 times)

jwhitten

  • Jr. Member
  • **
  • Posts: 61
What is the best strategy for developing / testing a new component?

I'm asking this because my first attempt was pretty dismal. I'm not really sure why I even had a problem-- the code is really simple and I sat there and followed the directions in the faq-- "How to Write Lazarus Component"  [http://wiki.freepascal.org/How_To_Write_Lazarus_Component].

I originally developed my component as a plain unit in another program-- a self-contained object that was originally descended from "TObject", and it was working fine in my program. I changed the ancestor to "TComponent" when I upgraded it to a component, and followed the directions in the HowTo. When Lazarus recompiled the IDE, it immediately crashed with a fairly useless error when it tried to fire back up-- "Unknown Run-Time Error: 202". What is that even supposed to mean anyway !?!!

(EDIT: I've attached my attempt at making a component-- the one in the .pas file is the plain stub, the one with the .SAVE suffix, has my actual code)

So I tried recovering using the backup version of Lazarus-- "Lazarus.old.exe" which is created when you recompile the IDE. It worked-- one time. I used it to rebuild the IDE and then exited the program and restart the regular one. However, when I ran into the same issue a second time, it crashed again and the backup version did NOT work. (I suspect that the "bad" version became the backup version, rather than the "Old" version that I was actually running).

In any case, I got that resolved and tried again-- this time using a plain jane, stock stub-- the one that was generated when I used "Packages->New Component" and that created the same situation. My code apparently isn't even a factor ?!?!?

So my question really is, what is the best strategy for doing all this? I'm sure that at least a FEW of us make an error now and then...  :-[ but does it really have to be this devastating every time to get back to a workable state? Or is there some trick(s) that I'm missing?


Thanks for any advice or opinions!     :)


John
« Last Edit: November 07, 2013, 04:40:03 pm by jwhitten »
Some programmers seem Blaise about Pascal...

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: What is the best strategy for developing / testing a new component?
« Reply #1 on: November 07, 2013, 05:48:44 pm »
1) every time you compile the IDE the backup is replaced with the current lazarus.exe assuming that this is the lazarus that executes the compilation.

2) No there is no other way other than if you ran the old one and remove your component from the installed list there is no need to rebuild Lazarus as it will give you the same exe you already running. 

3) always keep a working version of lazarus some where to help you when everything goes wrong ee like now. I usually have 2 installation of lazarus on my disk not including the trunk version of fpc and lazarus one the one I work on nothing gets installed there unless it has already been tested somewhere else, and one I test components on usual y they are the same version but recently that changed so now the playground installation is the old work installation after it got replaced with a newer version.

AS for you problem I don't think the component is the problem try installing a couple of 3rd party components and see if raises the same problem ee a stack overflow http://community.freepascal.org/docs-html/user/userch14.html
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

jwhitten

  • Jr. Member
  • **
  • Posts: 61
Re: What is the best strategy for developing / testing a new component?
« Reply #2 on: November 07, 2013, 06:35:27 pm »
No, it's not other components. I have a number of components already installed. Not as many as I used to have, but maybe 5-10 extra packages. And they've been working fine without any problems. So I don't think that's it.
Some programmers seem Blaise about Pascal...

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: What is the best strategy for developing / testing a new component?
« Reply #3 on: November 07, 2013, 06:38:22 pm »
My playground installation is in ruins at the moment I'll take a closer look on the attached file after I fix it and report my findings.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12518
  • Debugger - SynEdit - and more
    • wiki
Re: What is the best strategy for developing / testing a new component?
« Reply #4 on: November 07, 2013, 06:59:25 pm »
1) In the worst case, if you have no working lazarus.exe :
- either use the makefile (though I can give you no tips for that)
- download the installer, install to a diff directory (un-select associations, and menu/desktop shortcut). Copy that lazarus. exe into your folder (only the exe). Ignore warnings at startup. Recompile (without your component)

2) To find out more about the crash (202 stack overflow http://www.freepascal.org/docs-html/user/userap4.html)
Debug the IDE.

- Make a separate bakup of a good lazarus.exe
- Recompile with full debug info  [1], but do NOT restart 
- Open the project: ide/lazarus.lpi
- F9 (or run from menu)

[1] a)
In "Configure build Lazarus" is a field for options. Put there
-gh -gw -godwarfsets

I suggest
-O-1  -gh -g -gw -godwarfsets   -Criot   -gtt 

and maybe add  -Sa

[1] b)
- Menu > Package > Open loaded package
- Chose FCL
- go to options (speed button in package win)
  TAB:  "Package Options" > Usage
  there is a "Custom" field (memo) under "Add options to dependent packages and projects"
  add
 $(IDEBuildOptions)
 in this memo

You do need to remove that later, as it forces almost all packages and projects into debug builds.

Or leave it, but change the options in "conf build laz" (you can have several profiles)

 

TinyPortal © 2005-2018