From dd537d13a84fad412fb5fa68d5744199232423d4 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Sun, 21 Aug 2011 13:00:21 +0000 Subject: [PATCH] Followed Ingo's suggestion: use private get_app_ref(). This reduce code duplication. Thanks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42659 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../gui/teams_window/TeamsListView.cpp | 38 +++++-------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/teams_window/TeamsListView.cpp b/src/apps/debugger/user_interface/gui/teams_window/TeamsListView.cpp index 5839d22e8c..9c23dfdc8a 100644 --- a/src/apps/debugger/user_interface/gui/teams_window/TeamsListView.cpp +++ b/src/apps/debugger/user_interface/gui/teams_window/TeamsListView.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -203,51 +204,32 @@ TeamRow::TeamRow(team_id team) status_t TeamRow::_SetTo(team_info& info) { - BPath systemPath; team_info teamInfo = fTeamInfo = info; - find_directory(B_BEOS_SYSTEM_DIRECTORY, &systemPath); - // strip any trailing space(s)... for (int len = strlen(teamInfo.args) - 1; len >= 0 && teamInfo.args[len] == ' '; len--) { teamInfo.args[len] = 0; } - + app_info appInfo; status_t status = be_roster->GetRunningAppInfo(teamInfo.team, &appInfo); - - if (status == B_OK || teamInfo.team == B_SYSTEM_TEAM) { + if (status != B_OK) { + // Not an application known to be_roster + if (teamInfo.team == B_SYSTEM_TEAM) { - // Get icon and name from kernel + // Get icon and name from kernel image system_info systemInfo; get_system_info(&systemInfo); - BPath kernelPath(systemPath); + BPath kernelPath; + find_directory(B_BEOS_SYSTEM_DIRECTORY, &kernelPath); kernelPath.Append(systemInfo.kernel_name); get_ref_for_path(kernelPath.Path(), &appInfo.ref); - } - } else { - // Not an application known to be_roster - - // The teamInfo.args string is not safe and could be truncated. - // This could leads to show an intermediate folder icon! - // - // Let's retrieve instead the entry_ref from the first team's image of - // type B_APP_IMAGE - int32 cookie = 0; - image_info imageInfo; - while (get_next_image_info(teamInfo.team, &cookie, &imageInfo) == B_OK) { - if (imageInfo.type == B_APP_IMAGE) { - BPath imagePath(imageInfo.name); - appInfo.ref.device = imageInfo.device; - appInfo.ref.directory = imageInfo.node; - appInfo.ref.set_name(imagePath.Leaf()); - break; - } - } + } else + BPrivate::get_app_ref(teamInfo.team, &appInfo.ref); } BBitmap* icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGBA32);