[haiku-commits] haiku: hrev48511 - src/kits/interface

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 17 Dec 2014 10:24:07 +0100 (CET)

hrev48511 adds 1 changeset to branch 'master'
old head: cf01ee8a452b0e48c4b6cab3ca63b312c882e3fe
new head: c4793b242c5c4c7bcebc4a2702ff139365f017ef
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=c4793b2+%5Ecf01ee8

----------------------------------------------------------------------------

c4793b2: 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).

                                 [ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48511
Commit:      c4793b242c5c4c7bcebc4a2702ff139365f017ef
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c4793b2
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Wed Dec 17 09:20:10 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/9863

----------------------------------------------------------------------------

1 file changed, 10 insertions(+), 2 deletions(-)
src/kits/interface/Menu.cpp | 12 ++++++++++--

----------------------------------------------------------------------------

diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp
index 8d59153..58aaeb8 100644
--- a/src/kits/interface/Menu.cpp
+++ b/src/kits/interface/Menu.cpp
@@ -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,


Other related posts:

  • » [haiku-commits] haiku: hrev48511 - src/kits/interface - pulkomandy