Page 1 of 1

Test if MagickWandGenesis() or MagickWandTerminus() called

Posted: 2014-01-02T10:42:34-07:00
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!

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

Posted: 2014-01-02T13:04:32-07:00
by magick
Try IsMagickInstantiated().

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

Posted: 2014-01-02T15:10:54-07:00
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?

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

Posted: 2014-01-02T15:45:18-07:00
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!

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

Posted: 2014-01-02T16:32:26-07:00
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.

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

Posted: 2014-01-03T11:07:48-07:00
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!

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

Posted: 2014-01-03T11:17:12-07:00
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.