From fd702d31b5d32d0d55d58e41ca3b27385512b27d Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Tue, 30 Mar 2021 10:59:41 +0200 Subject: [PATCH] include haiku.h in setup.c improve haiku_get_app_path() --- src/haiku.cpp | 11 ++++++----- src/setup.c | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/haiku.cpp b/src/haiku.cpp index 708564ce..a13e6235 100644 --- a/src/haiku.cpp +++ b/src/haiku.cpp @@ -63,12 +63,13 @@ char* haiku_get_clipboard() const char* haiku_get_app_path() { static image_info info; - static int32 cookie = 0; + int32 cookie = 0; - if (cookie == 0) do { - get_next_image_info(B_CURRENT_TEAM, &cookie, &info); - } while (info.type != B_APP_IMAGE); + while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { + if (info.type == B_APP_IMAGE) + return info.name; + } - return info.name; + return NULL; } #endif diff --git a/src/setup.c b/src/setup.c index 3ecb0f66..1a5844c0 100644 --- a/src/setup.c +++ b/src/setup.c @@ -43,6 +43,7 @@ #include #elif defined(__HAIKU__) #include + #include "haiku.h" #endif #include "struct.h"