Fix #314: Remote commands for thumbnail maintenance
[geeqie.git] / src / image-load.c
index 1af4285..bafc16c 100644 (file)
@@ -1,16 +1,24 @@
 /*
- * Geeqie
- * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-
 #include "main.h"
 #include "image-load.h"
 #include "image_load_gdk.h"
@@ -99,8 +107,15 @@ static void image_loader_init(GTypeInstance *instance, gpointer g_class)
        il->can_destroy = TRUE;
 
 #ifdef HAVE_GTHREAD
+#if GLIB_CHECK_VERSION(2,32,0)
+       il->data_mutex = g_new(GMutex, 1);
+       g_mutex_init(il->data_mutex);
+       il->can_destroy_cond = g_new(GCond, 1);
+       g_cond_init(il->can_destroy_cond);
+#else
        il->data_mutex = g_mutex_new();
        il->can_destroy_cond = g_cond_new();
+#endif
 #endif
        DEBUG_1("new image loader %p, bufsize=%" G_GSIZE_FORMAT " idle_loop=%u", il, il->read_buffer_size, il->idle_read_loop_count);
 }
@@ -210,9 +225,16 @@ static void image_loader_finalize(GObject *object)
 
        file_data_unref(il->fd);
 #ifdef HAVE_GTHREAD
+#if GLIB_CHECK_VERSION(2,32,0)
+       g_mutex_clear(il->data_mutex);
+       g_free(il->data_mutex);
+       g_cond_clear(il->can_destroy_cond);
+       g_free(il->can_destroy_cond);
+#else
        g_mutex_free(il->data_mutex);
        g_cond_free(il->can_destroy_cond);
 #endif
+#endif
 }
 
 void image_loader_free(ImageLoader *il)
@@ -592,6 +614,8 @@ static void image_loader_setup_loader(ImageLoader *il)
 #ifdef HAVE_TIFF
        if (il->bytes_total >= 10 &&
            (memcmp(il->mapped_file, "MM\0*", 4) == 0 ||
+            memcmp(il->mapped_file, "MM\0+\0\x08\0\0", 8) == 0 ||
+            memcmp(il->mapped_file, "II+\0\x08\0\0\0", 8) == 0 ||
             memcmp(il->mapped_file, "II*\0", 4) == 0))
                {
                DEBUG_1("Using custom tiff loader");
@@ -1003,8 +1027,15 @@ static gboolean image_loader_start_thread(ImageLoader *il)
         if (!image_loader_thread_pool)
                {
                image_loader_thread_pool = g_thread_pool_new(image_loader_thread_run, NULL, -1, FALSE, NULL);
+#if GLIB_CHECK_VERSION(2,32,0)
+               if (!image_loader_prio_cond) image_loader_prio_cond = g_new(GCond, 1);
+               g_cond_init(image_loader_prio_cond);
+               if (!image_loader_prio_mutex) image_loader_prio_mutex = g_new(GMutex, 1);
+               g_mutex_init(image_loader_prio_mutex);
+#else
                image_loader_prio_cond = g_cond_new();
                image_loader_prio_mutex = g_mutex_new();
+#endif
                }
 
        il->can_destroy = FALSE; /* ImageLoader can't be freed until image_loader_thread_run finishes */