PDA

View Full Version : Help with debugging a conversion



jdarling
10-02-2009, 10:07 PM
Ok, I'm going snow-blind trying to find my mistake. A while back I wrote a simple little pixelart editor and decided to convert it over to Lazarus so I can use it on my Mac, Linux, and PC systems.

All was going well until I decided to "optimize" the graphics by creating my own layered image support. This works a treat and is MUCH faster then using per pixel manip via the LCL.

The problem is when I try and load an existing image from my HD using TPicture, TGraphic, TBitmap, whatever it all goes across the gap and I get errors in strange places.

This leads me to believe that I've screwed up and am either overriding memory some place, or have a memory leak some place that isn't so obvious.

If anyone can look at the source and tell me where/what I'm doing wrong I'd really appreciate it.

Download http://www.eonclash.com/PGD/ImageEditor.zip

PS: This is only the start of the conversion, lots more work to be completed before I'm done. I know the code is a mess and once I have this part working I'm going to start cleaning it up. This requires a version of Lazarus that has "frame" support to compile.

paul_nicholls
11-02-2009, 12:31 AM
Hi Jeremy :-)
I tried running the .exe and then opening up a .png file - I straight away got an access violation.

Is this one of the bugs you mean?

Also what version of Lazarus do I need...I have 0.9.26 beta installed.

It has errors about unknown properties when opening the project.

cheers,
Paul

Legolas
11-02-2009, 07:19 AM
Lazarus 0.9.27 beta here :)
As far as I can see, it seems something related to layer size. When loading a new image, TImageLayer.Resize is called, but NewWidth and NewHeight are 0, so you get an error in the fillchar call.

Just an advice: when debugging a project in Lazarus, it is useful to activate code checks (Project->Compiler options->Code->Checks[-Ci, -Cr, -Co, -Ct, -CR]) and debug infos (Project->Compiler options->Linking->Debugging[-g, -gl]), that in your project are disabled. With debug infos you can step over your code, so it is easier to debug :)

jdarling
11-02-2009, 04:21 PM
Paul, that's exactly the problem I'm having. Though at times I can open a pic just fine and others won't open at all. Size doesn't seem to matter much, as one run I can open one, and on another run I can't.

I get an error when the code tries to release the TPicture instance after I draw its TGraphic onto my temp PNG in LoadFrom. It just doesn't make any sense as the same code in another application works just fine.

I'm beginning to wonder if this has something to do with the frames and a memory problem. Guess I should try it without the frames and see what happens.

Legolas, I've tried that. Problem is the error comes from so deep in the system that the lazarus debugger only shows me the assembly window. A call stack trace shows no known lines of code. I've tried stepping down with F7 to the problem but it moves every few runs. I'm leaning more and more towards memory leak or problem with frames.

paul_nicholls
11-02-2009, 09:48 PM
Hi Legolas,
Perhaps this is a "dumb question (tm)", but where do I get Lazarus 0.9.27 beta from?

The downloads only have 0.9.26 available...

cheers,
Paul

jdarling
11-02-2009, 09:55 PM
Why you download the Daily Snapshot and prey it works: http://snapshots.lazarus.shikami.org/lazarus/

Or you can use the same version I'm on: http://www.eonclash.com/PGD/Lazarus-0.9.27-18350-fpc-2.2.3-20090120-win32.exe

That's the latest Daily that compiles and actually works that I've found LOL

paul_nicholls
12-02-2009, 04:26 AM
Why you download the Daily Snapshot and prey it works: http://snapshots.lazarus.shikami.org/lazarus/

Or you can use the same version I'm on: http://www.eonclash.com/PGD/Lazarus-0.9.27-18350-fpc-2.2.3-20090120-win32.exe

That's the latest Daily that compiles and actually works that I've found LOL

I like that, download and pray that it works!! lol

Thanks, I will download the exe and try it :)
cheers,
Paul