Small code fixes

This commit is contained in:
Markus Gans 2018-10-22 01:26:24 +02:00
parent 540291b410
commit 3678d52766
11 changed files with 28 additions and 34 deletions

View File

@ -925,12 +925,8 @@ void FDialog::initDialogMenu()
dialog_menu->setPos (getX(), getY() + 1); dialog_menu->setPos (getX(), getY() + 1);
dgl_menuitem = dialog_menu->getItem(); dgl_menuitem = dialog_menu->getItem();
dgl_menuitem->ignorePadding();
if ( dgl_menuitem ) dgl_menuitem->unsetFocusable();
{
dgl_menuitem->ignorePadding();
dgl_menuitem->unsetFocusable();
}
// Add the move/size menu item // Add the move/size menu item
initMoveSizeMenuItem (dialog_menu); initMoveSizeMenuItem (dialog_menu);

View File

@ -54,9 +54,7 @@ FDialogListMenu::~FDialogListMenu()
void FDialogListMenu::init() void FDialogListMenu::init()
{ {
FMenuItem* menuitem = getItem(); FMenuItem* menuitem = getItem();
menuitem->dialog_index = true;
if ( menuitem )
menuitem->dialog_index = true;
} }
} // namespace finalcut } // namespace finalcut

View File

@ -529,8 +529,7 @@ void FLineEdit::onTimer (FTimerEvent*)
return; return;
} }
if ( text_offset > 0 ) text_offset--;
text_offset--;
if ( cursor_pos > 0 ) if ( cursor_pos > 0 )
cursor_pos--; cursor_pos--;

View File

@ -1154,11 +1154,11 @@ void FOptiMove::moveByMethod ( int method
if ( xold >= 0 ) if ( xold >= 0 )
std::strncat ( move_ptr std::strncat ( move_ptr
, F_carriage_return.cap , F_carriage_return.cap
, BUF_SIZE - std::strlen(move_ptr) ); , BUF_SIZE - std::strlen(move_ptr) - 1 );
std::strncat ( move_ptr std::strncat ( move_ptr
, F_cursor_left.cap , F_cursor_left.cap
, BUF_SIZE - std::strlen(move_ptr) ); , BUF_SIZE - std::strlen(move_ptr) - 1);
move_ptr[BUF_SIZE - 1] ='\0'; move_ptr[BUF_SIZE - 1] ='\0';
move_ptr += std::strlen(move_buf); move_ptr += std::strlen(move_buf);
relativeMove (move_ptr, int(screen_width) - 1, yold - 1, xnew, ynew); relativeMove (move_ptr, int(screen_width) - 1, yold - 1, xnew, ynew);

View File

@ -416,7 +416,7 @@ char* FTerm::enableCursor()
// Restore the last used Linux console cursor style // Restore the last used Linux console cursor style
char* cstyle; char* cstyle;
cstyle = linux->restoreCursorStyle(); cstyle = linux->restoreCursorStyle();
std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str)); std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1);
} }
#endif // defined(__linux__) #endif // defined(__linux__)

View File

@ -577,19 +577,14 @@ bool FTermLinux::getUnicodeMap()
if ( ret != 0 ) if ( ret != 0 )
{ {
int count; std::size_t count = screen_unicode_map.entry_ct;
if ( errno != ENOMEM || screen_unicode_map.entry_ct == 0 ) if ( errno != ENOMEM || count == 0 )
return false;
count = screen_unicode_map.entry_ct;
if ( count <= 0 )
return false; return false;
try try
{ {
screen_unicode_map.entries = new struct unipair[std::size_t(count)](); screen_unicode_map.entries = new struct unipair[count]();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {

View File

@ -63,11 +63,11 @@ class FPoint
FPoint& operator += (const FPoint&); FPoint& operator += (const FPoint&);
FPoint& operator -= (const FPoint&); FPoint& operator -= (const FPoint&);
friend inline bool operator == (const FPoint&, const FPoint&); friend bool operator == (const FPoint&, const FPoint&);
friend inline bool operator != (const FPoint&, const FPoint&); friend bool operator != (const FPoint&, const FPoint&);
friend inline FPoint operator + (const FPoint&, const FPoint&); friend FPoint operator + (const FPoint&, const FPoint&);
friend inline FPoint operator - (const FPoint&, const FPoint&); friend FPoint operator - (const FPoint&, const FPoint&);
friend inline FPoint operator - (const FPoint&); friend FPoint operator - (const FPoint&);
friend std::ostream& operator << (std::ostream&, const FPoint&); friend std::ostream& operator << (std::ostream&, const FPoint&);
friend std::istream& operator >> (std::istream&, FPoint&); friend std::istream& operator >> (std::istream&, FPoint&);

View File

@ -2763,7 +2763,7 @@ void FKeyboardTest::utf8Test()
keyboard->disableUTF8(); keyboard->disableUTF8();
input("\360\220\200\200"); input("\360\220\200\200");
processInput(); processInput();
CPPUNIT_ASSERT ( key_released == 0200 ); CPPUNIT_ASSERT ( key_released == 128 );
clear(); clear();
} }

View File

@ -131,6 +131,7 @@ void FObjectTest::classNameTest()
void FObjectTest::noArgumentTest() void FObjectTest::noArgumentTest()
{ {
finalcut::FObject o1; finalcut::FObject o1;
finalcut::FObject o2;
CPPUNIT_ASSERT ( ! o1.hasParent() ); CPPUNIT_ASSERT ( ! o1.hasParent() );
CPPUNIT_ASSERT ( o1.getParent() == 0 ); CPPUNIT_ASSERT ( o1.getParent() == 0 );
CPPUNIT_ASSERT ( ! o1.hasChildren() ); CPPUNIT_ASSERT ( ! o1.hasChildren() );
@ -142,8 +143,8 @@ void FObjectTest::noArgumentTest()
CPPUNIT_ASSERT ( children_list.begin() == o1.end() ); CPPUNIT_ASSERT ( children_list.begin() == o1.end() );
CPPUNIT_ASSERT ( children_list.end() == o1.begin() ); CPPUNIT_ASSERT ( children_list.end() == o1.begin() );
CPPUNIT_ASSERT ( children_list.end() == o1.end() ); CPPUNIT_ASSERT ( children_list.end() == o1.end() );
CPPUNIT_ASSERT ( ! o1.isChild(&o1) ); CPPUNIT_ASSERT ( ! o1.isChild(&o2) );
CPPUNIT_ASSERT ( ! o1.isDirectChild(&o1) ); CPPUNIT_ASSERT ( ! o1.isDirectChild(&o2) );
CPPUNIT_ASSERT ( ! o1.isWidget() ); CPPUNIT_ASSERT ( ! o1.isWidget() );
CPPUNIT_ASSERT ( o1.isInstanceOf("FObject") ); CPPUNIT_ASSERT ( o1.isInstanceOf("FObject") );
CPPUNIT_ASSERT ( ! o1.isTimerInUpdating() ); CPPUNIT_ASSERT ( ! o1.isTimerInUpdating() );
@ -176,6 +177,7 @@ void FObjectTest::childObjectTest()
finalcut::FObject* c4 = new finalcut::FObject(&obj); finalcut::FObject* c4 = new finalcut::FObject(&obj);
finalcut::FObject* c5 = new finalcut::FObject(c1); finalcut::FObject* c5 = new finalcut::FObject(c1);
finalcut::FObject* c6 = new finalcut::FObject(c5); finalcut::FObject* c6 = new finalcut::FObject(c5);
finalcut::FObject* c7 = new finalcut::FObject();
CPPUNIT_ASSERT ( obj.hasChildren() ); CPPUNIT_ASSERT ( obj.hasChildren() );
CPPUNIT_ASSERT ( obj.getChild(0) == 0 ); CPPUNIT_ASSERT ( obj.getChild(0) == 0 );
@ -213,7 +215,7 @@ void FObjectTest::childObjectTest()
CPPUNIT_ASSERT ( children_list2.begin() != c1->end() ); CPPUNIT_ASSERT ( children_list2.begin() != c1->end() );
CPPUNIT_ASSERT ( children_list2.end() != c1->begin() ); CPPUNIT_ASSERT ( children_list2.end() != c1->begin() );
CPPUNIT_ASSERT ( children_list2.end() == c1->end() ); CPPUNIT_ASSERT ( children_list2.end() == c1->end() );
CPPUNIT_ASSERT ( ! c1->isDirectChild(c1) ); CPPUNIT_ASSERT ( ! c1->isDirectChild(c7) );
CPPUNIT_ASSERT ( ! c1->isWidget() ); CPPUNIT_ASSERT ( ! c1->isWidget() );
CPPUNIT_ASSERT ( c1->isInstanceOf("FObject") ); CPPUNIT_ASSERT ( c1->isInstanceOf("FObject") );
CPPUNIT_ASSERT ( ! c1->isTimerInUpdating() ); CPPUNIT_ASSERT ( ! c1->isTimerInUpdating() );

View File

@ -219,8 +219,10 @@ void FPointTest::equalTest()
CPPUNIT_ASSERT ( p1 == p2 ); CPPUNIT_ASSERT ( p1 == p2 );
CPPUNIT_ASSERT ( finalcut::FPoint(1,2) == p2 ); CPPUNIT_ASSERT ( finalcut::FPoint(1,2) == p2 );
CPPUNIT_ASSERT ( p1 == finalcut::FPoint(1,2) ); CPPUNIT_ASSERT ( p1 == finalcut::FPoint(1,2) );
CPPUNIT_ASSERT ( finalcut::FPoint() == finalcut::FPoint() ); const finalcut::FPoint p3;
CPPUNIT_ASSERT ( finalcut::FPoint() == -finalcut::FPoint() ); const finalcut::FPoint p4;
CPPUNIT_ASSERT ( p3 == p4 );
CPPUNIT_ASSERT ( p3 == -p4 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -299,7 +299,9 @@ void FRectTest::equalTest()
CPPUNIT_ASSERT ( r1 == r2 ); CPPUNIT_ASSERT ( r1 == r2 );
CPPUNIT_ASSERT ( finalcut::FRect(1, 2, 10, 20) == r2 ); CPPUNIT_ASSERT ( finalcut::FRect(1, 2, 10, 20) == r2 );
CPPUNIT_ASSERT ( r1 == finalcut::FRect(1, 2, 10, 20) ); CPPUNIT_ASSERT ( r1 == finalcut::FRect(1, 2, 10, 20) );
CPPUNIT_ASSERT ( finalcut::FRect() == finalcut::FRect() ); const finalcut::FRect r3;
const finalcut::FRect r4;
CPPUNIT_ASSERT ( r3 == r4 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------