From 46db18d19961c418116e83cca2edc8c59ad40f3f Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sat, 17 Nov 2012 22:00:47 -0500 Subject: [PATCH] DiskUsage: Truncating of tabs could lead to deadlock (#9170) --- src/apps/diskusage/ControlsView.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/apps/diskusage/ControlsView.cpp b/src/apps/diskusage/ControlsView.cpp index dcb1c00d81..b5d222af63 100644 --- a/src/apps/diskusage/ControlsView.cpp +++ b/src/apps/diskusage/ControlsView.cpp @@ -73,8 +73,8 @@ VolumeTab::IconWidth() const void VolumeTab::DrawLabel(BView* owner, BRect frame) { - owner->SetDrawingMode(B_OP_OVER); if (fIcon != NULL) { + owner->SetDrawingMode(B_OP_OVER); owner->MovePenTo(frame.left + kSmallHMargin, (frame.top + frame.bottom - fIcon->Bounds().Height()) / 2.0); owner->DrawBitmap(fIcon); @@ -188,13 +188,9 @@ ControlsView::VolumeTabView::TabFrame(int32 index) const oldToShave = toShave; for (int32 i = 0; i < countTabs; i++) { float iconWidth = ((VolumeTab*)TabAt(i))->IconWidth(); - float newMargin = margins[i] - averageToShave; - - toShave -= averageToShave; - if (newMargin < minimumMargin + iconWidth) { - toShave += minimumMargin - newMargin + iconWidth; - newMargin = minimumMargin + iconWidth; - } + float newMargin = max_c(margins[i] - averageToShave, + minimumMargin + iconWidth); + toShave -= margins[i] - newMargin; margins[i] = newMargin; } } while (toShave > 0 && oldToShave != toShave);