bad_alloc_str in now usable in the entire namespace finalcut

This commit is contained in:
Markus Gans 2018-11-22 21:51:32 +01:00
parent f6df9585f5
commit 820ef81377
29 changed files with 73 additions and 76 deletions

View File

@ -401,7 +401,7 @@ void FApplication::init (long key_time, long dblclick_time)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}

View File

@ -727,7 +727,7 @@ void FButton::draw()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -506,7 +506,7 @@ void FButtonGroup::drawLabel()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -887,7 +887,7 @@ void FDialog::init()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -906,7 +906,7 @@ void FDialog::initDialogMenu()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -934,7 +934,7 @@ void FDialog::initMoveSizeMenuItem (FMenu* menu)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -957,7 +957,7 @@ void FDialog::initZoomMenuItem (FMenu* menu)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -980,7 +980,7 @@ void FDialog::initCloseMenuItem (FMenu* menu)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -1446,7 +1446,7 @@ inline void FDialog::passEventToSubMenu ( mouseStates& ms
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
}
@ -1727,7 +1727,7 @@ void FDialog::cb_move (FWidget*, data_ptr)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -276,7 +276,7 @@ const FString FFileDialog::fileOpenChooser ( FWidget* parent
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return FString();
}
@ -319,7 +319,7 @@ const FString FFileDialog::fileSaveChooser ( FWidget* parent
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return FString();
}

View File

@ -373,7 +373,7 @@ bool FKeyboard::isKeypressTimeout()
FKey FKeyboard::UTF8decode (const char utf8[])
{
FKey ucs = 0; // Universal coded character
const int max = 4;
const std::size_t max = 4;
std::size_t len = std::strlen(utf8);
if ( len > max )

View File

@ -293,7 +293,7 @@ void FLabel::onMouseDown (FMouseEvent* ev)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
}
@ -529,7 +529,7 @@ void FLabel::drawMultiLine()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -574,7 +574,7 @@ void FLabel::drawSingleLine()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -844,7 +844,7 @@ void FListBox::init()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -877,7 +877,7 @@ FObject::FObjectIterator FListView::insert ( const FStringList& cols
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return FListView::null_iter;
}
@ -1468,7 +1468,7 @@ void FListView::init()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -953,7 +953,7 @@ void FMenu::passEventToSubMenu (FMouseEvent*& ev)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}
@ -977,7 +977,7 @@ void FMenu::passEventToSuperMenu (FMouseEvent*& ev)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}
@ -1002,7 +1002,7 @@ void FMenu::passEventToMenuBar (FMouseEvent*& ev)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}
@ -1336,7 +1336,7 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -566,7 +566,7 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -1027,8 +1027,7 @@ void FMenuBar::passEventToMenu (FMouseEvent*& ev)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}
}

View File

@ -692,8 +692,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -742,8 +741,7 @@ void FMenuItem::passMouseEvent ( T widget, FMouseEvent* ev
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc "
<< ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -202,7 +202,7 @@ int FMessageBox::info ( FWidget* parent
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return FDialog::Reject;
}
@ -231,7 +231,7 @@ int FMessageBox::info ( FWidget* parent
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return FDialog::Reject;
}
@ -259,7 +259,7 @@ int FMessageBox::error ( FWidget* parent
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return FDialog::Reject;
}
@ -374,7 +374,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
}
@ -423,10 +423,8 @@ inline void FMessageBox::initCallbacks()
//----------------------------------------------------------------------
void FMessageBox::calculateDimensions()
{
int x, y;
std::size_t w, h;
std::size_t headline_height = 0;
FWidget* parent_widget = getParentWidget();
text_split = text.split("\n");
text_num_lines = uInt(text_split.size());
text_components = &text_split[0];
@ -449,15 +447,7 @@ void FMessageBox::calculateDimensions()
if ( w < 20 )
w = 20;
if ( parent_widget )
{
x = 1 + int((parent_widget->getWidth() - w) / 2);
y = 1 + int((parent_widget->getHeight() - h) / 3);
}
else
x = y = 1;
setGeometry (x, y, w, h);
setSize (w, h);
}
//----------------------------------------------------------------------

View File

@ -59,7 +59,7 @@ FObject::FObject (FObject* parent)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
}

View File

@ -787,7 +787,7 @@ void FScrollView::init_scrollbar()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -28,10 +28,6 @@
namespace finalcut
{
// static class constant
const char* const FString::bad_alloc_str = "not enough memory " \
"to alloc a new string";
//----------------------------------------------------------------------
// class FString
//----------------------------------------------------------------------

View File

@ -1696,7 +1696,7 @@ inline void FTerm::allocationValues()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}

View File

@ -557,7 +557,7 @@ char* FTermDetection::parseAnswerbackMsg (char current_termtype[])
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return 0;
}
@ -628,7 +628,7 @@ char* FTermDetection::parseSecDA (char current_termtype[])
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return current_termtype;
}

View File

@ -541,7 +541,7 @@ bool FTermLinux::getScreenFont()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return false;
}
@ -588,7 +588,7 @@ bool FTermLinux::getUnicodeMap()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return false;
}
@ -665,7 +665,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return -1;
}

View File

@ -832,7 +832,7 @@ const FString* FTermXTerminal::captureXTermFont()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return 0;
}
@ -887,7 +887,7 @@ const FString* FTermXTerminal::captureXTermTitle()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return 0;
}

View File

@ -444,7 +444,7 @@ void FTextView::onMouseDown (FMouseEvent* ev)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}
}
@ -473,7 +473,7 @@ void FTextView::onMouseUp (FMouseEvent* ev)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}
}
@ -509,7 +509,7 @@ void FTextView::onMouseMove (FMouseEvent* ev)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}
}
@ -580,6 +580,9 @@ void FTextView::adjustSize()
if ( yoffset < 0 )
yoffset = 0;
if ( height < 3 )
return;
vbar->setMaximum (last_line - int(height) + 2 - nf_offset);
vbar->setPageSize (last_line, int(height) - 2 + nf_offset);
vbar->setX (int(width));
@ -587,6 +590,9 @@ void FTextView::adjustSize()
vbar->setValue (yoffset);
vbar->resize();
if ( width < 3 )
return;
hbar->setMaximum (max_width - int(width) + nf_offset + 2);
hbar->setPageSize (max_width, int(width) - nf_offset - 2);
hbar->setY (int(height));
@ -639,7 +645,7 @@ void FTextView::init()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -498,7 +498,7 @@ void FToggleButton::drawLabel()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}

View File

@ -630,7 +630,7 @@ void FVTerm::createArea ( int offset_left, int offset_top
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -757,7 +757,7 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return false;
}
@ -776,7 +776,7 @@ inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return false;
}
@ -1986,7 +1986,7 @@ void FVTerm::init (bool disable_alt_screen)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}

View File

@ -1958,7 +1958,7 @@ void FWidget::init()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
@ -1991,7 +1991,7 @@ void FWidget::init()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}

View File

@ -82,7 +82,7 @@ inline const FString& emptyFString::get()
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
}
}

View File

@ -264,7 +264,6 @@ class FString
static const uInt FWDBUFFER = 15;
static const uInt INPBUFFER = 200;
static const uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character
static const char* const bad_alloc_str;
// Methods
void initLength (std::size_t);

View File

@ -64,6 +64,9 @@ typedef uInt32 FKey;
namespace finalcut
{
const char* const bad_alloc_str = \
"not enough memory to alloc ";
template <typename T, bool is_signed>
struct is_negative
{

View File

@ -1032,7 +1032,7 @@ inline char* createBlankArray (std::size_t size)
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
std::cerr << bad_alloc_str << ex.what() << std::endl;
return 0;
}

View File

@ -2297,7 +2297,7 @@ void FTermDetectionTest::terminalSimulation (console con)
{
fd_set ifds;
struct timeval tv;
int len;
ssize_t len;
FD_ZERO(&ifds);
FD_SET(fd_stdin, &ifds);
@ -2314,8 +2314,11 @@ void FTermDetectionTest::terminalSimulation (console con)
{
len = read (fd_stdin, buffer, sizeof(buffer));
if ( len > 0 )
if ( len != -1 && std::size_t(len) < sizeof(buffer) )
{
buffer[len] = '\0';
write (fd_master, buffer, len); // Send data to the master side
}
}
// Data on the master side of PTY
@ -2323,10 +2326,13 @@ void FTermDetectionTest::terminalSimulation (console con)
{
len = read (fd_master, buffer, sizeof(buffer));
if ( len < 0 )
if ( len == -1 || std::size_t(len) >= sizeof(buffer) )
break;
else if ( len > 0 )
{
buffer[len] = '\0';
parseTerminalBuffer (len, con);
}
}
}
}