app_server: Fixed/documented uses of new without nothrow.

* This should fix all occurrences except for those in the drawing
  sub directory.
* In some cases, the use of new without nothrow was okay, though.
This commit is contained in:
Axel Dörfler
2016-08-04 22:52:40 +02:00
parent f744935b65
commit eb69155bbf
4 changed files with 32 additions and 14 deletions
+6 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2009, Haiku. * Copyright 2001-2016, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -357,6 +357,11 @@ CursorManager::FindCursor(int32 token)
} }
/*! \brief Initializes a predefined system cursor.
This method must only be called in the CursorManager's constructor,
as it may throw exceptions.
*/
void void
CursorManager::_InitCursor(ServerCursor*& cursorMember, CursorManager::_InitCursor(ServerCursor*& cursorMember,
const uint8* cursorBits, BCursorID id, const BPoint& hotSpot) const uint8* cursorBits, BCursorID id, const BPoint& hotSpot)
+2
View File
@@ -481,6 +481,8 @@ Desktop::RegisterListener(DesktopListener* listener)
} }
/*! This method is allowed to throw exceptions.
*/
status_t status_t
Desktop::Init() Desktop::Init()
{ {
+11 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2014, Haiku. * Copyright 2001-2016, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
// functions needed to convert a freetype vector graphics to a BShape // functions needed to convert a freetype vector graphics to a BShape
inline BPoint inline BPoint
VectorToPoint(const FT_Vector *vector) VectorToPoint(const FT_Vector *vector)
@@ -420,7 +421,11 @@ ServerFont::GetGlyphShapes(const char charArray[], int32 numChars,
const char* string = charArray; const char* string = charArray;
for (int i = 0; i < numChars; i++) { for (int i = 0; i < numChars; i++) {
shapeArray[i] = new BShape(); shapeArray[i] = new (std::nothrow) BShape();
if (shapeArray[i] == NULL) {
PutTransformedFace(face);
return B_NO_MEMORY;
}
FT_Load_Char(face, UTF8ToCharCode(&string), FT_LOAD_NO_BITMAP); FT_Load_Char(face, UTF8ToCharCode(&string), FT_LOAD_NO_BITMAP);
FT_Outline outline = face->glyph->outline; FT_Outline outline = face->glyph->outline;
FT_Outline_Decompose(&outline, &funcs, shapeArray[i]); FT_Outline_Decompose(&outline, &funcs, shapeArray[i]);
@@ -871,7 +876,10 @@ ServerFont::TruncateString(BString* inOut, uint32 mode, float width) const
int32 numChars = inOut->CountChars(); int32 numChars = inOut->CountChars();
// get the escapement of each glyph in font units // get the escapement of each glyph in font units
float* escapementArray = new float[numChars]; float* escapementArray = new (std::nothrow) float[numChars];
if (escapementArray == NULL)
return;
static escapement_delta delta = (escapement_delta){ 0.0, 0.0 }; static escapement_delta delta = (escapement_delta){ 0.0, 0.0 };
if (GetEscapements(inOut->String(), inOut->Length(), numChars, delta, if (GetEscapements(inOut->String(), inOut->Length(), numChars, delta,
escapementArray) == B_OK) { escapementArray) == B_OK) {
+10 -7
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2009, Haiku. * Copyright 2001-2016, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -7,13 +7,13 @@
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
*/ */
/*! Manages font families and styles */ /*! Manages font families and styles */
#include "FontFamily.h"
#include "FontManager.h" #include "FontManager.h"
#include "ServerConfig.h"
#include "ServerFont.h" #include <new>
#include <Autolock.h> #include <Autolock.h>
#include <Directory.h> #include <Directory.h>
@@ -25,7 +25,10 @@
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include <new> #include "FontFamily.h"
#include "ServerConfig.h"
#include "ServerFont.h"
//#define TRACE_FONT_MANAGER //#define TRACE_FONT_MANAGER
#ifdef TRACE_FONT_MANAGER #ifdef TRACE_FONT_MANAGER
@@ -608,8 +611,8 @@ FontManager::_AddFont(font_directory& directory, BEntry& entry)
FTRACE(("\tadd style: %s, %s\n", face->family_name, face->style_name)); FTRACE(("\tadd style: %s, %s\n", face->family_name, face->style_name));
// the FontStyle takes over ownership of the FT_Face object // the FontStyle takes over ownership of the FT_Face object
FontStyle *style = new FontStyle(nodeRef, path.Path(), face); FontStyle *style = new (std::nothrow) FontStyle(nodeRef, path.Path(), face);
if (!family->AddStyle(style)) { if (style == NULL || !family->AddStyle(style)) {
delete style; delete style;
delete family; delete family;
return B_NO_MEMORY; return B_NO_MEMORY;