From bfb4e79c681ad0b0b065551b2e21cf36be303f8f Mon Sep 17 00:00:00 2001
From: Sambuddha Basu <sambuddhabasu1@gmail.com>
Date: Fri, 30 Jan 2015 02:59:00 +0530
Subject: [PATCH] Ticket 11111 - Division by zero in TabDecorator
---
src/servers/app/decorator/TabDecorator.cpp | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/servers/app/decorator/TabDecorator.cpp b/src/servers/app/decorator/TabDecorator.cpp
index 0d295a0..9ac1af5 100644
a
|
b
|
TabDecorator::_DoTabLayout()
|
406 | 406 | void |
407 | 407 | TabDecorator::_DistributeTabSize(float delta) |
408 | 408 | { |
409 | | ASSERT(CountTabs() > 1); |
| 409 | int32 tabCount = fTabList.CountItems(); |
| 410 | ASSERT(tabCount > 1); |
410 | 411 | |
411 | 412 | float maxTabSize = 0; |
412 | 413 | float secMaxTabSize = 0; |
413 | 414 | int32 nTabsWithMaxSize = 0; |
414 | | for (int32 i = 0; i < fTabList.CountItems(); i++) { |
| 415 | for (int32 i = 0; i < tabCount; i++) { |
415 | 416 | Decorator::Tab* tab = fTabList.ItemAt(i); |
| 417 | |
| 418 | if (tab == NULL) |
| 419 | continue; |
| 420 | |
416 | 421 | float tabWidth = tab->tabRect.Width(); |
417 | 422 | if (int_equal(maxTabSize, tabWidth)) { |
418 | 423 | nTabsWithMaxSize++; |
… |
… |
TabDecorator::_DistributeTabSize(float delta)
|
431 | 436 | minus /= nTabsWithMaxSize; |
432 | 437 | |
433 | 438 | Decorator::Tab* prevTab = NULL; |
434 | | for (int32 i = 0; i < fTabList.CountItems(); i++) { |
| 439 | for (int32 i = 0; i < tabCount; i++) { |
435 | 440 | Decorator::Tab* tab = fTabList.ItemAt(i); |
436 | 441 | if (int_equal(maxTabSize, tab->tabRect.Width())) |
437 | 442 | tab->tabRect.right -= minus; |
… |
… |
TabDecorator::_DistributeTabSize(float delta)
|
452 | 457 | // done |
453 | 458 | prevTab->tabRect.right = floor(fFrame.right + fBorderWidth); |
454 | 459 | |
455 | | for (int32 i = 0; i < fTabList.CountItems(); i++) { |
| 460 | for (int32 i = 0; i < tabCount; i++) { |
456 | 461 | Decorator::Tab* tab = _TabAt(i); |
457 | 462 | tab->tabOffset = uint32(tab->tabRect.left - fLeftBorder.left); |
458 | 463 | } |