Index: trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.c	(revision 18957)
+++ trunk/psLib/src/imageops/psImageConvolve.c	(revision 19015)
@@ -7,6 +7,6 @@
 /// @author Eugene Magnier, IfA
 ///
-/// @version $Revision: 1.72 $ $Name: not supported by cvs2svn $
-/// @date $Date: 2008-08-08 18:07:30 $
+/// @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
+/// @date $Date: 2008-08-12 03:08:41 $
 ///
 /// Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -33,4 +33,9 @@
 
 #include "psImageConvolve.h"
+
+static bool threaded = false;           // Run image convolution threaded?
+
+
+
 
 static void kernelFree(psKernel *kernel)
@@ -865,5 +870,4 @@
 }
 
-
 psImage *psImageConvolveMask(psImage *out, const psImage *mask, psMaskType maskVal,
                              psMaskType setVal, int xMin, int xMax, int yMin, int yMax)
@@ -899,14 +903,4 @@
     }
 
-    static bool threadsInit = false;    // Threads initialised?
-    int numThreads = psThreadPoolSize();// Number of threads
-    if (numThreads > 0 && !threadsInit) {
-        psThreadTask *task = psThreadTaskAlloc("PSLIB_IMAGE_CONVOLVE_MASK", 8);
-        task->function = &imageConvolveMaskThread;
-        psThreadTaskAdd(task);
-        psFree(task);
-        threadsInit = true;
-    }
-
     int numRows = mask->numRows;        // Number of rows
     int numCols = mask->numCols;        // Number of columns
@@ -925,5 +919,6 @@
 
     // Rows
-    if (numThreads > 0) {
+    if (threaded) {
+        int numThreads = psThreadPoolSize(); // Number of threads
         float cols = (float)numCols / (float)numThreads; // Number of cols to do at once
         for (int i = 0; i < numThreads; i++) {
@@ -963,5 +958,6 @@
 
     // Columns
-    if (numThreads > 0) {
+    if (threaded) {
+        int numThreads = psThreadPoolSize(); // Number of threads
         float cols = (float)numCols / (float)numThreads; // Number of columns to do at once
         for (int i = 0; i < numThreads; i++) {
@@ -1064,2 +1060,25 @@
 }
 
+
+void psImageConvolveSetThreads(bool set)
+{
+    if (set && !threaded) {
+        {
+            psThreadTask *task = psThreadTaskAlloc("PSLIB_IMAGE_CONVOLVE_MASK", 8);
+            task->function = &imageConvolveMaskThread;
+            psThreadTaskAdd(task);
+            psFree(task);
+        }
+    } else if (!set && threaded) {
+        psThreadTaskDelete("PSLIB_IMAGE_CONVOLVE_MASK");
+    }
+
+    threaded = set;
+
+}
+
+bool psImageConvolveGetThreads(void)
+{
+    return threaded;
+}
+
