mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-11 19:54:03 +00:00
BAGEL: Remove useless null checks after variable creation by new (as it's covered by an exception)
This commit is contained in:
parent
53333942aa
commit
b5698f8f76
@ -39,9 +39,7 @@ CBagBmpObject::~CBagBmpObject() {
|
||||
|
||||
ErrorCode CBagBmpObject::attach(CBofPalette *palette) {
|
||||
_bmp = new CBofBitmap(getFileName(), palette);
|
||||
if (_bmp == nullptr) {
|
||||
bofMessageBox(_bmp->getFileName(), __FILE__);
|
||||
}
|
||||
|
||||
return CBagObject::attach();
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ ErrorCode CBagCharacterObject::attach() {
|
||||
|
||||
_bmpBuf = new CBofBitmap(_smacker->getWidth(), _smacker->getHeight(), smackPal);
|
||||
|
||||
if ((smackPal != nullptr) && (_bmpBuf != nullptr)) {
|
||||
if (smackPal != nullptr) {
|
||||
_bmpBuf->fillRect(nullptr, smackPal->getNearestIndex(RGB(255, 255, 255)));
|
||||
}
|
||||
|
||||
|
@ -63,9 +63,7 @@ ErrorCode CDevDlg::create(const char *bmp, CBofWindow *wnd, CBofPalette *pal, CB
|
||||
}
|
||||
|
||||
_guessText = new CBofText();
|
||||
if (_guessText != nullptr) {
|
||||
_guessText->setupText(rect, JUSTIFY_LEFT);
|
||||
}
|
||||
_guessText->setupText(rect, JUSTIFY_LEFT);
|
||||
|
||||
_guessCount = 0;
|
||||
Common::fill(_achGuess, _achGuess + ACH_GUESS_MAX_CHARS, 0);
|
||||
@ -78,21 +76,15 @@ ErrorCode CDevDlg::create(const char *bmp, CBofWindow *wnd, CBofPalette *pal, CB
|
||||
// Fall back to original dialog on failure
|
||||
if (bitmap == nullptr) {
|
||||
bitmap = new CBofBitmap(200, 100, pal);
|
||||
if (bitmap != nullptr) {
|
||||
assert(pal != nullptr);
|
||||
assert(pal != nullptr);
|
||||
|
||||
bitmap->fillRect(nullptr, pal->getNearestIndex(RGB(92, 92, 92)));
|
||||
bitmap->fillRect(nullptr, pal->getNearestIndex(RGB(92, 92, 92)));
|
||||
|
||||
CBofRect bmpRect(bitmap->getRect());
|
||||
bitmap->drawRect(&bmpRect, pal->getNearestIndex(RGB(0, 0, 0)));
|
||||
bitmap->fillRect(rect, pal->getNearestIndex(RGB(255, 255, 255)));
|
||||
|
||||
} else {
|
||||
reportError(ERR_MEMORY, "Unable to allocate a CBofBitmap");
|
||||
}
|
||||
CBofRect bmpRect(bitmap->getRect());
|
||||
bitmap->drawRect(&bmpRect, pal->getNearestIndex(RGB(0, 0, 0)));
|
||||
bitmap->fillRect(rect, pal->getNearestIndex(RGB(255, 255, 255)));
|
||||
}
|
||||
|
||||
assert(bitmap != nullptr);
|
||||
CBofRect bmpRect(bitmap->getRect());
|
||||
CBofString className = "CDevDlg";
|
||||
CBagStorageDevDlg::create(className, &bmpRect, wnd, 0);
|
||||
@ -189,10 +181,6 @@ void CDevDlg::setText(CBofString &text, CBofRect *textRect) {
|
||||
assert(isValidObject(this));
|
||||
|
||||
_titleText = new CBofText;
|
||||
|
||||
if (_titleText == nullptr)
|
||||
fatalError(ERR_MEMORY, "Unable to instantiate a new CBofText");
|
||||
|
||||
_titleText->setupText(textRect, JUSTIFY_CENTER, FORMAT_DEFAULT);
|
||||
_titleText->setColor(CTEXT_WHITE);
|
||||
_titleText->SetSize(FONT_14POINT);
|
||||
|
@ -78,15 +78,11 @@ ParseCodes CBagExpressionObject::setInfo(CBagIfstream &istr) {
|
||||
//
|
||||
// AS - n number of slides in sprite
|
||||
//
|
||||
case '(': {
|
||||
case '(':
|
||||
_expression = new CBagExpression();
|
||||
if (_expression) {
|
||||
_expression->setInfo(istr);
|
||||
objectUpdatedFl = true;
|
||||
} else {
|
||||
// there was an error
|
||||
}
|
||||
} break;
|
||||
_expression->setInfo(istr);
|
||||
objectUpdatedFl = true;
|
||||
break;
|
||||
//
|
||||
// No match return from function
|
||||
//
|
||||
|
@ -85,76 +85,55 @@ ErrorCode CBagHelp::attach() {
|
||||
CBofApp::getApp()->setPalette(backPal);
|
||||
|
||||
_okButton = new CBofBmpButton;
|
||||
if (_okButton != nullptr) {
|
||||
|
||||
CBofBitmap *upBmp = loadBitmap(buildHelpDir(HELP_OK_UP), backPal);
|
||||
CBofBitmap *downBmp = loadBitmap(buildHelpDir(HELP_OK_DOWN), backPal);
|
||||
CBofBitmap *focusBmp = loadBitmap(buildHelpDir(HELP_OK_FOCUS), backPal);
|
||||
CBofBitmap *disableBmp = loadBitmap(buildHelpDir(HELP_OK_DISABLED), backPal);
|
||||
CBofBitmap *upBmp = loadBitmap(buildHelpDir(HELP_OK_UP), backPal);
|
||||
CBofBitmap *downBmp = loadBitmap(buildHelpDir(HELP_OK_DOWN), backPal);
|
||||
CBofBitmap *focusBmp = loadBitmap(buildHelpDir(HELP_OK_FOCUS), backPal);
|
||||
CBofBitmap *disableBmp = loadBitmap(buildHelpDir(HELP_OK_DISABLED), backPal);
|
||||
|
||||
_okButton->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
|
||||
|
||||
_okButton->create("OK", HELP_OK_X, HELP_OK_Y, HELP_OK_CX, HELP_OK_CY, this, HELP_OK_ID);
|
||||
_okButton->show();
|
||||
} else {
|
||||
reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
|
||||
}
|
||||
_okButton->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
|
||||
_okButton->create("OK", HELP_OK_X, HELP_OK_Y, HELP_OK_CX, HELP_OK_CY, this, HELP_OK_ID);
|
||||
_okButton->show();
|
||||
|
||||
_pageUp = new CBofBmpButton;
|
||||
if (_pageUp != nullptr) {
|
||||
|
||||
CBofBitmap *upBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_UP), backPal);
|
||||
CBofBitmap *downBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_DOWN), backPal);
|
||||
CBofBitmap *focusBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_FOCUS), backPal);
|
||||
CBofBitmap *disableBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_DISABLED), backPal);
|
||||
upBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_UP), backPal);
|
||||
downBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_DOWN), backPal);
|
||||
focusBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_FOCUS), backPal);
|
||||
disableBmp = loadBitmap(buildHelpDir(HELP_PAGE_UP_DISABLED), backPal);
|
||||
|
||||
_pageUp->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
|
||||
|
||||
_pageUp->create("PageUp", HELP_PAGE_UP_X, HELP_PAGE_UP_Y, HELP_PAGE_UP_CX, HELP_PAGE_UP_CY, this, HELP_PAGE_UP_ID);
|
||||
_pageUp->show();
|
||||
} else {
|
||||
reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
|
||||
}
|
||||
_pageUp->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
|
||||
_pageUp->create("PageUp", HELP_PAGE_UP_X, HELP_PAGE_UP_Y, HELP_PAGE_UP_CX, HELP_PAGE_UP_CY, this, HELP_PAGE_UP_ID);
|
||||
_pageUp->show();
|
||||
|
||||
_pageDown = new CBofBmpButton;
|
||||
if (_pageDown != nullptr) {
|
||||
|
||||
CBofBitmap *upBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_UP), backPal);
|
||||
CBofBitmap *downBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_DOWN), backPal);
|
||||
CBofBitmap *focusBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_FOCUS), backPal);
|
||||
CBofBitmap *disableBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_DISABLED), backPal);
|
||||
upBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_UP), backPal);
|
||||
downBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_DOWN), backPal);
|
||||
focusBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_FOCUS), backPal);
|
||||
disableBmp = loadBitmap(buildHelpDir(HELP_PAGE_DOWN_DISABLED), backPal);
|
||||
|
||||
_pageDown->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
|
||||
_pageDown->loadBitmaps(upBmp, downBmp, focusBmp, disableBmp);
|
||||
|
||||
_pageDown->create("PageDown", HELP_PAGE_DOWN_X, HELP_PAGE_DOWN_Y, HELP_PAGE_DOWN_CX, HELP_PAGE_DOWN_CY, this, HELP_PAGE_DOWN_ID);
|
||||
_pageDown->show();
|
||||
} else {
|
||||
reportError(ERR_MEMORY, "Unable to allocate a CBofBmpButton");
|
||||
}
|
||||
_pageDown->create("PageDown", HELP_PAGE_DOWN_X, HELP_PAGE_DOWN_Y, HELP_PAGE_DOWN_CX, HELP_PAGE_DOWN_CY, this, HELP_PAGE_DOWN_ID);
|
||||
_pageDown->show();
|
||||
|
||||
CBofFile file(_textFile, CBF_BINARY | CBF_READONLY);
|
||||
|
||||
uint32 size = file.getLength();
|
||||
char *buffer = (char *)bofCAlloc(size + 1, 1);
|
||||
if (buffer != nullptr) {
|
||||
file.read(buffer, size);
|
||||
if (buffer == nullptr)
|
||||
fatalError(ERR_MEMORY, "Unable to allocate %d bytes to read %s.", size, _textFile.getBuffer());
|
||||
|
||||
CBofRect cRect;
|
||||
cRect.setRect(120, 100, 550, 348);
|
||||
file.read(buffer, size);
|
||||
|
||||
_textBox = new CBofTextBox(this, &cRect, buffer);
|
||||
if (_textBox != nullptr) {
|
||||
_textBox->setPageLength(18);
|
||||
CBofRect cRect;
|
||||
cRect.setRect(120, 100, 550, 348);
|
||||
|
||||
} else {
|
||||
reportError(ERR_MEMORY, "Unable to allocate a CBofTextBox");
|
||||
}
|
||||
_textBox = new CBofTextBox(this, &cRect, buffer);
|
||||
_textBox->setPageLength(18);
|
||||
|
||||
bofFree(buffer);
|
||||
|
||||
} else {
|
||||
reportError(ERR_MEMORY, "Unable to allocate %d bytes to read %s.", size, _textFile.getBuffer());
|
||||
}
|
||||
bofFree(buffer);
|
||||
|
||||
CBagCursor::showSystemCursor();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user