This should fix some problems I experienced later. At least, I can't reproduce them anymore
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16920 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1266,15 +1266,16 @@ BMenu::RemoveItems(int32 index, int32 count, BMenuItem *item, bool deleteItems)
|
|||||||
bool invalidateLayout = false;
|
bool invalidateLayout = false;
|
||||||
|
|
||||||
bool locked = LockLooper();
|
bool locked = LockLooper();
|
||||||
|
BWindow *window = Window();
|
||||||
|
|
||||||
// The plan is simple: If we're given a BMenuItem directly, we use it
|
// The plan is simple: If we're given a BMenuItem directly, we use it
|
||||||
// and ignore index and count. Otherwise, we use them instead.
|
// and ignore index and count. Otherwise, we use them instead.
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
if (fItems.RemoveItem(item)) {
|
if (fItems.RemoveItem(item)) {
|
||||||
if (item == fSelected)
|
if (item == fSelected && window != NULL)
|
||||||
SelectItem(NULL);
|
SelectItem(NULL);
|
||||||
item->SetSuper(NULL);
|
|
||||||
item->Uninstall();
|
item->Uninstall();
|
||||||
|
item->SetSuper(NULL);
|
||||||
if (deleteItems)
|
if (deleteItems)
|
||||||
delete item;
|
delete item;
|
||||||
success = invalidateLayout = true;
|
success = invalidateLayout = true;
|
||||||
@@ -1290,10 +1291,10 @@ BMenu::RemoveItems(int32 index, int32 count, BMenuItem *item, bool deleteItems)
|
|||||||
item = static_cast<BMenuItem*>(fItems.ItemAt(i));
|
item = static_cast<BMenuItem*>(fItems.ItemAt(i));
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
if (fItems.RemoveItem(item)) {
|
if (fItems.RemoveItem(item)) {
|
||||||
if (item == fSelected)
|
if (item == fSelected && window != NULL)
|
||||||
SelectItem(NULL);
|
SelectItem(NULL);
|
||||||
item->SetSuper(NULL);
|
|
||||||
item->Uninstall();
|
item->Uninstall();
|
||||||
|
item->SetSuper(NULL);
|
||||||
if (deleteItems)
|
if (deleteItems)
|
||||||
delete item;
|
delete item;
|
||||||
success = true;
|
success = true;
|
||||||
@@ -1307,8 +1308,10 @@ BMenu::RemoveItems(int32 index, int32 count, BMenuItem *item, bool deleteItems)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalidateLayout && locked && fResizeToFit)
|
if (invalidateLayout && locked && fResizeToFit) {
|
||||||
InvalidateLayout();
|
LayoutItems(0);
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
if (locked)
|
if (locked)
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ BMenuItem::Uninstall()
|
|||||||
if (Target() == fWindow)
|
if (Target() == fWindow)
|
||||||
SetTarget(BMessenger());
|
SetTarget(BMessenger());
|
||||||
|
|
||||||
if (fShortcutChar != 0 && fModifiers != 0 && fWindow != NULL)
|
if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) && fWindow != NULL)
|
||||||
fWindow->RemoveShortcut(fShortcutChar, fModifiers);
|
fWindow->RemoveShortcut(fShortcutChar, fModifiers);
|
||||||
|
|
||||||
fWindow = NULL;
|
fWindow = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user