1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Linux fixes

This commit is contained in:
disarray2077 2025-05-11 23:27:42 -03:00
parent ad3d90e521
commit 6a35544195
5 changed files with 39 additions and 0 deletions

View file

@ -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)

View file

@ -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 = ?;

View file

@ -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")]

View file

@ -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)