]> granicus.if.org Git - imagemagick/commitdiff
Remove delegate spawn delay
authoranthony <anthony@git.imagemagick.org>
Sun, 20 May 2012 05:43:24 +0000 (05:43 +0000)
committeranthony <anthony@git.imagemagick.org>
Sun, 20 May 2012 05:43:24 +0000 (05:43 +0000)
MagickCore/delegate.c
MagickCore/property.c
config/delegates.xml.in

index 7753584881c45cbdbc0baf6310834f44c4e29317..2567c93f43b15b3637ef0c7e6bfea559dddbaad6 100644 (file)
@@ -926,7 +926,7 @@ MagickExport MagickBooleanType InvokeDelegate(ImageInfo *image_info,
         }
       if (AcquireUniqueFilename(image_info->zero) == MagickFalse)
         {
-          (void) RelinquishUniqueFileResource(image_info->zero);
+          (void) RelinquishUniqueFileResource(image_info->unique);
           ThrowFileException(exception,FileOpenError,
             "UnableToCreateTemporaryFile",image_info->zero);
           return(MagickFalse);
@@ -1033,8 +1033,16 @@ MagickExport MagickBooleanType InvokeDelegate(ImageInfo *image_info,
         */
         status=SystemCommand(delegate_info->spawn,image_info->verbose,command,
           exception) != 0 ? MagickTrue : MagickFalse;
-        if (delegate_info->spawn != MagickFalse)
-          (void) sleep(2);    /* FUTURE: A better way is needed! */
+        /* If spawn, wait for input file to 'disappear', or maximum 5 secs */
+        if (delegate_info->spawn != MagickFalse) {
+#if 1
+            ssize_t count=50;  /* 50 x 0.1 sec sleeps maximum */
+            while( count > 0 && access_utf8(image->filename,F_OK) == 0 )
+              (void) usleep(100000);  /* sleep 0.1 seconds */
+#else
+            (void) sleep(2);
+#endif
+          }
         command=DestroyString(command);
       }
     if (LocaleCompare(decode,"SCAN") != 0)
index 4dea2145bbde944b242728e0bf6fc536fecf3277..838211026d5c895ae23b2377805822fc79dc80db 100644 (file)
@@ -3039,16 +3039,11 @@ MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
     }
     p++; /* advance beyond the percent */
 
-    if ( *p == '\0' ) {
-      (void) ThrowMagickException(exception,GetMagickModule(),
-          OptionWarning,"UnknownImageProperty","\"%%\"");
-      p--;
-      continue;
-    }
-
     /*
-      Doubled Percent
+      Doubled Percent - or percent at end of string
     */
+    if ( *p == '\0' )
+       p--;
     if ( *p == '%' ) {
         *q++='%';
         continue;
index e3f0d4e5a7b68718f88b489fbf4b97ba814aa738..cdd6e04b497aeb585d9ead2ab939b18fad68671c 100644 (file)
 
   Set option delegate:bimodal=true to process bimodal delegates otherwise they
   are ignored.
+
+  If stealth="True" the delegate is not listed in user requested
+  "-list delegate" listings. These are typically special internal delegates.
+
+  If spawn="True" ImageMagick will not way for the delegate to finish,
+  nor will it read any output image.  It will only wait for either the input
+  file to be removed (See "ephemeral:" coder) indicating that the input file
+  has been read, or a maximum time limit of 2 seconds.
 -->
 <delegatemap>
   <delegate decode="autotrace" stealth="True" command="&quot;@ConvertDelegate@&quot; &quot;%i&quot; &quot;pnm:%u&quot;\n&quot;@AutotraceDecodeDelegate@&quot; -input-format pnm -output-format svg -output-file &quot;%o&quot; &quot;%u&quot;"/>
   <delegate decode="blender" command="&quot;@BlenderDecodeDelegate@&quot; -b &quot;%i&quot; -F PNG -o &quot;%o&quot;&quot;\n&quot;@ConvertDelegate@&quot; -concatenate &quot;%o*.png&quot; &quot;%o&quot;"/>
-  <delegate decode="browse" stealth="True" spawn="True" command="&quot;@BrowseDelegate@&quot; http://www.imagemagick.org/"/>
+  <delegate decode="browse" stealth="True" spawn="True" command="&quot;@BrowseDelegate@&quot; http://www.imagemagick.org/; rm &quot;%i&quot;"/>
   <delegate decode="cdr" command="&quot;@UniconvertorDelegate@&quot; &quot;%i&quot; &quot;%o.svg&quot;; mv &quot;%o.svg&quot; &quot;%o&quot;"/>
   <delegate decode="cgm" thread-support="False" command="&quot;@CGMDecodeDelegate@&quot; -d ps -oC &lt; &quot;%i&quot; &gt; &quot;%o&quot; 2&gt; &quot;%Z&quot;"/>
   <delegate decode="dvi" command="&quot;@DVIDecodeDelegate@&quot; -q -o &quot;%o&quot; &quot;%i&quot;"/>