Skip to content

Commit

Permalink
Fix a crash when overriding the number of render threads
Browse files Browse the repository at this point in the history
This needs to be done a bit later, after GTK-related libraries have been initialized, since this invokes the static constructors for PintaCore.
  • Loading branch information
cameronwhite committed Dec 17, 2023
1 parent 9afaf22 commit 8240fab
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Pinta/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,13 @@ public static int Main (string[] args)
root_command.AddArgument (files_arg);

root_command.SetHandler ((threads, files) => {
if (threads > 0)
Pinta.Core.PintaCore.System.RenderThreads = threads;

OpenMainWindow (files);

OpenMainWindow (threads, files);
}, threads_option, files_arg);

return root_command.Invoke (args);
}

private static void OpenMainWindow (IEnumerable<string> files)
private static void OpenMainWindow (int threads, IEnumerable<string> files)
{
GLib.UnhandledException.SetHandler (OnUnhandledException);

Expand All @@ -97,6 +93,9 @@ private static void OpenMainWindow (IEnumerable<string> files)
RegisterForAppleEvents ();
}

if (threads > 0)
PintaCore.System.RenderThreads = threads;

app.OnActivate += (_, _) => {
main_window.Activate ();
OpenFilesFromCommandLine (files);
Expand Down

0 comments on commit 8240fab

Please sign in to comment.