Add an example for g_on_error_query() usage. (#148716, Christian Persch)

2004-08-23  Matthias Clasen  <mclasen@redhat.com>

	* glib/tmpl/warnings.sgml: Add an example for
	g_on_error_query() usage.  (#148716, Christian Persch)
This commit is contained in:
Matthias Clasen 2004-08-23 17:56:35 +00:00 committed by Matthias Clasen
parent 81f3c9dcc4
commit 66a18b3f64
2 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2004-08-23 Matthias Clasen <mclasen@redhat.com>
* glib/tmpl/warnings.sgml: Add an example for
g_on_error_query() usage. (#148716, Christian Persch)
2004-08-12 Matthias Clasen <mclasen@redhat.com>
* glib/tmpl/threads.sgml: Document the necessity to call

View File

@ -151,9 +151,34 @@ The macro can be turned off in final releases of code by defining
<!-- ##### FUNCTION g_on_error_query ##### -->
<para>
Prompts the user with <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
This function is intended to be used for debugging use only.
FIXME: How do you set it up?
This function is intended to be used for debugging use only. The following
example shows how it can be used together with the g_log() functions.
</para>
<informalexample><programlisting>
&num;include &lt;glib.h&gt;
static void
log_handler (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer user_data)
{
g_log_default_handler (log_domain, log_level, message, user_data);
g_on_error_query (MY_PROGRAM_NAME);
}
int main (int argc, char *argv[])
{
g_log_set_handler (MY_LOG_DOMAIN,
G_LOG_LEVEL_WARNING |
G_LOG_LEVEL_ERROR |
G_LOG_LEVEL_CRITICAL,
log_handler,
NULL);
/* ... */
</programlisting></informalexample>
<para>
If [E]xit is selected, the application terminates with a call to
<function>_exit(0)</function>.