[Scummvm-git-logs] scummvm master -> 883d023cd62cfd60f3ecc4229dac6a1428b0af62

Strangerke noreply at scummvm.org
Sun May 12 08:17:30 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
883d023cd6 BAGEL: In scroll_bar, remove unused variable in CBofScrollBar (fix CID 1544854), remove useless null check before deleti


Commit: 883d023cd62cfd60f3ecc4229dac6a1428b0af62
    https://github.com/scummvm/scummvm/commit/883d023cd62cfd60f3ecc4229dac6a1428b0af62
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-12T09:17:21+01:00

Commit Message:
BAGEL: In scroll_bar, remove unused variable in CBofScrollBar (fix CID 1544854), remove useless null check before deleting, reduce if depth, move assignments out of if statements

Changed paths:
    engines/bagel/boflib/gui/scroll_bar.cpp
    engines/bagel/boflib/gui/scroll_bar.h


diff --git a/engines/bagel/boflib/gui/scroll_bar.cpp b/engines/bagel/boflib/gui/scroll_bar.cpp
index f817b19d1bd..7fc329a0920 100644
--- a/engines/bagel/boflib/gui/scroll_bar.cpp
+++ b/engines/bagel/boflib/gui/scroll_bar.cpp
@@ -67,30 +67,23 @@ CBofScrollBar::~CBofScrollBar() {
 
 	_szScrollText[0] = '\0';
 
-	if (_pScrollText != nullptr) {
-		delete _pScrollText;
-		_pScrollText = nullptr;
-	}
-	if (_pThumb != nullptr) {
-		delete _pThumb;
-		_pThumb = nullptr;
-	}
-	if (_pLeftBtnUp != nullptr) {
-		delete _pLeftBtnUp;
-		_pLeftBtnUp = nullptr;
-	}
-	if (_pRightBtnUp != nullptr) {
-		delete _pRightBtnUp;
-		_pRightBtnUp = nullptr;
-	}
-	if (_pLeftBtnDn != nullptr) {
-		delete _pLeftBtnDn;
-		_pLeftBtnDn = nullptr;
-	}
-	if (_pRightBtnDn != nullptr) {
-		delete _pRightBtnDn;
-		_pRightBtnDn = nullptr;
-	}
+	delete _pScrollText;
+	_pScrollText = nullptr;
+
+	delete _pThumb;
+	_pThumb = nullptr;
+
+	delete _pLeftBtnUp;
+	_pLeftBtnUp = nullptr;
+
+	delete _pRightBtnUp;
+	_pRightBtnUp = nullptr;
+
+	delete _pLeftBtnDn;
+	_pLeftBtnDn = nullptr;
+
+	delete _pRightBtnDn;
+	_pRightBtnDn = nullptr;
 }
 
 
@@ -205,92 +198,87 @@ void CBofScrollBar::setScrollRange(int nMin, int nMax, bool bRepaint) {
 ErrorCode CBofScrollBar::loadBitmaps(const char *pszBack, const char *pszThumb, const char *pszLeftBtnUp, const char *pszRightBtnUp, const char *pszLeftBtnDn, const char *pszRightBtnDn) {
 	assert(isValidObject(this));
 
-	if ((pszBack != nullptr) && (pszThumb != nullptr)) {
-		_cLeftBtnRect.setRect(0, 0, 0, 0);
-		_cRightBtnRect.setRect(0, 0, 0, 0);
+	if ((pszBack == nullptr) || (pszThumb == nullptr))
+		return _errCode;
 
-		if (_pThumb != nullptr) {
-			_pThumb->eraseSprite(this);
-			delete _pThumb;
-			_pThumb = nullptr;
-		}
+	_cLeftBtnRect.setRect(0, 0, 0, 0);
+	_cRightBtnRect.setRect(0, 0, 0, 0);
 
-		killBackdrop();
-		setBackdrop(pszBack);
+	if (_pThumb != nullptr) {
+		_pThumb->eraseSprite(this);
+		delete _pThumb;
+		_pThumb = nullptr;
+	}
 
-		CBofPalette *pPalette = CBofApp::getApp()->getPalette();
+	killBackdrop();
+	setBackdrop(pszBack);
 
-		_cBkSize = _pBackdrop->getSize();
-		_nScrollWidth = _cBkSize.cx;
+	CBofPalette *pPalette = CBofApp::getApp()->getPalette();
 
-		if ((_pThumb = new CBofSprite) != nullptr) {
-			if (_pThumb->loadSprite(pszThumb) != false) {
-				_pThumb->setMaskColor(COLOR_WHITE);
-				_cThumbSize = _pThumb->getSize();
-			}
-		}
+	_cBkSize = _pBackdrop->getSize();
+	_nScrollWidth = _cBkSize.cx;
 
-		if (_pLeftBtnUp != nullptr) {
-			delete _pLeftBtnUp;
-			_pLeftBtnUp = nullptr;
+	_pThumb = new CBofSprite;
+	if (_pThumb != nullptr) {
+		if (_pThumb->loadSprite(pszThumb) != false) {
+			_pThumb->setMaskColor(COLOR_WHITE);
+			_cThumbSize = _pThumb->getSize();
 		}
+	}
 
-		CBofPoint cPoint;
-		if (pszLeftBtnUp != nullptr) {
-			if ((_pLeftBtnUp = new CBofBitmap(pszLeftBtnUp, pPalette)) != nullptr) {
-				cPoint.x = 0;
-				cPoint.y = (_pBackdrop->height() / 2) - (_pLeftBtnUp->height() / 2);
+	delete _pLeftBtnUp;
+	_pLeftBtnUp = nullptr;
 
-				_cLeftBtnRect = _pLeftBtnUp->getRect() + cPoint;
+	CBofPoint cPoint;
+	if (pszLeftBtnUp != nullptr) {
+		_pLeftBtnUp = new CBofBitmap(pszLeftBtnUp, pPalette);
+		if (_pLeftBtnUp != nullptr) {
+			cPoint.x = 0;
+			cPoint.y = (_pBackdrop->height() / 2) - (_pLeftBtnUp->height() / 2);
 
-				_nOffset = _pLeftBtnUp->width();
-				_nScrollWidth -= _nOffset;
+			_cLeftBtnRect = _pLeftBtnUp->getRect() + cPoint;
 
-			} else {
-				reportError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszLeftBtnUp);
-			}
-		}
+			_nOffset = _pLeftBtnUp->width();
+			_nScrollWidth -= _nOffset;
 
-		if (_pRightBtnUp != nullptr) {
-			delete _pRightBtnUp;
-			_pRightBtnUp = nullptr;
+		} else {
+			reportError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszLeftBtnUp);
 		}
+	}
 
-		if (pszRightBtnUp != nullptr) {
-			if ((_pRightBtnUp = new CBofBitmap(pszRightBtnUp, pPalette)) != nullptr) {
-				cPoint.x = _pBackdrop->width() - _pRightBtnUp->width();
-				cPoint.y = (_pBackdrop->height() / 2) - (_pRightBtnUp->height() / 2);
-				_cRightBtnRect = _pLeftBtnUp->getRect() + cPoint;
+	delete _pRightBtnUp;
+	_pRightBtnUp = nullptr;
 
-				_nScrollWidth -= _cRightBtnRect.width();
+	if (pszRightBtnUp != nullptr) {
+		_pRightBtnUp = new CBofBitmap(pszRightBtnUp, pPalette);
+		if (_pRightBtnUp != nullptr) {
+			cPoint.x = _pBackdrop->width() - _pRightBtnUp->width();
+			cPoint.y = (_pBackdrop->height() / 2) - (_pRightBtnUp->height() / 2);
+			_cRightBtnRect = _pLeftBtnUp->getRect() + cPoint;
 
-			} else {
-				reportError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszRightBtnUp);
-			}
+			_nScrollWidth -= _cRightBtnRect.width();
+		} else {
+			reportError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszRightBtnUp);
 		}
+	}
 
-		if (_pLeftBtnDn != nullptr) {
-			delete _pLeftBtnDn;
-			_pLeftBtnDn = nullptr;
-		}
-		if (pszLeftBtnDn != nullptr) {
-			if ((_pLeftBtnDn = new CBofBitmap(pszLeftBtnDn, pPalette)) != nullptr) {
+	delete _pLeftBtnDn;
+	_pLeftBtnDn = nullptr;
 
-			} else {
-				reportError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszLeftBtnDn);
-			}
+	if (pszLeftBtnDn != nullptr) {
+		_pLeftBtnDn = new CBofBitmap(pszLeftBtnDn, pPalette);
+		if (_pLeftBtnDn == nullptr) {
+			reportError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszLeftBtnDn);
 		}
+	}
 
-		if (_pRightBtnDn != nullptr) {
-			delete _pRightBtnDn;
-			_pRightBtnDn = nullptr;
-		}
-		if (pszRightBtnDn != nullptr) {
-			if ((_pRightBtnDn = new CBofBitmap(pszRightBtnDn, pPalette)) != nullptr) {
+	delete _pRightBtnDn;
+	_pRightBtnDn = nullptr;
 
-			} else {
-				reportError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszRightBtnDn);
-			}
+	if (pszRightBtnDn != nullptr) {
+		_pRightBtnDn = new CBofBitmap(pszRightBtnDn, pPalette);
+		if (_pRightBtnDn == nullptr) {
+			reportError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszRightBtnDn);
 		}
 	}
 
diff --git a/engines/bagel/boflib/gui/scroll_bar.h b/engines/bagel/boflib/gui/scroll_bar.h
index ae01ef63b88..f7b409f83d7 100644
--- a/engines/bagel/boflib/gui/scroll_bar.h
+++ b/engines/bagel/boflib/gui/scroll_bar.h
@@ -146,7 +146,6 @@ protected:
 	CBofPoint _cThumbPos;
 	int _nScrollState;
 	uint32 _nTimerCount;
-	bool _bHavePainted;
 };
 
 } // namespace Bagel




More information about the Scummvm-git-logs mailing list