From 6b414014de24dd9671e491c765c7c5535cd05d40 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 8 Feb 2018 10:41:01 +0100 Subject: Raise minimum GLib version to 2.38 --- CMakeLists.txt | 11 ++++--- bin/gui/uca-camera-control.c | 22 ++++--------- bin/tools/benchmark.c | 10 +++--- meson.build | 8 ++--- src/config.h.in | 2 ++ src/config.h.meson.in | 2 ++ src/meson.build | 5 ++- src/uca-camera.c | 76 ++++++++++++++++++++++---------------------- src/uca-plugin-manager.c | 4 ++- 9 files changed, 68 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b838fc..a04ce41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,10 +69,13 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package.sh.in #{{{ Common dependencies find_package(PkgConfig) find_program(GLIB2_MKENUMS glib-mkenums REQUIRED) -pkg_check_modules(GLIB2 glib-2.0>=2.28 REQUIRED) -pkg_check_modules(GOBJECT2 gobject-2.0>=2.28 REQUIRED) -pkg_check_modules(GMODULE2 gmodule-2.0>=2.28 REQUIRED) -pkg_check_modules(GIO2 gio-2.0>=2.28 REQUIRED) +pkg_check_modules(GLIB2 glib-2.0>=2.38 REQUIRED) +pkg_check_modules(GOBJECT2 gobject-2.0>=2.38 REQUIRED) +pkg_check_modules(GMODULE2 gmodule-2.0>=2.38 REQUIRED) +pkg_check_modules(GIO2 gio-2.0>=2.38 REQUIRED) + +set(GLIB_VERSION_MIN_REQUIRED "GLIB_VERSION_2_38") +set(GLIB_VERSION_MAX_ALLOWED "GLIB_VERSION_2_38") link_directories(${GLIB2_LIBRARY_DIRS}) #}}} diff --git a/bin/gui/uca-camera-control.c b/bin/gui/uca-camera-control.c index 375de2f..94f3bb8 100644 --- a/bin/gui/uca-camera-control.c +++ b/bin/gui/uca-camera-control.c @@ -1053,11 +1053,8 @@ on_start_button_clicked (GtkWidget *widget, ThreadData *data) data->state = RUNNING; set_tool_button_state (data); - if (!g_thread_create (preview_frames, data, FALSE, &error)) { - g_printerr ("Failed to create thread: %s\n", error->message); - data->state = IDLE; - set_tool_button_state (data); - } + /* FIXME: clean up struct */ + g_thread_new (NULL, preview_frames, data); } static void @@ -1094,11 +1091,8 @@ on_record_button_clicked (GtkWidget *widget, ThreadData *data) data->state = RECORDING; set_tool_button_state (data); - if (!g_thread_create (record_frames, data, FALSE, &error)) { - g_printerr ("Failed to create thread: %s\n", error->message); - data->state = IDLE; - set_tool_button_state (data); - } + /* FIXME: clean up struct */ + g_thread_new (NULL, record_frames, data); } static gpointer @@ -1160,11 +1154,8 @@ download_frames (ThreadData *data) static void on_download_button_clicked (GtkWidget *widget, ThreadData *data) { - GError *error = NULL; - - if (!g_thread_create ((GThreadFunc) download_frames, data, FALSE, &error)) { - g_printerr ("Failed to create thread: %s\n", error->message); - } + /* FIXME: clean up thread struct somewhere */ + g_thread_new (NULL, (GThreadFunc) download_frames, data); gtk_widget_set_sensitive (data->main_window, FALSE); gtk_window_set_modal (GTK_WINDOW (data->download_dialog), TRUE); @@ -1595,7 +1586,6 @@ main (int argc, char *argv[]) return 1; } - g_thread_init (NULL); gdk_threads_init (); gtk_init (&argc, &argv); diff --git a/bin/tools/benchmark.c b/bin/tools/benchmark.c index 99050f7..f6d7d7d 100644 --- a/bin/tools/benchmark.c +++ b/bin/tools/benchmark.c @@ -153,19 +153,19 @@ grab_frames_readout (UcaCamera *camera, gpointer buffer, guint n_frames, UcaCame static void grab_callback (gpointer data, gpointer user_data) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + static GMutex mutex; guint *n_acquired_frames = user_data; - g_static_mutex_lock (&mutex); + g_mutex_lock (&mutex); *n_acquired_frames += 1; - g_static_mutex_unlock (&mutex); + g_mutex_unlock (&mutex); } static guint grab_frames_async (UcaCamera *camera, gpointer buffer, guint n_frames, UcaCameraTriggerSource trigger_source, GTimer *timer) { GError *error = NULL; - volatile guint n_acquired_frames = 0; + guint n_acquired_frames = 0; g_object_set (camera, "trigger-source", trigger_source, NULL); uca_camera_set_grab_func (camera, grab_callback, &n_acquired_frames); @@ -363,8 +363,6 @@ main (int argc, char *argv[]) g_io_channel_shutdown (log_channel, TRUE, &error); g_assert_no_error (error); - -cleanup_camera: g_object_unref (camera); cleanup_manager: diff --git a/meson.build b/meson.build index a6d4ec9..5fdc6cf 100644 --- a/meson.build +++ b/meson.build @@ -10,10 +10,10 @@ version_patch = components[2] gnome = import('gnome') -glib_dep = dependency('glib-2.0', version: '>= 2.28') -gio_dep = dependency('gio-2.0', version: '>= 2.28') -gobject_dep = dependency('gobject-2.0', version: '>= 2.28') -gmodule_dep = dependency('gmodule-2.0', version: '>= 2.28') +glib_dep = dependency('glib-2.0', version: '>= 2.38') +gio_dep = dependency('gio-2.0', version: '>= 2.38') +gobject_dep = dependency('gobject-2.0', version: '>= 2.38') +gmodule_dep = dependency('gmodule-2.0', version: '>= 2.38') deps = [glib_dep, gio_dep, gobject_dep, gmodule_dep] diff --git a/src/config.h.in b/src/config.h.in index 4cceee4..0b58b4c 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -7,3 +7,5 @@ #cmakedefine HAVE_DEXELA_CL #cmakedefine HAVE_MOCK_CAMERA #define UCA_PLUGINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGINDIR}" +#define GLIB_VERSION_MIN_REQUIRED ${GLIB_VERSION_MIN_REQUIRED} +#define GLIB_VERSION_MAX_ALLOWED ${GLIB_VERSION_MAX_ALLOWED} diff --git a/src/config.h.meson.in b/src/config.h.meson.in index 33cacf6..fec239f 100644 --- a/src/config.h.meson.in +++ b/src/config.h.meson.in @@ -1 +1,3 @@ #mesondefine UCA_PLUGINDIR +#mesondefine GLIB_VERSION_MIN_REQUIRED +#mesondefine GLIB_VERSION_MAX_ALLOWED diff --git a/src/meson.build b/src/meson.build index b3bc649..5bd5509 100644 --- a/src/meson.build +++ b/src/meson.build @@ -13,6 +13,8 @@ plugindir = '@0@/@1@/uca'.format(get_option('prefix'), get_option('libdir')) conf = configuration_data() conf.set_quoted('UCA_PLUGINDIR', plugindir) +conf.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_38') +conf.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_38') configure_file( input: 'config.h.meson.in', @@ -36,9 +38,6 @@ sources += [enums_c, enums_h] lib = library('uca', sources: sources, dependencies: [glib_dep, gobject_dep, gmodule_dep, gio_dep], - c_args: [ - '-Wno-deprecated-declarations', - ], version: version, soversion: version_major, install: true, diff --git a/src/uca-camera.c b/src/uca-camera.c index a4545f2..99ff51e 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -135,7 +135,7 @@ const gchar *uca_camera_props[N_BASE_PROPERTIES] = { }; static GParamSpec *camera_properties[N_BASE_PROPERTIES] = { NULL, }; -static GStaticMutex access_lock = G_STATIC_MUTEX_INIT; +static GMutex access_lock; static gboolean str_to_boolean (const gchar *s); #define DEFINE_CAST(suffix, trans_func) \ @@ -766,8 +766,8 @@ uca_camera_start_recording (UcaCamera *camera, GError **error) { UcaCameraClass *klass; UcaCameraPrivate *priv; + static GMutex mutex; GError *tmp_error = NULL; - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; g_return_if_fail (UCA_IS_CAMERA (camera)); @@ -778,7 +778,7 @@ uca_camera_start_recording (UcaCamera *camera, GError **error) priv = camera->priv; - g_static_mutex_lock (&mutex); + g_mutex_lock (&mutex); if (priv->is_recording) { g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_RECORDING, @@ -792,9 +792,9 @@ uca_camera_start_recording (UcaCamera *camera, GError **error) goto start_recording_unlock; } - g_static_mutex_lock (&access_lock); + g_mutex_lock (&access_lock); (*klass->start_recording)(camera, &tmp_error); - g_static_mutex_unlock (&access_lock); + g_mutex_unlock (&access_lock); if (tmp_error == NULL) { priv->is_readout = FALSE; @@ -826,7 +826,7 @@ uca_camera_start_recording (UcaCamera *camera, GError **error) } start_recording_unlock: - g_static_mutex_unlock (&mutex); + g_mutex_unlock (&mutex); } /** @@ -841,8 +841,8 @@ uca_camera_stop_recording (UcaCamera *camera, GError **error) { UcaCameraClass *klass; UcaCameraPrivate *priv; + static GMutex mutex; GError *tmp_error = NULL; - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; g_return_if_fail (UCA_IS_CAMERA (camera)); @@ -853,7 +853,7 @@ uca_camera_stop_recording (UcaCamera *camera, GError **error) priv = camera->priv; - g_static_mutex_lock (&mutex); + g_mutex_lock (&mutex); if (!priv->is_recording) { g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING, @@ -868,12 +868,12 @@ uca_camera_stop_recording (UcaCamera *camera, GError **error) priv->read_thread = NULL; } - g_static_mutex_lock (&access_lock); + g_mutex_lock (&access_lock); (*klass->stop_recording)(camera, &tmp_error); priv->cancelling_recording = FALSE; - g_static_mutex_unlock (&access_lock); + g_mutex_unlock (&access_lock); if (tmp_error == NULL) { priv->is_recording = FALSE; @@ -890,7 +890,7 @@ uca_camera_stop_recording (UcaCamera *camera, GError **error) } error_stop_recording: - g_static_mutex_unlock (&mutex); + g_mutex_unlock (&mutex); } /** @@ -923,7 +923,7 @@ void uca_camera_start_readout (UcaCamera *camera, GError **error) { UcaCameraClass *klass; - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + static GMutex mutex; g_return_if_fail (UCA_IS_CAMERA(camera)); @@ -932,7 +932,7 @@ uca_camera_start_readout (UcaCamera *camera, GError **error) g_return_if_fail (klass != NULL); g_return_if_fail (klass->start_readout != NULL); - g_static_mutex_lock (&mutex); + g_mutex_lock (&mutex); if (camera->priv->is_recording) { g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_RECORDING, @@ -941,9 +941,9 @@ uca_camera_start_readout (UcaCamera *camera, GError **error) else { GError *tmp_error = NULL; - g_static_mutex_lock (&access_lock); + g_mutex_lock (&access_lock); (*klass->start_readout) (camera, &tmp_error); - g_static_mutex_unlock (&access_lock); + g_mutex_unlock (&access_lock); if (tmp_error == NULL) { camera->priv->is_readout = TRUE; @@ -954,7 +954,7 @@ uca_camera_start_readout (UcaCamera *camera, GError **error) g_propagate_error (error, tmp_error); } - g_static_mutex_unlock (&mutex); + g_mutex_unlock (&mutex); } /** @@ -970,7 +970,7 @@ void uca_camera_stop_readout (UcaCamera *camera, GError **error) { UcaCameraClass *klass; - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + static GMutex mutex; g_return_if_fail (UCA_IS_CAMERA(camera)); @@ -979,7 +979,7 @@ uca_camera_stop_readout (UcaCamera *camera, GError **error) g_return_if_fail (klass != NULL); g_return_if_fail (klass->stop_readout != NULL); - g_static_mutex_lock (&mutex); + g_mutex_lock (&mutex); if (camera->priv->is_recording) { g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_RECORDING, @@ -988,9 +988,9 @@ uca_camera_stop_readout (UcaCamera *camera, GError **error) else { GError *tmp_error = NULL; - g_static_mutex_lock (&access_lock); + g_mutex_lock (&access_lock); (*klass->stop_readout) (camera, &tmp_error); - g_static_mutex_unlock (&access_lock); + g_mutex_unlock (&access_lock); if (tmp_error == NULL) { camera->priv->is_readout = FALSE; @@ -1000,7 +1000,7 @@ uca_camera_stop_readout (UcaCamera *camera, GError **error) g_propagate_error (error, tmp_error); } - g_static_mutex_unlock (&mutex); + g_mutex_unlock (&mutex); } /** @@ -1032,7 +1032,7 @@ void uca_camera_trigger (UcaCamera *camera, GError **error) { UcaCameraClass *klass; - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + static GMutex mutex; g_return_if_fail (UCA_IS_CAMERA (camera)); @@ -1041,7 +1041,7 @@ uca_camera_trigger (UcaCamera *camera, GError **error) g_return_if_fail (klass != NULL); g_return_if_fail (klass->trigger != NULL); - g_static_mutex_lock (&mutex); + g_mutex_lock (&mutex); if (!camera->priv->is_recording) g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING, "Camera is not recording"); @@ -1049,7 +1049,7 @@ uca_camera_trigger (UcaCamera *camera, GError **error) (*klass->trigger) (camera, error); } - g_static_mutex_unlock (&mutex); + g_mutex_unlock (&mutex); } /** @@ -1103,7 +1103,7 @@ uca_camera_grab (UcaCamera *camera, gpointer data, GError **error) gboolean result = FALSE; /* FIXME: this prevents accessing two independent cameras simultanously. */ - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + static GMutex mutex; g_return_val_if_fail (UCA_IS_CAMERA(camera), FALSE); @@ -1114,7 +1114,7 @@ uca_camera_grab (UcaCamera *camera, gpointer data, GError **error) g_return_val_if_fail (data != NULL, FALSE); if (!camera->priv->buffered) { - g_static_mutex_lock (&mutex); + g_mutex_lock (&mutex); if (!camera->priv->is_recording && !camera->priv->is_readout) { g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING, @@ -1126,26 +1126,26 @@ uca_camera_grab (UcaCamera *camera, gpointer data, GError **error) PyGILState_STATE state = PyGILState_Ensure (); Py_BEGIN_ALLOW_THREADS - g_static_mutex_lock (&access_lock); + g_mutex_lock (&access_lock); result = (*klass->grab) (camera, data, error); - g_static_mutex_unlock (&access_lock); + g_mutex_unlock (&access_lock); Py_END_ALLOW_THREADS PyGILState_Release (state); } else { - g_static_mutex_lock (&access_lock); + g_mutex_lock (&access_lock); result = (*klass->grab) (camera, data, error); - g_static_mutex_unlock (&access_lock); + g_mutex_unlock (&access_lock); } #else - g_static_mutex_lock (&access_lock); + g_mutex_lock (&access_lock); result = (*klass->grab) (camera, data, error); - g_static_mutex_unlock (&access_lock); + g_mutex_unlock (&access_lock); #endif } - g_static_mutex_unlock (&mutex); + g_mutex_unlock (&mutex); } else { gpointer buffer; @@ -1197,7 +1197,7 @@ uca_camera_readout (UcaCamera *camera, gpointer data, guint index, GError **erro gboolean result = FALSE; /* FIXME: this prevents accessing two independent cameras simultanously. */ - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + static GMutex mutex; g_return_val_if_fail (UCA_IS_CAMERA(camera), FALSE); @@ -1213,14 +1213,14 @@ uca_camera_readout (UcaCamera *camera, gpointer data, guint index, GError **erro return FALSE; } - g_static_mutex_lock (&mutex); + g_mutex_lock (&mutex); if (!camera->priv->is_recording && !camera->priv->is_readout) { g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING, "Camera is not in readout or record mode"); } else { - g_static_mutex_lock (&access_lock); + g_mutex_lock (&access_lock); #ifdef WITH_PYTHON_MULTITHREADING if (Py_IsInitialized ()) { @@ -1239,10 +1239,10 @@ uca_camera_readout (UcaCamera *camera, gpointer data, guint index, GError **erro result = (*klass->readout) (camera, data, index, error); #endif - g_static_mutex_unlock (&access_lock); + g_mutex_unlock (&access_lock); } - g_static_mutex_unlock (&mutex); + g_mutex_unlock (&mutex); return result; } diff --git a/src/uca-plugin-manager.c b/src/uca-plugin-manager.c index 0958ae0..b4c7048 100644 --- a/src/uca-plugin-manager.c +++ b/src/uca-plugin-manager.c @@ -32,10 +32,12 @@ * * Since: 1.1 */ + +#include "config.h" + #include #include #include "uca-plugin-manager.h" -#include "config.h" G_DEFINE_TYPE (UcaPluginManager, uca_plugin_manager, G_TYPE_OBJECT) -- cgit v1.2.3