glib-changes.html   [plain text]


<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Changes to GLib</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib.html" title="GLib Overview"><link rel="previous" href="glib-running.html" title="Running GLib Applications"><link rel="next" href="glib-resources.html" title="Mailing lists and bug reports"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="refentry" href="glib-building.html" title="Compiling the GLib package"><link rel="refentry" href="glib-cross-compiling.html" title="Cross-compiling the GLib package"><link rel="refentry" href="glib-compiling.html" title="Compiling GLib Applications"><link rel="refentry" href="glib-running.html" title="Running GLib Applications"><link rel="refentry" href="glib-changes.html" title="Changes to GLib"><link rel="refentry" href="glib-resources.html" title="Mailing lists and bug reports"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="refentry" href="glib-Basic-Types.html" title="Basic Types"><link rel="refentry" href="glib-Limits-of-Basic-Types.html" title="Limits of Basic Types"><link rel="refentry" href="glib-Standard-Macros.html" title="Standard Macros"><link rel="refentry" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros"><link rel="refentry" href="glib-Byte-Order-Macros.html" title="Byte Order Macros"><link rel="refentry" href="glib-Numerical-Definitions.html" title="Numerical Definitions"><link rel="refentry" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros"><link rel="refentry" href="glib-Atomic-Operations.html" title="Atomic Operations"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="refentry" href="glib-The-Main-Event-Loop.html" title="The Main Event Loop"><link rel="refentry" href="glib-Threads.html" title="
Threads"><link rel="refentry" href="glib-Thread-Pools.html" title="Thread Pools"><link rel="refentry" href="glib-Asynchronous-Queues.html" title="Asynchronous Queues"><link rel="refentry" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules"><link rel="refentry" href="glib-Memory-Allocation.html" title="Memory Allocation"><link rel="refentry" href="glib-IO-Channels.html" title="IO Channels"><link rel="refentry" href="glib-Error-Reporting.html" title="Error Reporting"><link rel="refentry" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions"><link rel="refentry" href="glib-Message-Logging.html" title="Message Logging"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="refentry" href="glib-String-Utility-Functions.html" title="String Utility Functions"><link rel="refentry" href="glib-Character-Set-Conversion.html" title="Character Set Conversion"><link rel="refentry" href="glib-Unicode-Manipulation.html" title="Unicode Manipulation"><link rel="refentry" href="glib-I18N.html" title="Internationalization"><link rel="refentry" href="glib-Date-and-Time-Functions.html" title="Date and Time Functions"><link rel="refentry" href="glib-Random-Numbers.html" title="Random Numbers"><link rel="refentry" href="glib-Hook-Functions.html" title="Hook Functions"><link rel="refentry" href="glib-Miscellaneous-Utility-Functions.html" title="Miscellaneous Utility Functions"><link rel="refentry" href="glib-Lexical-Scanner.html" title="Lexical Scanner"><link rel="refentry" href="glib-Automatic-String-Completion.html" title="Automatic String Completion"><link rel="refentry" href="glib-Timers.html" title="Timers"><link rel="refentry" href="glib-Spawning-Processes.html" title="Spawning Processes"><link rel="refentry" href="glib-File-Utilities.html" title="File Utilities"><link rel="refentry" href="glib-Shell-related-Utilities.html" title="Shell-related Utilities"><link rel="refentry" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching"><link rel="refentry" href="glib-Simple-XML-Subset-Parser.html" title="Simple XML Subset Parser"><link rel="refentry" href="glib-Windows-Compatability-Functions.html" title="Windows Compatibility Functions"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="refentry" href="glib-Memory-Chunks.html" title="Memory Chunks"><link rel="refentry" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists"><link rel="refentry" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists"><link rel="refentry" href="glib-Double-ended-Queues.html" title="Double-ended Queues"><link rel="refentry" href="glib-Trash-Stacks.html" title="Trash Stacks"><link rel="refentry" href="glib-Hash-Tables.html" title="Hash Tables"><link rel="refentry" href="glib-Strings.html" title="Strings"><link rel="refentry" href="glib-String-Chunks.html" title="String Chunks"><link rel="refentry" href="glib-Arrays.html" title="Arrays"><link rel="refentry" href="glib-Pointer-Arrays.html" title="Pointer Arrays"><link rel="refentry" href="glib-Byte-Arrays.html" title="Byte Arrays"><link rel="refentry" href="glib-Balanced-Binary-Trees.html" title="Balanced Binary Trees"><link rel="refentry" href="glib-N-ary-Trees.html" title="N-ary Trees"><link rel="refentry" href="glib-Quarks.html" title="Quarks"><link rel="refentry" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists"><link rel="refentry" href="glib-Datasets.html" title="Datasets"><link rel="refentry" href="glib-Relations-and-Tuples.html" title="Relations and Tuples"><link rel="refentry" href="glib-Caches.html" title="Caches"><link rel="refentry" href="glib-Memory-Allocators.html" title="Memory Allocators"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="refentry" href="glib-gettextize.html" title="glib-gettextize"><link rel="index" href="ix01.html" title="Index"><link rel="section" href="glib-changes.html#id2971085" title="Incompatible changes from 2.0 to 2.2"><link rel="section" href="glib-changes.html#id2971302" title="Incompatible changes from 1.2 to 2.0"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-running.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-resources.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-changes"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Changes to GLib</span></h2><p>Changes to GLib &#8212; 
Incompatible changes made between successing versions of GLib
</p></div><div class="refsect1" lang="en"><a name="id2971085"></a><h2>Incompatible changes from 2.0 to 2.2</h2><div class="itemizedlist"><ul type="disc"><li><p>
GLib changed the seeding algorithm for the pseudo-random number
generator Mersenne Twister, as used by <span class="structname">GRand</span>
and <span class="structname">GRandom</span>. This was necessary, because some
seeds would yield very bad pseudo-random streams. Also the
pseudo-random integers generated by
<tt class="function">g_rand*_int_range()</tt> will have a
slightly better equal distribution with the new version of GLib.
</p><p>
Further information can be found at the website of the Mersenne
Twister random number generator at <a href="http://www.math.keio.ac.jp/~matumoto/emt.html" target="_top">http://www.math.keio.ac.jp/~matumoto/emt.html</a>.
</p><p>
The original seeding and generation algorithms, as found in GLib
2.0.x, can be used instead of the new ones by setting the environment
variable <tt class="envar">G_RANDOM_VERSION</tt> to the value of '2.0'. Use
the GLib-2.0 algorithms only if you have sequences of numbers generated
with Glib-2.0 that you need to reproduce exactly.  
</p></li></ul></div></div><div class="refsect1" lang="en"><a name="id2971302"></a><h2>Incompatible changes from 1.2 to 2.0</h2><p>
The <a href="http://developer.gnome.org/dotplan/porting/" target="_top">GNOME 2.0
porting guide</a> on <a href="http://developer.gnome.org" target="_top">http://developer.gnome.org</a>
has some more detailed discussion of porting from 1.2 to 2.0.
See the section on GLib.
</p><div class="itemizedlist"><ul type="disc"><li><p>
The event loop functionality <span class="structname">GMain</span> has extensively 
been revised to support multiple separate main loops in separate threads. 
All sources (timeouts, idle functions, etc.) are associated with a 
<span class="structname">GMainContext</span>.
</p><p>
Compatibility functions exist so that most application code dealing with
the main loop will continue to work. However, code that creates new custom 
types of sources will require modification.
</p><p>
The main changes here are:

  </p><div class="itemizedlist"><ul type="circle"><li><p>
   Sources are now exposed as <span class="type">GSource *</span>, rather than simply as 
   numeric ids.
  </p></li><li><p>
   New types of sources are created by structure "derivation" from 
   <span class="structname">GSource</span>, so the <tt class="literal">source_data</tt> 
   parameter to the <span class="structname">GSource</span> virtual functions has been
   replaced with a <span class="type">GSource *</span>.
  </p></li><li><p>
   Sources are first created, then later added to a specific 
   <span class="structname">GMainContext</span>. 
  </p></li><li><p>
   Dispatching has been modified so both the callback and data are passed
   in to the <tt class="function">dispatch()</tt> virtual function.
  </p></li></ul></div><p>
  To go along with this change, the vtable for 
  <span class="structname">GIOChannel</span> has changed and
  <tt class="function">add_watch()</tt> has been replaced by 
  <tt class="function">create_watch()</tt>.
</p></li><li><p>
<tt class="function">g_list_foreach()</tt> and 
<tt class="function">g_slist_foreach()</tt> have been changed so they
are now safe against removal of the current item, not the next item.
</p><p>
It's not recommended to mutate the list in the callback to these
functions in any case.
</p></li><li><p>
<span class="structname">GDate</span> now works in UTF-8, not in the current locale. 
If you want to use it with the encoding of the locale, you need to convert 
strings using <tt class="function">g_locale_to_utf8()</tt> first.
</p></li><li><p>
<tt class="function">g_strsplit()</tt> has been fixed to:

  </p><div class="itemizedlist"><ul type="circle"><li><p>
   include trailing empty tokens, rather than stripping them
  </p></li><li><p>
   split into a maximum of <tt class="literal">max_tokens</tt> tokens, rather 
   than <tt class="literal">max_tokens + 1</tt>
  </p></li></ul></div><p>

  Code depending on either of these bugs will need to be fixed.
</p></li><li><p>
Deprecated functions that got removed:
<tt class="function">g_set_error_handler()</tt>, 
<tt class="function">g_set_warning_handler()</tt>,
<tt class="function">g_set_message_handler()</tt>, use 
<tt class="function">g_log_set_handler()</tt> instead.
</p></li></ul></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-running.html"><b>&lt;&lt; Running GLib Applications</b></a></td><td align="right"><a accesskey="n" href="glib-resources.html"><b>Mailing lists and bug reports &gt;&gt;</b></a></td></tr></table></body></html>