Test if MagickWandGenesis() or MagickWandTerminus() called

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
chris_andsomenumbers
Posts: 4
Joined: 2014-01-02T10:23:06-07:00
Authentication code: 6789

Test if MagickWandGenesis() or MagickWandTerminus() called

Post by chris_andsomenumbers »

Hi. I can't seem to find any method of testing if Genesis or Terminus have been called. Do functions that test this exist?

I'm developing an application that uses MagickWand. It calls genesis and terminus in main, so this isn't a problem within my application. However, my application takes plugins that handle specific functionality. The idea being that others would develop these modules. In one of my reference modules, I'd like to use MagickWand. This is where I'm having my problem. If I call Genesis and Terminus in my module init and finalize functions, I get this error:

Code: Select all

magick/semaphore.c:290: LockSemaphoreInfo: Assertion `semaphore_info != (SemaphoreInfo *) ((void *)0)' failed.

I'm assuming this is caused by a second call to Genesis.

This leaves me with an unpleasant choice: I can either not use MagickWand in my module, and try to use a different library and add an extra dependency, or I can use my knowledge that Genesis has been called in the main application and not worry about it. However, while that's an assumption that I can make, I can't expect that others have implementation details of my application.

Am I mising something? Am I just approaching this the wrong way? Any help is appreciated!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Test if MagickWandGenesis() or MagickWandTerminus() call

Post by magick »

Try IsMagickInstantiated().
chris_andsomenumbers
Posts: 4
Joined: 2014-01-02T10:23:06-07:00
Authentication code: 6789

Re: Test if MagickWandGenesis() or MagickWandTerminus() call

Post by chris_andsomenumbers »

That would seem to be exactly what I'm looking for! Thank you for the quick reply!

That said, I can't find that function anywhere in the API documentation I've been using. (http://www.imagemagick.org/script/magick-wand.php) Is there some extra documentation somewhere that I missed?
chris_andsomenumbers
Posts: 4
Joined: 2014-01-02T10:23:06-07:00
Authentication code: 6789

Re: Test if MagickWandGenesis() or MagickWandTerminus() call

Post by chris_andsomenumbers »

Well, I just tried to run my app using IsMagickInstantiated(), and I'm having some more issues. No matter what, IsMagickInstantiated always returns 0. So, if I do this:

Code: Select all

MagickWandGenesis();
g_assert(IsMagickInstantiated());
I get an assertion failure:

Code: Select all

ERROR:photo_strip.c:84:dmp_pb_photo_strip_init: assertion failed: (IsMagickInstantiated())
Running through the debugger also shows this behavior.

I'm using ImageMagick 6.7.7.10 from the repositories with Ubuntu 13.04

Thanks in advance for your help!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Test if MagickWandGenesis() or MagickWandTerminus() call

Post by magick »

Can you try ImageMaagick 6.8.8-1, the current release? In the mean-time we'll add IsMagickWandInstantiated() to the MagickWand API in the next release, 6.8.8-2.
chris_andsomenumbers
Posts: 4
Joined: 2014-01-02T10:23:06-07:00
Authentication code: 6789

Re: Test if MagickWandGenesis() or MagickWandTerminus() call

Post by chris_andsomenumbers »

Ok, I just installed ImageMagick 6.8.8-1 from source. I gave this block of code a shot:

Code: Select all

MagickWandGenesis();
const gchar * testing = MagickGetVersion(NULL);
g_printf("%s", testing);
g_assert(IsMagickInstantiated());
...and I got the same result:

Code: Select all

ERROR:photo_strip.c:88:dmp_pb_photo_strip_init: assertion failed: (IsMagickInstantiated())
ImageMagick 6.8.8-1 Q16 x86_64 2014-01-03 http://www.imagemagick.org
I suppose going forward I can go back to tracking this manually within my application. Maybe I'll provide a callback that modules can use to check the state of MagickWand until the new IsMagickWandInstantiated() function is implemented.

Thanks for your help!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Test if MagickWandGenesis() or MagickWandTerminus() call

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.8-2 Beta, available by sometime tomorrow. Thanks.
Post Reply