1 <refentry id="glib-changes" revision="17 Jan 2002">
3 <refentrytitle>Changes to GLib</refentrytitle>
4 <manvolnum>3</manvolnum>
5 <refmiscinfo>Changes to GLib</refmiscinfo>
9 <refname>Changes to GLib</refname>
11 Incompatible changes made between successing versions of GLib
17 <title>Incompatible changes from 2.0 to 2.2</title>
23 GLib changed the seeding algorithm for the pseudo-random number
24 generator Mersenne Twister, as used by <structname>GRand</structname>
25 and <structname>GRandom</structname>. This was necessary, because some
26 seeds would yield very bad pseudo-random streams.
30 Further information can be found at the website of the Mersenne
31 Twister random number generator at <ulink
32 url="http://www.math.keio.ac.jp/~matumoto/emt.html">http://www.math.keio.ac.jp/~matumoto/emt.html</ulink>.
36 The original seeding algorithm, as found in GLib 2.0.x, can be used
37 instead of the new one by setting the environment variable
38 <envar>G_RANDOM_VERSION</envar> to the value of '2.0'. Use the
39 GLib-2.0 algorithm only if you have sequences of numbers generated
40 with Glib-2.0 that you need to reproduce exactly.
49 <title>Incompatible changes from 1.2 to 2.0</title>
52 The <ulink url="http://developer.gnome.org/dotplan/porting/">GNOME 2.0
53 porting guide</ulink> on <ulink
54 url="http://developer.gnome.org">http://developer.gnome.org</ulink>
55 has some more detailed discussion of porting from 1.2 to 2.0.
56 See the section on GLib.
63 The event loop functionality <structname>GMain</structname> has extensively
64 been revised to support multiple separate main loops in separate threads.
65 All sources (timeouts, idle functions, etc.) are associated with a
66 <structname>GMainContext</structname>.
70 Compatibility functions exist so that most application code dealing with
71 the main loop will continue to work. However, code that creates new custom
72 types of sources will require modification.
76 The main changes here are:
82 Sources are now exposed as <type>GSource *</type>, rather than simply as
89 New types of sources are created by structure "derivation" from
90 <structname>GSource</structname>, so the <literal>source_data</literal>
91 parameter to the <structname>GSource</structname> virtual functions has been
92 replaced with a <type>GSource *</type>.
98 Sources are first created, then later added to a specific
99 <structname>GMainContext</structname>.
105 Dispatching has been modified so both the callback and data are passed
106 in to the <function>dispatch()</function> virtual function.
111 To go along with this change, the vtable for
112 <structname>GIOChannel</structname> has changed and
113 <function>add_watch()</function> has been replaced by
114 <function>create_watch()</function>.
120 <function>g_list_foreach()</function> and
121 <function>g_slist_foreach()</function> have been changed so they
122 are now safe against removal of the current item, not the next item.
126 It's not recommended to mutate the list in the callback to these
127 functions in any case.
133 <structname>GDate</structname> now works in UTF-8, not in the current locale.
134 If you want to use it with the encoding of the locale, you need to convert
135 strings using <function>g_locale_to_utf8()</function> first.
141 <function>g_strsplit()</function> has been fixed to:
146 include trailing empty tokens, rather than stripping them
151 split into a maximum of <literal>max_tokens</literal> tokens, rather
152 than <literal>max_tokens + 1</literal>
157 Code depending on either of these bugs will need to be fixed.
163 Deprecated functions that got removed:
164 <function>g_set_error_handler()</function>,
165 <function>g_set_warning_handler()</function>,
166 <function>g_set_message_handler()</function>, use
167 <function>g_log_set_handler()</function> instead.