From d3e85ecc1a37e095de7783750cc3e3755434508b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 26 Aug 2010 12:13:45 +0000 Subject: [PATCH] * LaunchApp() now removes an existing app hint if load_image() returned an error. It could even try again in the case of launch-by-signature to make it more robust. * _ResolveApp() now only updates the MIME type's app hint if there is no hint already. This means that only the first app launch will update the hint, not the ones after that; ie. if you had two installations of an app, launching it by signature will now always launch the first app, not the one started last. * This is done since the app hint is written before its known whether or not the app could be started at all. Now, if an app could not be started, the hint is removed, which means it can be reset on next try. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38368 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Roster.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/kits/app/Roster.cpp b/src/kits/app/Roster.cpp index 9e354cba24..650f82d758 100644 --- a/src/kits/app/Roster.cpp +++ b/src/kits/app/Roster.cpp @@ -2323,8 +2323,20 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref, if (error != B_OK) { if (appThread >= 0) kill_thread(appThread); - if (!isScript) + if (!isScript) { _RemovePreRegApp(appToken); + + if (!wasDocument) { + // Remove app hint if it's this one + BMimeType appType(signature); + entry_ref hintRef; + + if (appType.InitCheck() == B_OK + && appType.GetAppHint(&hintRef) == B_OK + && appRef == hintRef) + appType.SetAppHint(NULL); + } + } } } @@ -2451,9 +2463,12 @@ BRoster::_ResolveApp(const char* inType, entry_ref* ref, char signature[B_MIME_TYPE_LENGTH]; if (appFileInfo.SetTo(&appFile) == B_OK && appFileInfo.GetSignature(signature) == B_OK) { - if (!strcasecmp(appMeta.Type(), signature)) - appMeta.SetAppHint(&appRef); - else { + if (!strcasecmp(appMeta.Type(), signature)) { + // Only set the app hint if there is none yet + entry_ref dummyRef; + if (appMeta.GetAppHint(&dummyRef) != B_OK) + appMeta.SetAppHint(&appRef); + } else { appMeta.SetAppHint(NULL); appMeta.SetTo(signature); }