Răsfoiți Sursa

Merge pull request #2238 from disarray2077/patch-9

Linux fixes
Brian Fiete 2 luni în urmă
părinte
comite
4353d2a10d

+ 1 - 0
BeefLibs/Beefy2D/src/gfx/Image.bf

@@ -103,6 +103,7 @@ namespace Beefy.gfx
 			scope AutoBeefPerf("Image.LoadFromFile");
 
 			var useFileName = scope String()..Append(fileName);
+            useFileName.Replace('\\', '/');
 			FilePackManager.TryMakeMemoryString(useFileName);
             void* aNativeTextureSegment = Gfx_LoadTexture(useFileName, (int32)flags);
             if (aNativeTextureSegment == null)

+ 3 - 0
BeefLibs/corlib/src/IO/FileDialog.bf

@@ -623,6 +623,9 @@ abstract class CommonDialog
 
 	public Result<DialogResult> ShowDialog(INativeWindow owner = null)
 	{
+		if (!Linux.IsSystemdAvailable)
+			return .Err;
+
 		TryC!(Linux.SdBusOpenUser(&mBus)); // Maybe keep the bus open while the program is running ?
 		
 		Linux.DBusMsg* call = ?;

+ 27 - 0
BeefLibs/corlib/src/Linux.bf

@@ -44,6 +44,33 @@ class Linux
 
 	public typealias DBusMsgHandler = function int32(DBusMsg *m, void *userdata, DBusErr *ret_error);
 
+	public static bool IsSystemdAvailable { get; private set; } = true;
+
+	[AlwaysInclude, StaticInitPriority(100)]
+	static class AllowFail
+	{
+		public static this()
+		{
+			Runtime.AddErrorHandler(new => Handle);
+		}
+
+		public static Runtime.ErrorHandlerResult Handle(Runtime.ErrorStage errorStage, Runtime.Error error)
+		{
+			if (errorStage == .PreFail)
+			{
+				if (var loadLibaryError = error as Runtime.LoadSharedLibraryError)
+				{
+					if (loadLibaryError.mPath == "libsystemd.so")
+					{
+						IsSystemdAvailable = false;
+						return .Ignore;
+					}
+				}
+			}
+			return .ContinueFailure;
+		}
+	}
+
 	[Import("libsystemd.so"), LinkName("sd_bus_open_user")]
 	public static extern c_int SdBusOpenUser(DBus **ret);
 	[Import("libsystemd.so"), LinkName("sd_bus_open_system")]

+ 6 - 0
BeefLibs/corlib/src/String.bf

@@ -972,6 +972,9 @@ namespace System
 
 		public void Append(char8* appendPtr, int length)
 		{
+			Debug.Assert(length >= 0);
+			if (length <= 0)
+				return;
 			int newCurrentIndex = mLength + length;
 			char8* ptr;
 			if (newCurrentIndex > AllocSize)
@@ -996,6 +999,9 @@ namespace System
 
 		public void Append(char8[] arr, int idx, int length)
 		{
+			Debug.Assert(length >= 0);
+			if (length <= 0)
+				return;
 			int newCurrentIndex = mLength + length;
 			char8* ptr;
 			if (newCurrentIndex > AllocSize)

+ 2 - 0
IDE/src/IDEApp.bf

@@ -3438,6 +3438,8 @@ namespace IDE
 				delete mWorkspace.mDir;
 				mWorkspace.mDir = newPath;
 			}
+			else if (mWorkspace.mDir == null)
+				mWorkspace.mDir = new String();
 
 			List<String> platforms = scope List<String>();
 			if (IDEApp.sPlatform32Name != null)