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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
jvene

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

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post 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.
jvene

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Why not post your patches here and we'll get them into the ImageMagick distribution.
jvene

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post 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.
Post Reply