[haiku-commits] haiku: hrev51425 - src/apps/deskbar

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 14 Sep 2017 19:33:22 +0200 (CEST)

hrev51425 adds 2 changesets to branch 'master'
old head: d3499f24a7aacb407d75f23c2c59adbaa08fbc52
new head: 938fd26fbb82a0cbd1cdb0474b67df04262f4268
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=938fd26fbb82+%5Ed3499f24a7aa

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

037df9293864: Revert "Revert "Deskbar: eliminate infinite loop bug""
  
  This reverts commit 032a3f45f76d811cb25e76a96a2c817ce3840b99.

938fd26fbb82: Fix infinite loop bug, take 2
  
  ... by calling TBarView::UpdatePlacement() in
  TBarWindow::FramedResized() only if the width has changed.
  
  Explanation from take 1:
      TBarWindow::FrameResized() calls TBarView::UpdatePlacement() to
      resize the ExpandoMenuBar, however, UpdatePlacement() as part of its
      work also resizes the window, which calls TBarWindow::FrameResized()
      which in turn calls TBarView::UpdatePlacement() and so on.
  
      To get out of this mess remove TBarView::UpdatePlacement() from
      TBarWindow::FrameResized() but that leaves ExpandoMenuBar the
      wrong size initially.
  
      (now call UpdatePlacement() conditionally instead of removing it)
  
      To fix this call SizeWindow() on AllAttached() which resizes
      ExpandoMenuBar along with the rest of the window, but, just once not in
      an infinite loop. Use AllAttached() rather than AttachedToWindow() so that
      we are assured that ExpandoMenuBar and all of its children have been
      attached thus avoiding the potential for an embarrasing Deskbar crash.
  
      (we still need to call SizeWindow() on AllAttached())
  
  Fixes #13706

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

3 files changed, 18 insertions(+), 7 deletions(-)
src/apps/deskbar/BarWindow.cpp      | 15 ++++++++-------
src/apps/deskbar/ExpandoMenuBar.cpp |  9 +++++++++
src/apps/deskbar/ExpandoMenuBar.h   |  1 +

############################################################################

Commit:      037df92938644bf5894ac2024fb051b7b1b01f68
URL:         http://cgit.haiku-os.org/haiku/commit/?id=037df9293864
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Wed Sep 13 22:50:35 2017 UTC

Revert "Revert "Deskbar: eliminate infinite loop bug""

This reverts commit 032a3f45f76d811cb25e76a96a2c817ce3840b99.

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

diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp
index e57c4e2..db38219 100644
--- a/src/apps/deskbar/BarWindow.cpp
+++ b/src/apps/deskbar/BarWindow.cpp
@@ -252,7 +252,6 @@ TBarWindow::FrameResized(float width, float height)
                if (fBarView->Vertical() && fBarView->ExpandoState())
                        fBarView->ExpandoMenuBar()->SetMaxContentWidth(width);
 
-               fBarView->UpdatePlacement();
                Unlock();
        }
 }
diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp 
b/src/apps/deskbar/ExpandoMenuBar.cpp
index 1e2850c..643d013 100644
--- a/src/apps/deskbar/ExpandoMenuBar.cpp
+++ b/src/apps/deskbar/ExpandoMenuBar.cpp
@@ -114,6 +114,15 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView* barView, bool 
vertical)
 
 
 void
+TExpandoMenuBar::AllAttached()
+{
+       BMenuBar::AllAttached();
+
+       SizeWindow(0);
+}
+
+
+void
 TExpandoMenuBar::AttachedToWindow()
 {
        BMenuBar::AttachedToWindow();
diff --git a/src/apps/deskbar/ExpandoMenuBar.h 
b/src/apps/deskbar/ExpandoMenuBar.h
index 5f338c5..1aa2e86 100644
--- a/src/apps/deskbar/ExpandoMenuBar.h
+++ b/src/apps/deskbar/ExpandoMenuBar.h
@@ -63,6 +63,7 @@ class TExpandoMenuBar : public BMenuBar {
 public:
                                                        
TExpandoMenuBar(TBarView* barView, bool vertical);
 
+       virtual void                    AllAttached();
        virtual void                    AttachedToWindow();
        virtual void                    DetachedFromWindow();
 

############################################################################

Revision:    hrev51425
Commit:      938fd26fbb82a0cbd1cdb0474b67df04262f4268
URL:         http://cgit.haiku-os.org/haiku/commit/?id=938fd26fbb82
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Thu Sep 14 15:51:59 2017 UTC

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

Fix infinite loop bug, take 2

... by calling TBarView::UpdatePlacement() in
TBarWindow::FramedResized() only if the width has changed.

Explanation from take 1:
    TBarWindow::FrameResized() calls TBarView::UpdatePlacement() to
    resize the ExpandoMenuBar, however, UpdatePlacement() as part of its
    work also resizes the window, which calls TBarWindow::FrameResized()
    which in turn calls TBarView::UpdatePlacement() and so on.

    To get out of this mess remove TBarView::UpdatePlacement() from
    TBarWindow::FrameResized() but that leaves ExpandoMenuBar the
    wrong size initially.

    (now call UpdatePlacement() conditionally instead of removing it)

    To fix this call SizeWindow() on AllAttached() which resizes
    ExpandoMenuBar along with the rest of the window, but, just once not in
    an infinite loop. Use AllAttached() rather than AttachedToWindow() so that
    we are assured that ExpandoMenuBar and all of its children have been
    attached thus avoiding the potential for an embarrasing Deskbar crash.

    (we still need to call SizeWindow() on AllAttached())

Fixes #13706

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

diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp
index db38219..e9aee53 100644
--- a/src/apps/deskbar/BarWindow.cpp
+++ b/src/apps/deskbar/BarWindow.cpp
@@ -243,16 +243,18 @@ TBarWindow::FrameResized(float width, float height)
                else
                        newWidth = width;
 
+               float oldWidth = 
static_cast<TBarApp*>(be_app)->Settings()->width;
+
                // update width setting
                static_cast<TBarApp*>(be_app)->Settings()->width = newWidth;
-       }
 
-       if (Lock()) {
-               fBarView->ResizeTo(width, fBarView->Bounds().Height());
-               if (fBarView->Vertical() && fBarView->ExpandoState())
-                       fBarView->ExpandoMenuBar()->SetMaxContentWidth(width);
+               if (oldWidth != newWidth) {
+                       fBarView->ResizeTo(width, fBarView->Bounds().Height());
+                       if (fBarView->Vertical() && fBarView->ExpandoState())
+                               
fBarView->ExpandoMenuBar()->SetMaxContentWidth(width);
 
-               Unlock();
+                       fBarView->UpdatePlacement();
+               }
        }
 }
 


Other related posts: