📄 glib-changes.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Changes to GLib</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib.html" title="GLib Overview"><link rel="prev" href="glib-running.html" title="Running GLib Applications"><link rel="next" href="glib-regex-syntax.html" title="Regular expression syntax"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"><link rel="index" href="ix09.html" title="Index of new symbols in 2.14"><link rel="index" href="ix10.html" title="Index of new symbols in 2.16"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" 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-regex-syntax.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 class="refnamediv"><table width="100%"><tr><td valign="top"><h2><span class="refentrytitle">Changes to GLib</span></h2><p>Changes to GLib — Incompatible changes made between successing versions of GLib</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsect1" lang="en"><a name="id2811743"></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 numbergenerator Mersenne Twister, as used by <span class="structname">GRand</span>and <span class="structname">GRandom</span>. This was necessary, because someseeds would yield very bad pseudo-random streams. Also thepseudo-random integers generated by<code class="function">g_rand*_int_range()</code> will have aslightly better equal distribution with the new version of GLib.</p><p>Further information can be found at the website of the MersenneTwister random number generator at <a class="ulink" 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 GLib2.0.x, can be used instead of the new ones by setting the environmentvariable <code class="envar">G_RANDOM_VERSION</code> to the value of '2.0'. Usethe GLib-2.0 algorithms only if you have sequences of numbers generatedwith Glib-2.0 that you need to reproduce exactly. </p></li></ul></div></div><div class="refsect1" lang="en"><a name="id2812402"></a><h2>Incompatible changes from 1.2 to 2.0</h2><p>The <a class="ulink" href="http://developer.gnome.org/dotplan/porting/" target="_top">GNOME 2.0porting guide</a> on <a class="ulink" 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 withthe 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 <code class="literal">source_data</code> 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 <code class="function">dispatch()</code> virtual function. </p></li></ul></div><p> To go along with this change, the vtable for <span class="structname">GIOChannel</span> has changed and <code class="function">add_watch()</code> has been replaced by <code class="function">create_watch()</code>.</p></li><li><p><code class="function">g_list_foreach()</code> and <code class="function">g_slist_foreach()</code> have been changed so theyare 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 thesefunctions 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 <code class="function">g_locale_to_utf8()</code> first.</p></li><li><p><code class="function">g_strsplit()</code> 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 <code class="literal">max_tokens</code> tokens, rather than <code class="literal">max_tokens + 1</code> </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:<code class="function">g_set_error_handler()</code>, <code class="function">g_set_warning_handler()</code>,<code class="function">g_set_message_handler()</code>, use <code class="function">g_log_set_handler()</code> instead.</p></li></ul></div></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -