mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-27 11:59:17 +00:00
Improve runtime error for non-thread-safe detection
https://bugzilla.gnome.org/show_bug.cgi?id=721664
This commit is contained in:
parent
270350f2c0
commit
d4d999f990
|
@ -24,6 +24,25 @@ private const string version = Config.VERSION;
|
|||
|
||||
public class Main
|
||||
{
|
||||
private static void init_error(string[] args, string msg)
|
||||
{
|
||||
Gtk.init(ref args);
|
||||
|
||||
var dlg = new Gtk.MessageDialog(null,
|
||||
0,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.CLOSE,
|
||||
"%s",
|
||||
msg);
|
||||
|
||||
dlg.window_position = Gtk.WindowPosition.CENTER;
|
||||
|
||||
dlg.response.connect(() => { Gtk.main_quit(); });
|
||||
dlg.show();
|
||||
|
||||
Gtk.main();
|
||||
}
|
||||
|
||||
public static int main(string[] args)
|
||||
{
|
||||
Intl.setlocale(LocaleCategory.ALL, "");
|
||||
|
@ -34,7 +53,22 @@ public class Main
|
|||
Environment.set_prgname("gitg");
|
||||
Environment.set_application_name(_("gitg"));
|
||||
|
||||
Gitg.init();
|
||||
try
|
||||
{
|
||||
Gitg.init();
|
||||
}
|
||||
catch (Error e)
|
||||
{
|
||||
if (e is Gitg.InitError.THREADS_UNSAFE)
|
||||
{
|
||||
var errmsg = _("We are terribly sorry, but gitg requires libgit2 (a library on which gitg depends) to be compiled with threading support.\n\nIf you manually compiled libgit2, then please configure libgit2 with -DTHREADSAFE:BOOL=ON.\n\nOtherwise, report a bug in your distributions' bug reporting system for providing libgit2 without threading support.");
|
||||
|
||||
init_error(args, errmsg);
|
||||
error("%s", errmsg);
|
||||
}
|
||||
|
||||
Process.exit(1);
|
||||
}
|
||||
|
||||
// Make sure to pull in gd symbols since libgd gets linked statically
|
||||
Gd.ensure_types();
|
||||
|
|
|
@ -20,11 +20,34 @@
|
|||
namespace Gitg
|
||||
{
|
||||
|
||||
public void init()
|
||||
public errordomain InitError
|
||||
{
|
||||
THREADS_UNSAFE
|
||||
}
|
||||
|
||||
private static bool gitg_inited = false;
|
||||
private static InitError? gitg_initerr = null;
|
||||
|
||||
public void init() throws Error
|
||||
{
|
||||
if (gitg_inited)
|
||||
{
|
||||
if (gitg_initerr != null)
|
||||
{
|
||||
throw gitg_initerr;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gitg_inited = true;
|
||||
|
||||
if ((Ggit.get_capabilities() & Ggit.CapFlags.THREADS) == 0)
|
||||
{
|
||||
error("libgit2 must be built with threading support in order to run gitg");
|
||||
gitg_initerr = new InitError.THREADS_UNSAFE("no thread support");
|
||||
|
||||
warning("libgit2 must be built with threading support in order to run gitg");
|
||||
throw gitg_initerr;
|
||||
}
|
||||
|
||||
Ggit.init();
|
||||
|
|
Loading…
Reference in a new issue