diff --git a/src/servers/app/CursorManager.cpp b/src/servers/app/CursorManager.cpp index bdc4615290..71baafa022 100644 --- a/src/servers/app/CursorManager.cpp +++ b/src/servers/app/CursorManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku. + * Copyright 2001-2016, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -341,7 +341,7 @@ CursorManager::GetCursor(BCursorID which) \param token ID of the cursor to find \return The cursor or NULL if not found */ -ServerCursor * +ServerCursor* CursorManager::FindCursor(int32 token) { if (!Lock()) @@ -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 CursorManager::_InitCursor(ServerCursor*& cursorMember, const uint8* cursorBits, BCursorID id, const BPoint& hotSpot) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index ed1a026349..8a510285a7 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -481,6 +481,8 @@ Desktop::RegisterListener(DesktopListener* listener) } +/*! This method is allowed to throw exceptions. +*/ status_t Desktop::Init() { diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index 5c0da7563c..d84068c1e1 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2014, Haiku. + * Copyright 2001-2016, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -31,6 +31,7 @@ #include #include + // functions needed to convert a freetype vector graphics to a BShape inline BPoint VectorToPoint(const FT_Vector *vector) @@ -401,7 +402,7 @@ ServerFont::PutTransformedFace(FT_Face face) const status_t ServerFont::GetGlyphShapes(const char charArray[], int32 numChars, - BShape *shapeArray[]) const + BShape* shapeArray[]) const { if (!charArray || numChars <= 0 || !shapeArray) return B_BAD_DATA; @@ -418,9 +419,13 @@ ServerFont::GetGlyphShapes(const char charArray[], int32 numChars, funcs.shift = 0; funcs.delta = 0; - const char *string = charArray; + const char* string = charArray; 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_Outline outline = face->glyph->outline; FT_Outline_Decompose(&outline, &funcs, shapeArray[i]); @@ -871,7 +876,10 @@ ServerFont::TruncateString(BString* inOut, uint32 mode, float width) const int32 numChars = inOut->CountChars(); // 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 }; if (GetEscapements(inOut->String(), inOut->Length(), numChars, delta, escapementArray) == B_OK) { diff --git a/src/servers/app/font/FontManager.cpp b/src/servers/app/font/FontManager.cpp index 18176681dc..43b1801880 100644 --- a/src/servers/app/font/FontManager.cpp +++ b/src/servers/app/font/FontManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku. + * Copyright 2001-2016, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -7,13 +7,13 @@ * Axel Dörfler, axeld@pinc-software.de */ + /*! Manages font families and styles */ -#include "FontFamily.h" #include "FontManager.h" -#include "ServerConfig.h" -#include "ServerFont.h" + +#include #include #include @@ -25,7 +25,10 @@ #include #include -#include +#include "FontFamily.h" +#include "ServerConfig.h" +#include "ServerFont.h" + //#define 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)); // the FontStyle takes over ownership of the FT_Face object - FontStyle *style = new FontStyle(nodeRef, path.Path(), face); - if (!family->AddStyle(style)) { + FontStyle *style = new (std::nothrow) FontStyle(nodeRef, path.Path(), face); + if (style == NULL || !family->AddStyle(style)) { delete style; delete family; return B_NO_MEMORY;