[Scummvm-git-logs] scummvm master -> f75fef4626234a9947eda849b1e027377fc08c0d

Strangerke noreply at scummvm.org
Sun May 19 19:37:50 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:
f75fef4626 BAGEL: Remove some more useless checks in boflib/gui


Commit: f75fef4626234a9947eda849b1e027377fc08c0d
    https://github.com/scummvm/scummvm/commit/f75fef4626234a9947eda849b1e027377fc08c0d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T20:37:44+01:00

Commit Message:
BAGEL: Remove some more useless checks in boflib/gui

Changed paths:
    engines/bagel/boflib/gfx/text.cpp
    engines/bagel/boflib/gui/button.cpp
    engines/bagel/boflib/gui/dialog.cpp
    engines/bagel/boflib/gui/list_box.cpp
    engines/bagel/boflib/gui/scroll_bar.cpp
    engines/bagel/boflib/gui/text_box.cpp
    engines/bagel/boflib/gui/window.cpp


diff --git a/engines/bagel/boflib/gfx/text.cpp b/engines/bagel/boflib/gfx/text.cpp
index 64a2c000994..dde92a414e4 100644
--- a/engines/bagel/boflib/gfx/text.cpp
+++ b/engines/bagel/boflib/gfx/text.cpp
@@ -126,14 +126,9 @@ ErrorCode CBofText::setupText(const CBofRect *pRect, int nJustify, uint32 nForma
 
 	// Create a bitmap to serve as our work area as we output text
 	_pWork = new CBofBitmap(_cSize.cx, _cSize.cy, pPalette);
-	if (_pWork == nullptr)
-		fatalError(ERR_MEMORY, "Could not allocate a (%d x %d) CBofBitmap", _cSize.cx, _cSize.cy);
 
 	// Create a bitmap to hold the background we overwrite
 	_pBackground = new CBofBitmap(_cSize.cx, _cSize.cy, pPalette);
-	if (_pBackground == nullptr) {
-		fatalError(ERR_MEMORY, "Could not allocate a (%d x %d) CBofBitmap", _cSize.cx, _cSize.cy);
-	}
 
 	return _errCode;
 }
diff --git a/engines/bagel/boflib/gui/button.cpp b/engines/bagel/boflib/gui/button.cpp
index 5fd6bc41a0c..4b405a2819d 100644
--- a/engines/bagel/boflib/gui/button.cpp
+++ b/engines/bagel/boflib/gui/button.cpp
@@ -480,10 +480,6 @@ ErrorCode CBofBmpButton::paint(CBofRect *) {
 
 		if (_pBackground == nullptr) {
 			_pBackground = new CBofBitmap(nWidth, nHeight, pPalette);
-			if (_pBackground == nullptr) {
-				fatalError(ERR_MEMORY, "Could not allocate a CBofBitmap(%d x %d)", nWidth, nHeight);
-			}
-
 		} else {
 			_pBackground->paint(&cOffScreen, 0, 0);
 		}
@@ -544,24 +540,16 @@ ErrorCode CBofBmpButton::loadBitmaps(CBofPalette *pPalette, const char *pszUp, c
 
 	// Load each of the bitmaps that represent the button state
 	_pButtonUp = new CBofBitmap(pszUp, pPalette);
-	if (_pButtonUp != nullptr) {
-		_pButtonUp->setReadOnly(true);
-	}
+	_pButtonUp->setReadOnly(true);
 
 	_pButtonDown = new CBofBitmap(pszDown, pPalette);
-	if (_pButtonDown != nullptr) {
-		_pButtonDown->setReadOnly(true);
-	}
+	_pButtonDown->setReadOnly(true);
 	
 	_pButtonFocus = new CBofBitmap(pszFocus, pPalette);
-	if (_pButtonFocus != nullptr) {
-		_pButtonFocus->setReadOnly(true);
-	}
+	_pButtonFocus->setReadOnly(true);
 
 	_pButtonDisabled = new CBofBitmap(pszDisabled, pPalette);
-	if (_pButtonDisabled != nullptr) {
-		_pButtonDisabled->setReadOnly(true);
-	}
+	_pButtonDisabled->setReadOnly(true);
 
 	return _errCode;
 }
diff --git a/engines/bagel/boflib/gui/dialog.cpp b/engines/bagel/boflib/gui/dialog.cpp
index dbf0c453ea1..82d61dd001e 100644
--- a/engines/bagel/boflib/gui/dialog.cpp
+++ b/engines/bagel/boflib/gui/dialog.cpp
@@ -92,10 +92,10 @@ ErrorCode CBofDialog::create(const char *pszName, int x, int y, int nWidth, int
 	// Calculate effective bounds
 	Common::Rect stRect(x, y, x + nWidth, y + nHeight);
 	if (pParent != nullptr)
-		stRect.translate(pParent->getWindowRect().left,
-						 pParent->getWindowRect().top);
+		stRect.translate(pParent->getWindowRect().left, pParent->getWindowRect().top);
 
 	_cRect = stRect;
+
 	delete _surface;
 	_surface = new Graphics::ManagedSurface(*g_engine->_screen, stRect);
 
@@ -204,8 +204,6 @@ ErrorCode CBofDialog::saveBackground() {
 		delete _pDlgBackground;
 		// Save a copy of the background
 		_pDlgBackground = new CBofBitmap(width(), height(), pPalette);
-		if (_pDlgBackground == nullptr)
-			fatalError(ERR_MEMORY, "Unable to allocate a new CBofBitmap(%d x %d)", width(), height());
 
 		_pDlgBackground->captureScreen(this, &_cRect);
 		_pDlgBackground->setReadOnly(true);
diff --git a/engines/bagel/boflib/gui/list_box.cpp b/engines/bagel/boflib/gui/list_box.cpp
index eaeb3941fd4..fd7af32359f 100644
--- a/engines/bagel/boflib/gui/list_box.cpp
+++ b/engines/bagel/boflib/gui/list_box.cpp
@@ -337,8 +337,6 @@ ErrorCode CBofListBox::saveBackground() {
 
 	killBackground();
 	_pBackdrop = new CBofBitmap(width(), height(), CBofApp::getApp()->getPalette());
-	if (_pBackdrop == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a %d x %d CBofBitmap", width(), height());
 
 	if ((_parent != nullptr) && (_parent->getBackdrop() != nullptr)) {
 		CBofRect cRect = _pBackdrop->getRect();
@@ -360,9 +358,6 @@ ErrorCode CBofListBox::createWorkArea() {
 	if (_pWork == nullptr) {
 		assert(_pBackdrop != nullptr);
 		_pWork = new CBofBitmap(width(), height(), _pBackdrop->getPalette());
-		if (_pWork == nullptr) {
-			fatalError(ERR_MEMORY, "Unable to allocate a %d x %d CBofBitmap", width(), height());
-		}
 	}
 
 	return _errCode;
diff --git a/engines/bagel/boflib/gui/scroll_bar.cpp b/engines/bagel/boflib/gui/scroll_bar.cpp
index ae81177edaa..d9e30eaa5eb 100644
--- a/engines/bagel/boflib/gui/scroll_bar.cpp
+++ b/engines/bagel/boflib/gui/scroll_bar.cpp
@@ -111,9 +111,6 @@ ErrorCode CBofScrollBar::setText(const char *pszText, int nJustify) {
 			cTempRect.right += 20;
 
 			_pScrollText = new CBofText(&cTempRect, nJustify);
-			if (_pScrollText == nullptr) {
-				fatalError(ERR_MEMORY, "Could not allocate a new CBofText");
-			}
 		}
 
 		if (_pScrollText != nullptr) {
@@ -217,8 +214,6 @@ ErrorCode CBofScrollBar::loadBitmaps(const char *pszBack, const char *pszThumb,
 	_nScrollWidth = _cBkSize.cx;
 
 	_pThumb = new CBofSprite;
-	if (_pThumb == nullptr)
-		fatalError(ERR_MEMORY, "Could not allocate a new CBofSprite");
 
 	if (_pThumb->loadSprite(pszThumb) != false) {
 		_pThumb->setMaskColor(COLOR_WHITE);
@@ -231,8 +226,6 @@ ErrorCode CBofScrollBar::loadBitmaps(const char *pszBack, const char *pszThumb,
 	CBofPoint cPoint;
 	if (pszLeftBtnUp != nullptr) {
 		_pLeftBtnUp = new CBofBitmap(pszLeftBtnUp, pPalette);
-		if (_pLeftBtnUp == nullptr)
-			fatalError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszLeftBtnUp);
 
 		cPoint.x = 0;
 		cPoint.y = (_pBackdrop->height() / 2) - (_pLeftBtnUp->height() / 2);
@@ -248,8 +241,6 @@ ErrorCode CBofScrollBar::loadBitmaps(const char *pszBack, const char *pszThumb,
 
 	if (pszRightBtnUp != nullptr) {
 		_pRightBtnUp = new CBofBitmap(pszRightBtnUp, pPalette);
-		if (_pRightBtnUp == nullptr)
-			fatalError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszRightBtnUp);
 
 		cPoint.x = _pBackdrop->width() - _pRightBtnUp->width();
 		cPoint.y = (_pBackdrop->height() / 2) - (_pRightBtnUp->height() / 2);
@@ -263,9 +254,6 @@ ErrorCode CBofScrollBar::loadBitmaps(const char *pszBack, const char *pszThumb,
 
 	if (pszLeftBtnDn != nullptr) {
 		_pLeftBtnDn = new CBofBitmap(pszLeftBtnDn, pPalette);
-		if (_pLeftBtnDn == nullptr) {
-			fatalError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszLeftBtnDn);
-		}
 	}
 
 	delete _pRightBtnDn;
@@ -273,9 +261,6 @@ ErrorCode CBofScrollBar::loadBitmaps(const char *pszBack, const char *pszThumb,
 
 	if (pszRightBtnDn != nullptr) {
 		_pRightBtnDn = new CBofBitmap(pszRightBtnDn, pPalette);
-		if (_pRightBtnDn == nullptr) {
-			fatalError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%s)", pszRightBtnDn);
-		}
 	}
 
 	return _errCode;
@@ -303,9 +288,6 @@ ErrorCode CBofScrollBar::paint(CBofRect *pDirtyRect) {
 		if ((_pBackdrop != nullptr) && (_pThumb != nullptr)) {
 			// Do all painting offscreen
 			CBofBitmap *pBmp = new CBofBitmap(_cBkSize.cx, _cBkSize.cy, pPalette);
-			if (pBmp == nullptr)
-				fatalError(ERR_MEMORY, "Could not allocate a new CBofBitmap(%d x %d))", _cBkSize.cx, _cBkSize.cy);
-
 			_pBackdrop->paint(pBmp, 0, 0, nullptr, COLOR_WHITE);
 
 			if ((_nScrollState == 1) && (_pLeftBtnDn != nullptr)) {
diff --git a/engines/bagel/boflib/gui/text_box.cpp b/engines/bagel/boflib/gui/text_box.cpp
index 9de54edf245..c7724383e87 100644
--- a/engines/bagel/boflib/gui/text_box.cpp
+++ b/engines/bagel/boflib/gui/text_box.cpp
@@ -111,8 +111,6 @@ ErrorCode CBofTextBox::setBox(const CBofRect *pRect) {
 
 	// Create a new text field the size of the box we want
 	_pTextField = new CBofText(pRect, JUSTIFY_WRAP);
-	if (_pTextField == nullptr)
-		fatalError(ERR_MEMORY, "Could not allocate a CBofText");
 
 	return _errCode;
 }
diff --git a/engines/bagel/boflib/gui/window.cpp b/engines/bagel/boflib/gui/window.cpp
index c7fd212334b..750a03b7810 100644
--- a/engines/bagel/boflib/gui/window.cpp
+++ b/engines/bagel/boflib/gui/window.cpp
@@ -317,9 +317,6 @@ void CBofWindow::setTimer(uint32 nID, uint32 nInterval, BofCallback pCallBack) {
 	}
 
 	pPacket = new CBofTimerPacket;
-	if (pPacket == nullptr)
-		fatalError(ERR_MEMORY, "Unable to allocate a CBofTimerPacket");
-
 	pPacket->_nID = nID;
 	pPacket->_nInterval = nInterval;
 	pPacket->_pCallBack = pCallBack;
@@ -489,8 +486,6 @@ ErrorCode CBofWindow::setBackdrop(const char *pszFileName, bool bRefresh) {
 	// Use Application's palette if none supplied
 	CBofPalette *pPalette = CBofApp::getApp()->getPalette();
 	CBofBitmap *pBmp = new CBofBitmap(pszFileName, pPalette);
-	if (pBmp == nullptr)
-		fatalError(ERR_MEMORY, "Could not allocate a new CBofBitmap");
 
 	return setBackdrop(pBmp, bRefresh);
 }




More information about the Scummvm-git-logs mailing list