Ticket #7734: 0001-Fix7734.-Avoid-race-conditions-in-ToolBar-animation.patch

File 0001-Fix7734.-Avoid-race-conditions-in-ToolBar-animation.patch, 3.1 KB (added by Janus, 7 years ago)
  • src/apps/showimage/ShowImageWindow.cpp

    From b6a2e37719df6055c054ef64c1d15c82d3e3a20f Mon Sep 17 00:00:00 2001
    From: Janus <janus2@ymail.com>
    Date: Sun, 2 Dec 2012 12:55:06 +0000
    Subject: [PATCH] Fix7734. Avoid race conditions in ToolBar animation
    
    ---
     src/apps/showimage/ShowImageWindow.cpp |   17 ++++++++---------
     src/apps/showimage/ShowImageWindow.h   |    1 +
     2 files changed, 9 insertions(+), 9 deletions(-)
    
    diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp
    index b79059e..e871751 100644
    a b ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,  
    209209        viewFrame.top = fToolBarView->Frame().bottom + 1;
    210210    else
    211211        fToolBarView->Hide();
     212       
     213    fToolBarVisible = fShowToolBar;
    212214
    213215    viewFrame.bottom = contentView->Bounds().bottom;
    214216    viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
    ShowImageWindow::MessageReceived(BMessage* message)  
    10511053            if (message->FindFloat("offset", &offset) == B_OK
    10521054                && message->FindBool("show", &show) == B_OK) {
    10531055                // Compensate rounding errors with the final placement
    1054                 if (show)
    1055                     fToolBarView->MoveTo(fToolBarView->Frame().left, 0);
    1056                 else {
    1057                     fToolBarView->MoveTo(fToolBarView->Frame().left, offset);
     1056                fToolBarView->MoveTo(fToolBarView->Frame().left, offset);
     1057                if (!show)
    10581058                    fToolBarView->Hide();
    1059                 }
    10601059                BRect frame = fToolBarView->Parent()->Bounds();
    10611060                frame.top = fToolBarView->Frame().bottom + 1;
    10621061                fScrollView->MoveTo(fScrollView->Frame().left, frame.top);
    ShowImageWindow::_UpdateRatingMenu()  
    15191518void
    15201519ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)
    15211520{
    1522     if (visible == !fToolBarView->IsHidden())
     1521    if (visible == fToolBarVisible)
    15231522        return;
    1524 
     1523       
     1524    fToolBarVisible = visible;
    15251525    float diff = fToolBarView->Bounds().Height() + 2;
    15261526    if (!visible)
    15271527        diff = -diff;
    ShowImageWindow::_SetToolBarVisible(bool visible, bool animate)  
    15331533        // not to block the window thread.
    15341534        const float kAnimationOffsets[] = { 0.05, 0.2, 0.5, 0.2, 0.05 };
    15351535        const int32 steps = sizeof(kAnimationOffsets) / sizeof(float);
    1536         float originalY = fToolBarView->Frame().top;
    15371536        for (int32 i = 0; i < steps; i++) {
    15381537            BMessage message(kMsgSlideToolBar);
    15391538            message.AddFloat("offset", floorf(diff * kAnimationOffsets[i]));
    15401539            PostMessage(&message, this);
    15411540        }
    15421541        BMessage finalMessage(kMsgFinishSlidingToolBar);
    1543         finalMessage.AddFloat("offset", originalY + diff);
     1542        finalMessage.AddFloat("offset", visible ? 0 : diff);
    15441543        finalMessage.AddBool("show", visible);
    15451544        PostMessage(&finalMessage, this);
    15461545    } else {
  • src/apps/showimage/ShowImageWindow.h

    diff --git a/src/apps/showimage/ShowImageWindow.h b/src/apps/showimage/ShowImageWindow.h
    index f5cf499..4834739 100644
    a b private:  
    115115            BMenu*              fSlideShowDelayMenu;
    116116            BMenu*              fRatingMenu;
    117117            ToolBarView*        fToolBarView;
     118            bool                fToolBarVisible;
    118119            BScrollView*        fScrollView;
    119120            BScrollBar*         fVerticalScrollBar;
    120121            ShowImageView*      fImageView;