Page 1 of 1

Minor bug in NtMagick demo - it simply can't run as is...

Posted: 2007-01-10T20:00:25-07:00
by jvene
I downloaded 6.3.1-6, my first introduction to ImageMagick. Looking through the C source, I'm impressed by the depth of coverage, so I'm (almost) convinced this is the right choice for new project development.

I have a few concerns, though - for example:

In NtMagickView.cpp, in the function DoDisplayImage, the following snippet:

Code: Select all


  if (pDC != NULL )

Allows the drawing code to attempt to display a non-existent bitmap, crashing the app the moment it displays after launch.

Changing this to:

Code: Select all


  if (pDC != NULL && m_Image.isValid() )

Fixes that, so at least the demo will execute.

Is that an appropriate cure for a common situation like this?


I'm using Visual Studio 2005, and I run Fedora Core 5 in VMWare, with GCC, for cross platform development, soon to install Kubuntu as a cross check.

VS2005 naturally complains liberally in warnings about the CRT functions like sprintf and strcpy, but that's 'new' in this compiler.

What concerns me most are memory leaks.

The demo "UTIL_NtMagick" will show a few memory leaks if you just launch it, the close it without doing anything.

If you load an image, there's at least a few dozen (this is too long to count).

I've searched the forum on the subject, and aside from a few responses that amount to "we tried it and it doesn't leak here" - I don't find much.

I don't assume that means no one is looking.

Perhaps there's some setting (a define perhaps) I've not yet learned about that fixes this.

Posted: 2007-01-10T20:27:19-07:00
by magick
NtMagickView is a contributed project, the ImageMagick developers did not write it. We run memory checkers on the ImageMagick API's and utilities and are confident there are no memory leaks. However, its possible our regression tests missed something. If you can show a leak we are interested and will patch it promptly.

Posted: 2007-01-10T21:29:15-07:00
by jvene
That makes sense, thanks!

Indeed, as I discovered just now, both the NtMagick and IMDisplay examples have these leaks, but it's because neither called any form of 'DestroyMagick'.

Once I added that, there are no leaks whatsoever.

Posted: 2007-01-10T22:26:11-07:00
by magick
Why not post your patches here and we'll get them into the ImageMagick distribution.

Posted: 2007-01-15T18:06:04-07:00
by jvene
Sure!

Should I post code snippets here, in code tags, or elsewhere?

You'll think I'm out of my mind for it, but I'm running through all the code, making it capable of building in unicode under Windows.

Interested in that?

How would that be contributed?

Posted: 2007-01-15T18:18:36-07:00
by magick
Since its a contributed project you are free to enhance it as you see fit and contribute your changes back. If its a major change, you can post a URL to the updated code or send us a private message. We'll include your changes in the next ImageMagick release. If its just a few changes you can post a difference listing here.