aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Menu.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 975a967..6f997a5 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -702,6 +702,14 @@ void Menu::drawSubmenu(unsigned int index) {
702 702
703 item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height); 703 item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height);
704 704
705 // ensure we do not divide by 0 and thus cause a SIGFPE
706 if (m_rows_per_column == 0) {
707#if DEBUG
708 cout << "Error: m_rows_per_column == 0 in FbTk::Menu::clearItem()\n";
709#endif
710 return;
711 }
712
705 int column = index / m_rows_per_column; 713 int column = index / m_rows_per_column;
706 int row = index - (column * m_rows_per_column); 714 int row = index - (column * m_rows_per_column);
707 int new_x = x() + ((m_item_w * (column + 1)) + m_window.borderWidth()); 715 int new_x = x() + ((m_item_w * (column + 1)) + m_window.borderWidth());
@@ -769,6 +777,14 @@ int Menu::drawItem(FbDrawable &drawable, unsigned int index,
769 MenuItem *item = menuitems[index]; 777 MenuItem *item = menuitems[index];
770 if (! item) return 0; 778 if (! item) return 0;
771 779
780 // ensure we do not divide by 0 and thus cause a SIGFPE
781 if (m_rows_per_column == 0) {
782#if DEBUG
783 cout << "Error: m_rows_per_column == 0 in FbTk::Menu::clearItem()\n";
784#endif
785 return 0;
786 }
787
772 int column = index / m_rows_per_column; 788 int column = index / m_rows_per_column;
773 int row = index - (column * m_rows_per_column); 789 int row = index - (column * m_rows_per_column);
774 int item_x = (column * m_item_w); 790 int item_x = (column * m_item_w);
@@ -999,6 +1015,15 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
999 1015
1000 1016
1001void Menu::exposeEvent(XExposeEvent &ee) { 1017void Menu::exposeEvent(XExposeEvent &ee) {
1018
1019 // some xservers (eg: nxserver) send XExposeEvent for the unmapped menu.
1020 // this caused a SIGFPE in ::clearItem(), since m_rows_per_column is
1021 // still 0 -> division by 0.
1022 //
1023 // it is still unclear, why nxserver behaves this way
1024 if (!isVisible())
1025 return;
1026
1002 if (ee.window == m_title) { 1027 if (ee.window == m_title) {
1003 m_title.clearArea(ee.x, ee.y, ee.width, ee.height); 1028 m_title.clearArea(ee.x, ee.y, ee.width, ee.height);
1004 } else if (ee.window == m_frame) { 1029 } else if (ee.window == m_frame) {
@@ -1241,6 +1266,14 @@ void Menu::clearItem(int index, bool clear, int search_index) {
1241 if (!validIndex(index)) 1266 if (!validIndex(index))
1242 return; 1267 return;
1243 1268
1269 // ensure we do not divide by 0 and thus cause a SIGFPE
1270 if (m_rows_per_column == 0) {
1271#if DEBUG
1272 cout << "Error: m_rows_per_column == 0 in FbTk::Menu::clearItem()\n";
1273#endif
1274 return;
1275 }
1276
1244 int column = index / m_rows_per_column; 1277 int column = index / m_rows_per_column;
1245 int row = index - (column * m_rows_per_column); 1278 int row = index - (column * m_rows_per_column);
1246 unsigned int item_w = m_item_w; 1279 unsigned int item_w = m_item_w;
@@ -1276,6 +1309,15 @@ void Menu::clearItem(int index, bool clear, int search_index) {
1276 1309
1277// Area must have been cleared before calling highlight 1310// Area must have been cleared before calling highlight
1278void Menu::highlightItem(int index) { 1311void Menu::highlightItem(int index) {
1312
1313 // ensure we do not divide by 0 and thus cause a SIGFPE
1314 if (m_rows_per_column == 0) {
1315#if DEBUG
1316 cout << "Error: m_rows_per_column == 0 in FbTk::Menu::clearItem()\n";
1317#endif
1318 return;
1319 }
1320
1279 int column = index / m_rows_per_column; 1321 int column = index / m_rows_per_column;
1280 int row = index - (column * m_rows_per_column); 1322 int row = index - (column * m_rows_per_column);
1281 unsigned int item_w = m_item_w; 1323 unsigned int item_w = m_item_w;
@@ -1333,6 +1375,14 @@ void Menu::drawLine(int index, int size){
1333 if (!validIndex(index)) 1375 if (!validIndex(index))
1334 return; 1376 return;
1335 1377
1378 // ensure we do not divide by 0 and thus cause a SIGFPE
1379 if (m_rows_per_column == 0) {
1380#if DEBUG
1381 cout << "Error: m_rows_per_column == 0 in FbTk::Menu::clearItem()\n";
1382#endif
1383 return;
1384 }
1385
1336 int column = index / m_rows_per_column; 1386 int column = index / m_rows_per_column;
1337 int row = index - (column * m_rows_per_column); 1387 int row = index - (column * m_rows_per_column);
1338 int item_x = (column * m_item_w); 1388 int item_x = (column * m_item_w);