CComponents: More precise error message (commit aa87ed1)

Origin commit data
------------------
Branch: ni/coolstream
Commit: d1b8246316
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2014-03-03 (Mon, 03 Mar 2014)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2014-03-03 19:33:24 +01:00
parent 303d356537
commit dc88ba25cc
2 changed files with 23 additions and 13 deletions

View File

@@ -78,13 +78,23 @@ void CComponents::clearSavedScreen()
saved_screen.pixbuf = NULL; saved_screen.pixbuf = NULL;
} }
bool CComponents::CheckFbData(const comp_fbdata_t& fbdata) bool CComponents::CheckFbData(const comp_fbdata_t& fbdata, const char* func, const int line)
{ {
if ( (fbdata.x <= 0 || fbdata.y <= 0) || int32_t rows = fbdata.dx / (int32_t)frameBuffer->getScreenWidth(true) - 1 + fbdata.y;
(fbdata.dx == 0 || fbdata.dy == 0) || int32_t rest = fbdata.dx % (int32_t)frameBuffer->getScreenWidth(true);
(fbdata.dx > (int32_t)frameBuffer->getScreenWidth(true) || fbdata.dy > (int32_t)frameBuffer->getScreenHeight(true))){ int32_t end = rows * (int32_t)frameBuffer->getScreenWidth(true) + rest;
printf("\33[31m\t[CComponents] WARNING! Position <= 0 [%s - %d]\n\tx = %d y = %d\n\tdx = %d dy = %d\n\033[37m", if ( (fbdata.x < 0 || fbdata.y < 0) ||
__func__, __LINE__, (end >= (int32_t)frameBuffer->getScreenWidth(true)*(int32_t)frameBuffer->getScreenHeight(true))
) {
printf("\33[31m\t[CComponents] ERROR! Position < 0 or > FB end [%s - %d]\n\tx = %d y = %d\n\tdx = %d dy = %d\n\33[0m",
func, line,
fbdata.x, fbdata.y,
fbdata.dx, fbdata.dy);
return false;
}
if (fbdata.dx == 0 || fbdata.dy == 0) {
printf("\33[33m\t[CComponents] WARNING! dx and/or dy = 0 [%s - %d]\n\tx = %d y = %d\n\tdx = %d dy = %d\n\33[0m",
func, line,
fbdata.x, fbdata.y, fbdata.x, fbdata.y,
fbdata.dx, fbdata.dy); fbdata.dx, fbdata.dy);
return false; return false;
@@ -98,7 +108,7 @@ void CComponents::paintFbItems(bool do_save_bg)
//save background before first paint, do_save_bg must be true //save background before first paint, do_save_bg must be true
if (firstPaint && do_save_bg){ if (firstPaint && do_save_bg){
for(size_t i=0; i<v_fbdata.size(); i++){ for(size_t i=0; i<v_fbdata.size(); i++){
if (!CheckFbData(v_fbdata[i])){ if (!CheckFbData(v_fbdata[i], __func__, __LINE__)){
DisplayErrorMessage("Screensave error, please show log and report!"); DisplayErrorMessage("Screensave error, please show log and report!");
break; break;
} }
@@ -126,7 +136,7 @@ void CComponents::paintFbItems(bool do_save_bg)
for(size_t i=0; i< v_fbdata.size(); i++){ for(size_t i=0; i< v_fbdata.size(); i++){
// Don't paint on dimension or position error dx or dy are 0 // Don't paint on dimension or position error dx or dy are 0
if (!CheckFbData(v_fbdata[i])){ if (!CheckFbData(v_fbdata[i], __func__, __LINE__)){
DisplayErrorMessage("Display error, please show log and report!"); DisplayErrorMessage("Display error, please show log and report!");
continue; continue;
} }

View File

@@ -101,7 +101,7 @@ class CComponents
void paintFbItems(bool do_save_bg = true); void paintFbItems(bool do_save_bg = true);
///check current fbdtata position and dimensions, parameter fbdata is an element of v_fbdata, returns false on error ///check current fbdtata position and dimensions, parameter fbdata is an element of v_fbdata, returns false on error
bool CheckFbData(const comp_fbdata_t& fbdata); bool CheckFbData(const comp_fbdata_t& fbdata, const char* func, const int line);
///clean up old screen buffer saved in v_fbdata ///clean up old screen buffer saved in v_fbdata
virtual void clearFbData(); virtual void clearFbData();