sdl2: add patch to fetch application signature from resources

This avoids warnings like:
Signature in rsrc doesn't match constructor arg.
(application/x-SDL-executable, application/x-vnd.oricutron)

It also avoid roster messing around with applications it things are the same.
This commit is contained in:
François Revol
2016-07-11 17:39:29 +02:00
parent 46a1381866
commit 6a45dc0ff9
2 changed files with 53 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ software, emulators, and popular games."
HOMEPAGE="http://www.libsdl.org/"
COPYRIGHT="1997-2014 Sam Lantinga"
LICENSE="Zlib"
REVISION="1"
REVISION="2"
SOURCE_URI="http://www.libsdl.org/release/SDL2-$portVersion.tar.gz"
CHECKSUM_SHA256="da55e540bf6331824153805d58b590a29c39d2d506c6d02fa409aedeab21174b"
SOURCE_DIR="SDL2-$portVersion"

View File

@@ -212,3 +212,55 @@ index 47186d6..5fcfeec 100644
--
2.2.2
From c69f84542f84c2a40dd811c6524fa862fefff276 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Mon, 11 Jul 2016 15:39:01 +0200
Subject: Try to find correct application signature from app resources
Instead of always hardcoding application/x-SDL-executable.
diff --git a/src/main/haiku/SDL_BeApp.cc b/src/main/haiku/SDL_BeApp.cc
index 36c2a1a..4676c58 100644
--- a/src/main/haiku/SDL_BeApp.cc
+++ b/src/main/haiku/SDL_BeApp.cc
@@ -25,8 +25,10 @@
/* Handle the BeApp specific portions of the application */
#include <AppKit.h>
+#include <storage/AppFileInfo.h>
#include <storage/Path.h>
#include <storage/Entry.h>
+#include <storage/File.h>
#include <unistd.h>
#include "SDL_BApp.h" /* SDL_BApp class definition */
@@ -49,7 +51,24 @@ StartBeApp(void *unused)
{
BApplication *App;
- App = new SDL_BApp("application/x-SDL-executable");
+ // default application signature
+ const char *signature = "application/x-SDL-executable";
+ // dig resources for correct signature
+ image_info info;
+ int32 cookie = 0;
+ if (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
+ BFile f(info.name, O_RDONLY);
+ if (f.InitCheck() == B_OK) {
+ BAppFileInfo app_info(&f);
+ if (app_info.InitCheck() == B_OK) {
+ char sig[B_MIME_TYPE_LENGTH];
+ if (app_info.GetSignature(sig) == B_OK)
+ signature = strndup(sig, B_MIME_TYPE_LENGTH);
+ }
+ }
+ }
+
+ App = new BApplication(signature);
App->Run();
delete App;
--
2.8.0