Commit 3bbebaf6 authored by Jehan's avatar Jehan

Issue #1999: Opening the Preferences dialogue triggers Xcode warning.

It seems that calling `lldb` when it is absent triggers some popup
proposing to install Xcode on macOS. This is obviously not good. Let's
check presence with g_find_program_in_path() instead. I was refraining
from doing so until now, because this function allocates memory, hence
may not do well during a crash.
Fortunately we don't need to check for lldb during crash (unlike gdb
which has some unacceptable behavior for older versions, at least on
FreeBSD) so that should be ok.

(cherry picked from commit 04bbe941)
parent c05bd7b6
......@@ -87,8 +87,6 @@ static gboolean gimp_utils_generic_available (const gchar *program,
gint minor);
static gboolean gimp_utils_gdb_available (gint major,
gint minor);
static gboolean gimp_utils_lldb_available (gint major,
gint minor);
/**
* gimp_utf8_strtrim:
......@@ -1114,14 +1112,37 @@ gimp_flags_value_get_abbrev (GFlagsClass *flags_class,
*
* On Win32, we return TRUE if Dr. Mingw is built-in, FALSE otherwise.
*
* Note: this function is not crash-safe, i.e. you should not try to use
* it in a callback when the program is already crashing. In such a
* case, call gimp_stack_trace_print() or gimp_stack_trace_query()
* directly.
*
* Since: 2.10
**/
gboolean
gimp_stack_trace_available (gboolean optimal)
{
#ifndef G_OS_WIN32
if (gimp_utils_gdb_available (7, 0) ||
gimp_utils_lldb_available (0, 0))
gchar *lld_path = NULL;
gboolean has_lldb = FALSE;
/* Similarly to gdb, we could check for lldb by calling:
* gimp_utils_generic_available ("lldb", major, minor).
* We don't do so on purpose because on macOS, when lldb is absent, it
* triggers a popup asking to install Xcode. So instead, we just
* search for the executable in path.
* This is the reason why this function is not crash-safe, since
* g_find_program_in_path() allocates memory.
* See issue #1999.
*/
lld_path = g_find_program_in_path ("lldb");
if (lld_path)
{
has_lldb = TRUE;
g_free (lld_path);
}
if (gimp_utils_gdb_available (7, 0) || has_lldb)
return TRUE;
#ifdef HAVE_EXECINFO_H
if (! optimal)
......@@ -1577,10 +1598,3 @@ gimp_utils_gdb_available (gint major,
{
return gimp_utils_generic_available ("gdb", major, minor);
}
static gboolean
gimp_utils_lldb_available (gint major,
gint minor)
{
return gimp_utils_generic_available ("lldb", major, minor);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment