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. Also the
27 pseudo-random integers generated by
28 <function>g_rand*_int_range()</function> will have a
29 slightly better equal distribution with the new version of GLib.
33 Further information can be found at the website of the Mersenne
34 Twister random number generator at <ulink
35 url="http://www.math.keio.ac.jp/~matumoto/emt.html">http://www.math.keio.ac.jp/~matumoto/emt.html</ulink>.
39 The original seeding and generation algorithms, as found in GLib
40 2.0.x, can be used instead of the new ones by setting the environment
41 variable <envar>G_RANDOM_VERSION</envar> to the value of '2.0'. Use
42 the GLib-2.0 algorithms only if you have sequences of numbers generated
43 with Glib-2.0 that you need to reproduce exactly.
53 <title>Incompatible changes from 1.2 to 2.0</title>
56 The <ulink url="http://developer.gnome.org/dotplan/porting/">GNOME 2.0
57 porting guide</ulink> on <ulink
58 url="http://developer.gnome.org">http://developer.gnome.org</ulink>
59 has some more detailed discussion of porting from 1.2 to 2.0.
60 See the section on GLib.
67 The event loop functionality <structname>GMain</structname> has extensively
68 been revised to support multiple separate main loops in separate threads.
69 All sources (timeouts, idle functions, etc.) are associated with a
70 <structname>GMainContext</structname>.
74 Compatibility functions exist so that most application code dealing with
75 the main loop will continue to work. However, code that creates new custom
76 types of sources will require modification.
80 The main changes here are:
86 Sources are now exposed as <type>GSource *</type>, rather than simply as
93 New types of sources are created by structure "derivation" from
94 <structname>GSource</structname>, so the <literal>source_data</literal>
95 parameter to the <structname>GSource</structname> virtual functions has been
96 replaced with a <type>GSource *</type>.
102 Sources are first created, then later added to a specific
103 <structname>GMainContext</structname>.
109 Dispatching has been modified so both the callback and data are passed
110 in to the <function>dispatch()</function> virtual function.
115 To go along with this change, the vtable for
116 <structname>GIOChannel</structname> has changed and
117 <function>add_watch()</function> has been replaced by
118 <function>create_watch()</function>.
124 <function>g_list_foreach()</function> and
125 <function>g_slist_foreach()</function> have been changed so they
126 are now safe against removal of the current item, not the next item.
130 It's not recommended to mutate the list in the callback to these
131 functions in any case.
137 <structname>GDate</structname> now works in UTF-8, not in the current locale.
138 If you want to use it with the encoding of the locale, you need to convert
139 strings using <function>g_locale_to_utf8()</function> first.
145 <function>g_strsplit()</function> has been fixed to:
150 include trailing empty tokens, rather than stripping them
155 split into a maximum of <literal>max_tokens</literal> tokens, rather
156 than <literal>max_tokens + 1</literal>
161 Code depending on either of these bugs will need to be fixed.
167 Deprecated functions that got removed:
168 <function>g_set_error_handler()</function>,
169 <function>g_set_warning_handler()</function>,
170 <function>g_set_message_handler()</function>, use
171 <function>g_log_set_handler()</function> instead.