fixed some pretty bad bugs that prevented menus from working (they now do): The BMessage* in AddShortcut is taken in responsibility by the BWindow, so we cannot directly use the message from BMenuItem, the be_app was locked in InitData but never unlocked, it fixes BMenus only working once, and who knows what else it fixes. A little cleanup with _BCmdKey usage, also note that it is inefficient to RemoveItem()s from a list in the destructor of any class using a BList as data container! Simply delete the items and be done with it. The BList destructor will take care of the rest and free its storage in one go.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12982 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -225,12 +225,7 @@ BWindow::~BWindow()
|
||||
|
||||
noOfItems = accelList.CountItems();
|
||||
for (int index = noOfItems-1; index >= 0; index--) {
|
||||
_BCmdKey *cmdKey = (_BCmdKey *)accelList.ItemAt(index);
|
||||
|
||||
accelList.RemoveItem(index);
|
||||
|
||||
delete cmdKey->message;
|
||||
delete cmdKey;
|
||||
delete (_BCmdKey*)accelList.ItemAt(index);
|
||||
}
|
||||
|
||||
// TODO: release other dynamically-allocated objects
|
||||
@@ -1185,7 +1180,8 @@ BWindow::PulseRate() const
|
||||
void
|
||||
BWindow::AddShortcut(uint32 key, uint32 modifiers, BMenuItem *item)
|
||||
{
|
||||
AddShortcut(key, modifiers, item->Message(), this);
|
||||
if (item->Message())
|
||||
AddShortcut(key, modifiers, new BMessage(*item->Message()), this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1212,21 +1208,15 @@ BWindow::AddShortcut(uint32 key, uint32 modifiers, BMessage *msg, BHandler *targ
|
||||
|
||||
modifiers = modifiers | B_COMMAND_KEY;
|
||||
|
||||
_BCmdKey *cmdKey = new _BCmdKey;
|
||||
cmdKey->key = key;
|
||||
cmdKey->modifiers = modifiers;
|
||||
cmdKey->message = msg;
|
||||
_BCmdKey *cmdKey = new _BCmdKey(key, modifiers, msg);
|
||||
|
||||
if (target == NULL)
|
||||
cmdKey->targetToken = B_ANY_TOKEN;
|
||||
else
|
||||
if (target)
|
||||
cmdKey->targetToken = _get_object_token_(target);
|
||||
|
||||
// removes the shortcut from accelList if it exists!
|
||||
RemoveShortcut(key, modifiers);
|
||||
|
||||
accelList.AddItem(cmdKey);
|
||||
|
||||
accelList.AddItem((void*)cmdKey);
|
||||
}
|
||||
|
||||
|
||||
@@ -1239,8 +1229,6 @@ BWindow::RemoveShortcut(uint32 key, uint32 modifiers)
|
||||
_BCmdKey *cmdKey = (_BCmdKey *)accelList.ItemAt(index);
|
||||
|
||||
accelList.RemoveItem(index);
|
||||
|
||||
delete cmdKey->message;
|
||||
delete cmdKey;
|
||||
}
|
||||
}
|
||||
@@ -2126,6 +2114,9 @@ BWindow::InitData(BRect frame, const char* title, window_look look,
|
||||
fLink->Read<port_id>(&send_port);
|
||||
fLink->SetSendPort(send_port);
|
||||
|
||||
if (locked)
|
||||
be_app->Unlock();
|
||||
|
||||
STRACE(("Server says that our send port is %ld\n", send_port));
|
||||
|
||||
STRACE(("Window locked?: %s\n", IsLocked()?"True":"False"));
|
||||
|
||||
Reference in New Issue
Block a user