Fixed a crashing bug that occured when both, "sort running applications", and
"tracker always first" was selected, and the first app that was launched was not Tracker. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15507 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -69,7 +69,7 @@ BLocker TExpandoMenuBar::sMonLocker("expando monitor");
|
|||||||
|
|
||||||
TExpandoMenuBar::TExpandoMenuBar(TBarView *bar, BRect frame, const char *name,
|
TExpandoMenuBar::TExpandoMenuBar(TBarView *bar, BRect frame, const char *name,
|
||||||
bool vertical, bool drawLabel)
|
bool vertical, bool drawLabel)
|
||||||
: BMenuBar(frame, name, B_FOLLOW_NONE,
|
: BMenuBar(frame, name, B_FOLLOW_NONE,
|
||||||
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW, vertical),
|
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW, vertical),
|
||||||
fVertical(vertical),
|
fVertical(vertical),
|
||||||
fOverflow(false),
|
fOverflow(false),
|
||||||
@@ -136,8 +136,8 @@ TExpandoMenuBar::AttachedToWindow()
|
|||||||
BarTeamInfo *barInfo = (BarTeamInfo *)teamList.ItemAt(i);
|
BarTeamInfo *barInfo = (BarTeamInfo *)teamList.ItemAt(i);
|
||||||
if ((barInfo->flags & B_BACKGROUND_APP) == 0
|
if ((barInfo->flags & B_BACKGROUND_APP) == 0
|
||||||
&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
|
&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
|
||||||
if ((settings->trackerAlwaysFirst)
|
if (settings->trackerAlwaysFirst
|
||||||
&& (strcmp(barInfo->sig, kTrackerSignature)) == 0) {
|
&& !strcmp(barInfo->sig, kTrackerSignature)) {
|
||||||
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
|
||||||
barInfo->name, barInfo->sig, width, height,
|
barInfo->name, barInfo->sig, width, height,
|
||||||
fDrawLabel, fVertical), fFirstApp);
|
fDrawLabel, fVertical), fFirstApp);
|
||||||
@@ -206,9 +206,9 @@ TExpandoMenuBar::MessageReceived(BMessage *message)
|
|||||||
BBitmap *icon = NULL;
|
BBitmap *icon = NULL;
|
||||||
message->FindPointer("icon", (void **)&icon);
|
message->FindPointer("icon", (void **)&icon);
|
||||||
|
|
||||||
const char *sig;
|
const char *signature;
|
||||||
if (message->FindString("sig", &sig) == B_OK
|
if (message->FindString("sig", &signature) == B_OK
|
||||||
&&strcasecmp(sig, kDeskbarSignature) == 0) {
|
&&strcasecmp(signature, kDeskbarSignature) == 0) {
|
||||||
delete teams;
|
delete teams;
|
||||||
delete icon;
|
delete icon;
|
||||||
break;
|
break;
|
||||||
@@ -225,7 +225,7 @@ TExpandoMenuBar::MessageReceived(BMessage *message)
|
|||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
message->FindString("name", &name);
|
message->FindString("name", &name);
|
||||||
|
|
||||||
AddTeam(teams, icon, strdup(name), strdup(sig));
|
AddTeam(teams, icon, strdup(name), strdup(signature));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,31 +472,31 @@ TExpandoMenuBar::ItemAtPoint(BPoint point)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TExpandoMenuBar::AddTeam(BList *team, BBitmap *icon, char *name, char *sig)
|
TExpandoMenuBar::AddTeam(BList *team, BBitmap *icon, char *name, char *signature)
|
||||||
{
|
{
|
||||||
float itemWidth = fVertical ? Frame().Width() : kMinimumWindowWidth;
|
float itemWidth = fVertical ? Frame().Width() : kMinimumWindowWidth;
|
||||||
float itemHeight = -1.0f;
|
float itemHeight = -1.0f;
|
||||||
|
|
||||||
desk_settings *settings = ((TBarApp *)be_app)->Settings();
|
desk_settings *settings = ((TBarApp *)be_app)->Settings();
|
||||||
TTeamMenuItem *item = new TTeamMenuItem(team, icon, name, sig, itemWidth,
|
TTeamMenuItem *item = new TTeamMenuItem(team, icon, name, signature, itemWidth,
|
||||||
itemHeight, fDrawLabel, fVertical);
|
itemHeight, fDrawLabel, fVertical);
|
||||||
|
|
||||||
if (settings->trackerAlwaysFirst && !strcmp( sig, kTrackerSignature)) {
|
if (settings->trackerAlwaysFirst && !strcmp(signature, kTrackerSignature)) {
|
||||||
AddItem(item, fFirstApp);
|
AddItem(item, fFirstApp);
|
||||||
} else if (settings->sortRunningApps) {
|
} else if (settings->sortRunningApps) {
|
||||||
|
TTeamMenuItem *teamItem = dynamic_cast<TTeamMenuItem *>(ItemAt(fFirstApp));
|
||||||
int32 firstApp = fFirstApp;
|
int32 firstApp = fFirstApp;
|
||||||
|
|
||||||
// if Tracker should always be the first item, we need to skip it
|
// if Tracker should always be the first item, we need to skip it
|
||||||
// when sorting in the current item
|
// when sorting in the current item
|
||||||
if ((settings->trackerAlwaysFirst)
|
if (settings->trackerAlwaysFirst && teamItem != NULL
|
||||||
&& (strcmp(static_cast<TTeamMenuItem *>(ItemAt(fFirstApp))->Signature(),
|
&& !strcmp(teamItem->Signature(), kTrackerSignature)) {
|
||||||
kTrackerSignature) == 0)) {
|
|
||||||
firstApp++;
|
firstApp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 count = CountItems(), i;
|
int32 count = CountItems(), i;
|
||||||
for (i = firstApp; i < count; i++) {
|
for (i = firstApp; i < count; i++) {
|
||||||
TTeamMenuItem *teamItem = dynamic_cast<TTeamMenuItem *>(ItemAt(i));
|
teamItem = dynamic_cast<TTeamMenuItem *>(ItemAt(i));
|
||||||
if (teamItem != NULL && strcasecmp(teamItem->Name(), name) > 0) {
|
if (teamItem != NULL && strcasecmp(teamItem->Name(), name) > 0) {
|
||||||
AddItem(item, i);
|
AddItem(item, i);
|
||||||
break;
|
break;
|
||||||
@@ -521,13 +521,13 @@ TExpandoMenuBar::AddTeam(BList *team, BBitmap *icon, char *name, char *sig)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TExpandoMenuBar::AddTeam(team_id team, const char *sig)
|
TExpandoMenuBar::AddTeam(team_id team, const char *signature)
|
||||||
{
|
{
|
||||||
int32 count = CountItems();
|
int32 count = CountItems();
|
||||||
for (int32 i = fFirstApp; i < count; i++) {
|
for (int32 i = fFirstApp; i < count; i++) {
|
||||||
// Only add to team menu items
|
// Only add to team menu items
|
||||||
if (TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(ItemAt(i))) {
|
if (TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(ItemAt(i))) {
|
||||||
if (strcasecmp(item->Signature(), sig) == 0) {
|
if (strcasecmp(item->Signature(), signature) == 0) {
|
||||||
if (!(item->Teams()->HasItem((void *)team)))
|
if (!(item->Teams()->HasItem((void *)team)))
|
||||||
item->Teams()->AddItem((void *)team);
|
item->Teams()->AddItem((void *)team);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user