2 * test-floating.c - Source for TestFloatingWithSinkFunc and TestFloatingWithoutSinkFunc
3 * Copyright (C) 2010 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "test-floating.h"
22 /* TestFloatingWithSinkFunc */
24 G_DEFINE_TYPE(TestFloatingWithSinkFunc, test_floating_with_sink_func, G_TYPE_INITIALLY_UNOWNED)
27 test_floating_with_sink_func_finalize (GObject *gobject)
29 TestFloatingWithSinkFunc *object = TEST_FLOATING_WITH_SINK_FUNC (gobject);
31 if (g_object_is_floating (object))
33 g_warning ("A floating object was finalized. This means that someone\n"
34 "called g_object_unref() on an object that had only a floating\n"
35 "reference; the initial floating reference is not owned by anyone\n"
36 "and must be removed with g_object_ref_sink().");
39 G_OBJECT_CLASS (test_floating_with_sink_func_parent_class)->finalize (gobject);
43 test_floating_with_sink_func_class_init (TestFloatingWithSinkFuncClass *klass)
45 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
47 gobject_class->finalize = test_floating_with_sink_func_finalize;
51 test_floating_with_sink_func_init (TestFloatingWithSinkFunc *self)
56 sink_test_floating_with_sink_func (GObject *object)
58 if (g_object_is_floating(object)) {
59 g_object_ref_sink(object);
63 /* TestFloatingWithoutSinkFunc */
65 G_DEFINE_TYPE(TestFloatingWithoutSinkFunc, test_floating_without_sink_func, G_TYPE_INITIALLY_UNOWNED)
68 test_floating_without_sink_func_finalize (GObject *gobject)
70 TestFloatingWithoutSinkFunc *object = TEST_FLOATING_WITHOUT_SINK_FUNC (gobject);
72 if (g_object_is_floating (object))
74 g_warning ("A floating object was finalized. This means that someone\n"
75 "called g_object_unref() on an object that had only a floating\n"
76 "reference; the initial floating reference is not owned by anyone\n"
77 "and must be removed without g_object_ref_sink().");
80 G_OBJECT_CLASS (test_floating_without_sink_func_parent_class)->finalize (gobject);
84 test_floating_without_sink_func_class_init (TestFloatingWithoutSinkFuncClass *klass)
86 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
88 gobject_class->finalize = test_floating_without_sink_func_finalize;
92 test_floating_without_sink_func_init (TestFloatingWithoutSinkFunc *self)