Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
Improved gtk_init error handling
Browse files Browse the repository at this point in the history
Replaced gtk_init_check with gtk_init_with_args so that we can return
the actual GTK error if it fails instead of a generic error.
  • Loading branch information
Patrick D. Andersen committed Jun 23, 2014
1 parent 2f32450 commit 4d8069b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ext/gtk+/php_gtk+.c
Expand Up @@ -44,6 +44,7 @@ static void init_gtk(TSRMLS_D)
char **argv = NULL;
int argc, i;
zend_bool no_argc = 0;
GError *error = NULL;

/*
* Grab the argc/argv values from $_SERVER array.
Expand Down Expand Up @@ -90,13 +91,16 @@ static void init_gtk(TSRMLS_D)
unloaded. */
//DL_LOAD("libgtk.so");

if (!gtk_init_check(&argc, &argv)) {
// New error handler that passes the actual gtk_init error

if (!gtk_init_with_args(&argc, &argv, NULL, NULL, NULL, &error)) {
if (argv != NULL) {
for (i = 0; i < argc; i++)
g_free(argv[i]);
g_free(argv);
}
php_error(E_ERROR, "php-gtk: Could not open display");
php_error(E_ERROR, "%s", error->message);
g_error_free (error);
return;
}

Expand Down

0 comments on commit 4d8069b

Please sign in to comment.