Fix some deprecation warnings

This commit is contained in:
Yevgen Muntyan 2014-12-06 12:16:16 -08:00
parent 5e713bc05d
commit e20f5cf49c
9 changed files with 144 additions and 48 deletions

View File

@ -94,9 +94,6 @@ _MOO_AC_CHECK_COMPILER_OPTIONS([dnl
-Wno-missing-field-initializers -Wno-overlength-strings dnl
-Wno-format-y2k -Wno-overlength-strings dnl
])
_MOO_AC_CHECK_C_COMPILER_OPTIONS([dnl
-Wno-missing-declarations dnl
])
_MOO_AC_CHECK_CXX_COMPILER_OPTIONS([dnl
-std=c++98 -fno-rtti dnl
])
@ -294,10 +291,17 @@ AC_DEFUN_ONCE([MOO_AC_FLAGS],[
MOO_CPPFLAGS="$MOO_CPPFLAGS -I$moo_top_src_dir/moo -DXDG_PREFIX=_moo_edit_xdg -DG_LOG_DOMAIN=\\\"Moo\\\""
MOO_LIBS="$MOO_LIBS $GTK_LIBS $GTHREAD_LIBS $GMODULE_LIBS $LIBM"
# G_DISABLE_DEPRECATED (or rather lack of it) is not respected anymore. Glib wants you
# to define it; if you don't, then you got to jump through additional hoops in order to
# really not disable deprecated stuff.
MOO_CPPFLAGS="$MOO_CPPFLAGS -DGLIB_DISABLE_DEPRECATION_WARNINGS=1"
if test "x$MOO_STRICT_MODE" != "xyes"; then
# G_DISABLE_DEPRECATED (or rather lack of it) is not respected anymore. Glib wants you
# to define it; if you don't, then you got to jump through additional hoops in order to
# really not disable deprecated stuff.
MOO_CPPFLAGS="$MOO_CPPFLAGS -DGLIB_DISABLE_DEPRECATION_WARNINGS=1"
else
#MOO_CPPFLAGS="$MOO_CPPFLAGS -DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED"
#MOO_CPPFLAGS="$MOO_CPPFLAGS -DGSEAL_ENABLE"
#MOO_CPPFLAGS="$MOO_CPPFLAGS -DGTK_DISABLE_SINGLE_INCLUDES"
true
fi
if $GDK_X11; then
_moo_x_pkgs=

View File

@ -695,7 +695,7 @@ _gtk_source_language_file_parse_version1 (GtkSourceLanguage *language,
doc = xmlParseMemory (g_mapped_file_get_contents (mf),
g_mapped_file_get_length (mf));
g_mapped_file_free (mf);
g_mapped_file_unref (mf);
}
if (doc == NULL)

View File

@ -706,7 +706,9 @@ medit_main (int argc, char *argv[])
MooOpenInfoArray *files;
init_mem_stuff ();
#if !GLIB_CHECK_VERSION(2,32,0)
g_thread_init (NULL);
#endif
g_set_prgname ("medit");
ctx = parse_args (argc, argv);

View File

@ -634,7 +634,7 @@ moo_app_init_ui (MooApp *app)
moo_ui_xml_add_ui_from_string (xml,
g_mapped_file_get_contents (file),
g_mapped_file_get_length (file));
g_mapped_file_free (file);
g_mapped_file_unref (file);
break;
}

View File

@ -71,6 +71,10 @@ _moo_gtk_action_connect_proxy (GtkAction *action,
#endif /* GTK_DISABLE_DEPRECATED */
#if GTK_CHECK_VERSION(2,24,0)
#undef GTK_WIDGET_REALIZED
#define GTK_WIDGET_REALIZED(w) gtk_widget_get_realized (GTK_WIDGET (w))
#endif // GTK_CHECK_VERSION(2,24,0)
#if GTK_CHECK_VERSION(2,22,0) && defined(GTK_DISABLE_DEPRECATED)
@ -127,17 +131,4 @@ _moo_gdk_drawable_get_size (GdkDrawable *drawable,
#endif /* gtk-2.24.0 && DISABLE_DEPRECATED */
#if GLIB_CHECK_VERSION(2,22,0) && defined(G_DISABLE_DEPRECATED)
inline static void
_moo_g_mapped_file_free (GMappedFile *file)
{
g_mapped_file_unref (file);
}
#define g_mapped_file_free _moo_g_mapped_file_free
#endif /* gtk-2-16 && GTK_DISABLE_DEPRECATED */
#endif /* MOO_GTK_H */

View File

@ -604,9 +604,9 @@ same_content (const char *filename1,
out:
if (file1)
g_mapped_file_free (file1);
g_mapped_file_unref (file1);
if (file2)
g_mapped_file_free (file2);
g_mapped_file_unref (file2);
return equal;
}

View File

@ -1770,7 +1770,11 @@ parse_property (GParamSpec *param_spec,
if (param_spec->value_type == G_TYPE_CHAR)
{
#if GLIB_CHECK_VERSION(2,32,0)
g_value_set_schar (&param->value, value[0]);
#else
g_value_set_char (&param->value, value[0]);
#endif
}
else if (param_spec->value_type == G_TYPE_UCHAR)
{

View File

@ -861,18 +861,42 @@ moo_set_log_func_window (gboolean show_now)
static char *moo_log_file;
static gboolean moo_log_file_written;
#if GLIB_CHECK_VERSION(2,32,0)
static GRecMutex moo_log_file_mutex;
static void moo_static_rec_mutex_lock (GRecMutex *mutex)
{
g_rec_mutex_lock (mutex);
}
static void moo_static_rec_mutex_unlock (GRecMutex *mutex)
{
g_rec_mutex_unlock (mutex);
}
#else
static GStaticRecMutex moo_log_file_mutex = G_STATIC_REC_MUTEX_INIT;
static void moo_static_rec_mutex_lock (GStaticRecMutex *mutex)
{
g_static_rec_mutex_lock (mutex);
}
static void moo_static_rec_mutex_unlock (GStaticRecMutex *mutex)
{
g_static_rec_mutex_unlock (mutex);
}
#endif
static void
print_func_file (const char *string)
{
FILE *file;
g_static_rec_mutex_lock (&moo_log_file_mutex);
moo_static_rec_mutex_lock (&moo_log_file_mutex);
if (!moo_log_file)
{
g_static_rec_mutex_unlock (&moo_log_file_mutex);
moo_static_rec_mutex_unlock (&moo_log_file_mutex);
g_return_if_reached ();
}
@ -896,7 +920,7 @@ print_func_file (const char *string)
/* TODO ??? */
}
g_static_rec_mutex_unlock (&moo_log_file_mutex);
moo_static_rec_mutex_unlock (&moo_log_file_mutex);
}
@ -924,11 +948,11 @@ log_func_file (const char *log_domain,
void
moo_set_log_func_file (const char *log_file)
{
g_static_rec_mutex_lock (&moo_log_file_mutex);
moo_static_rec_mutex_lock (&moo_log_file_mutex);
g_free (moo_log_file);
moo_log_file = g_strdup (log_file);
set_print_funcs (log_func_file, print_func_file, print_func_file);
g_static_rec_mutex_unlock (&moo_log_file_mutex);
moo_static_rec_mutex_unlock (&moo_log_file_mutex);
}

View File

@ -66,10 +66,77 @@ typedef struct {
} EventQueue;
#if !GLIB_CHECK_VERSION(2,32,0)
static GStaticMutex queue_lock = G_STATIC_MUTEX_INIT;
#else
static GMutex queue_lock;
#endif
static EventQueue queue;
#if GLIB_CHECK_VERSION(2,32,0)
static GMutex *moo_mutex_new ()
{
GMutex *mutex = g_slice_new (GMutex);
g_mutex_init (mutex);
return mutex;
}
static void moo_mutex_free (GMutex* mutex)
{
if (mutex)
{
g_mutex_clear (mutex);
g_slice_free (GMutex, mutex);
}
}
static void moo_static_mutex_lock (GMutex* mutex)
{
g_mutex_lock (mutex);
}
static void moo_static_mutex_unlock (GMutex* mutex)
{
g_mutex_unlock (mutex);
}
static GThread *
moo_thread_create (GThreadFunc thread_func,
gpointer data)
{
return g_thread_new (NULL, thread_func, data);
}
#else
static GMutex *moo_mutex_new ()
{
return g_mutex_new ();
}
static void moo_mutex_free (GMutex* mutex)
{
g_mutex_free (mutex);
}
static void moo_static_mutex_lock (GStaticMutex* mutex)
{
g_static_mutex_lock (mutex);
}
static void moo_static_mutex_unlock (GStaticMutex* mutex)
{
g_static_mutex_unlock (mutex);
}
static GThread *
moo_thread_create (GThreadFunc thread_func,
gpointer data)
{
return g_thread_create (thread_func, data, FALSE, NULL);
}
#endif
static QueueClient *
get_event_client (guint id)
{
@ -136,11 +203,11 @@ got_data (GIOChannel *io)
GHashTable *data;
char buf[1];
g_static_mutex_lock (&queue_lock);
moo_static_mutex_lock (&queue_lock);
data = queue.data;
queue.data = NULL;
g_io_channel_read_chars (io, buf, 1, NULL, NULL);
g_static_mutex_unlock (&queue_lock);
moo_static_mutex_unlock (&queue_lock);
g_hash_table_foreach (data, (GHFunc) invoke_callback, NULL);
g_hash_table_destroy (data);
@ -156,7 +223,7 @@ _moo_event_queue_do_events (guint event_id)
g_return_if_fail (queue.init);
g_static_mutex_lock (&queue_lock);
moo_static_mutex_lock (&queue_lock);
if (queue.data)
{
@ -166,7 +233,7 @@ _moo_event_queue_do_events (guint event_id)
g_hash_table_remove (queue.data, GUINT_TO_POINTER (event_id));
}
g_static_mutex_unlock (&queue_lock);
moo_static_mutex_unlock (&queue_lock);
if (events)
invoke_callback (GUINT_TO_POINTER (event_id), events);
@ -179,7 +246,7 @@ init_queue (void)
if (g_atomic_int_get (&queue.init))
return;
g_static_mutex_lock (&queue_lock);
moo_static_mutex_lock (&queue_lock);
if (!queue.init)
{
@ -214,7 +281,7 @@ init_queue (void)
}
out:
g_static_mutex_unlock (&queue_lock);
moo_static_mutex_unlock (&queue_lock);
}
@ -234,10 +301,10 @@ _moo_event_queue_connect (MooEventQueueCallback callback,
client->callback_data = data;
client->notify = notify;
g_static_mutex_lock (&queue_lock);
moo_static_mutex_lock (&queue_lock);
client->id = ++queue.last_id;
queue.clients = queue_client_list_prepend (queue.clients, client);
g_static_mutex_unlock (&queue_lock);
moo_static_mutex_unlock (&queue_lock);
return client->id;
}
@ -251,7 +318,7 @@ _moo_event_queue_disconnect (guint event_id)
g_return_if_fail (event_id != 0);
g_return_if_fail (queue.init);
g_static_mutex_lock (&queue_lock);
moo_static_mutex_lock (&queue_lock);
client = get_event_client (event_id);
@ -260,7 +327,7 @@ _moo_event_queue_disconnect (guint event_id)
else
queue.clients = queue_client_list_remove (queue.clients, client);
g_static_mutex_unlock (&queue_lock);
moo_static_mutex_unlock (&queue_lock);
if (client && client->notify)
client->notify (client->callback_data);
@ -284,7 +351,7 @@ _moo_event_queue_push (guint event_id,
event_data->destroy = data_destroy;
event_data->id = event_id;
g_static_mutex_lock (&queue_lock);
moo_static_mutex_lock (&queue_lock);
if (!queue.data)
{
@ -302,7 +369,7 @@ _moo_event_queue_push (guint event_id,
event_data_queue_push_tail (events, event_data);
g_static_mutex_unlock (&queue_lock);
moo_static_mutex_unlock (&queue_lock);
}
@ -310,7 +377,11 @@ _moo_event_queue_push (guint event_id,
/* Messages
*/
#if GLIB_CHECK_VERSION(2,32,0)
static GMutex message_lock;
#else
static GStaticMutex message_lock = G_STATIC_MUTEX_INIT;
#endif
static volatile int message_event_id = 0;
static volatile int print_event_id = 0;
@ -341,14 +412,14 @@ print_callback (GList *events, G_GNUC_UNUSED gpointer data)
static void
init_message_queue (void)
{
g_static_mutex_lock (&message_lock);
moo_static_mutex_lock (&message_lock);
if (!message_event_id)
message_event_id = _moo_event_queue_connect (message_callback, NULL, NULL);
if (!print_event_id)
print_event_id = _moo_event_queue_connect (print_callback, NULL, NULL);
g_static_mutex_unlock (&message_lock);
moo_static_mutex_unlock (&message_lock);
}
void
@ -404,6 +475,7 @@ typedef struct {
GObjectClass base_class;
} MooAsyncJobClass;
MOO_DEFINE_TYPE_STATIC (MooAsyncJob, moo_async_job, G_TYPE_OBJECT)
static void
@ -423,7 +495,7 @@ moo_async_job_dispose (GObject *object)
if (job->mutex)
{
g_mutex_free (job->mutex);
moo_mutex_free (job->mutex);
job->mutex = NULL;
}
@ -444,7 +516,7 @@ moo_async_job_init (MooAsyncJob *job)
job->data_notify = NULL;
job->thread = NULL;
job->mutex = g_mutex_new ();
job->mutex = moo_mutex_new ();
job->cancelled = FALSE;
}
@ -519,9 +591,8 @@ moo_async_job_start (MooAsyncJob *job)
g_mutex_lock (job->mutex);
job->thread = g_thread_create ((GThreadFunc) moo_async_job_thread_func,
g_object_ref (job),
FALSE, &error);
job->thread = moo_thread_create ((GThreadFunc) moo_async_job_thread_func,
g_object_ref (job));
if (!job->thread)
{
g_critical ("could not start thread: %s", moo_error_message (error));