fix adding or removing items to an open BMenu

The menu would try to relayout itself, but fail to get the supermenu
bounds as the looper for it was not locked in that case.

This fixes the crash with two downsides:
* The menu width isn't adjusted to match the parent menu (mostly visible
in BMenuFields)
* There is some flickering as the menu is updated

Fixes #9863 (Network prefs part).
This commit is contained in:
Adrien Destugues
2014-12-17 10:23:40 +01:00
parent cf01ee8a45
commit c4793b242c
+10 -2
View File
@@ -2140,8 +2140,16 @@ BMenu::_ComputeLayout(int32 index, bool bestFit, bool moveItems,
BRect parentFrame;
BRect* overrideFrame = NULL;
if (dynamic_cast<_BMCMenuBar_*>(Supermenu()) != NULL) {
parentFrame = Supermenu()->Bounds();
overrideFrame = &parentFrame;
// When the menu is modified while it's open, we get here in a
// situation where trying to lock the looper would deadlock
// (the window is locked waiting for the menu to terminate).
// In that case, just give up on getting the supermenu bounds
// and keep the menu at the current width and position.
if (Supermenu()->LockLooperWithTimeout(0) == B_OK) {
parentFrame = Supermenu()->Bounds();
Supermenu()->UnlockLooper();
overrideFrame = &parentFrame;
}
}
_ComputeColumnLayout(index, bestFit, moveItems, overrideFrame,