mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
CComponents: add member CheckFbData() for fbdata check
This check happens several times, therefore it is senseful, to move into own member. Function returns false on error and is used here to show an error message if something was wrong. Such errors can happen on position or dimension errors e.g. out of screen or too large display values. Note: this is only an emergency helper for debugging on fatal errors during developing of window stuff. Mostly errors of this kind causing crashes and must be fixed.
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
#include "cc_base.h"
|
#include "cc_base.h"
|
||||||
|
#include <gui/widget/messagebox.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//abstract basic class CComponents
|
//abstract basic class CComponents
|
||||||
@@ -83,15 +83,30 @@ void CComponents::initVarBasic()
|
|||||||
saved_screen.pixbuf = NULL;
|
saved_screen.pixbuf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CComponents::CheckFbData(const comp_fbdata_t& fbdata)
|
||||||
|
{
|
||||||
|
if ( (fbdata.x <= 0 || fbdata.y <= 0) ||
|
||||||
|
(fbdata.dx == 0 || fbdata.dy == 0) ||
|
||||||
|
(fbdata.dx > (int32_t)frameBuffer->getScreenWidth(true) || fbdata.dy > (int32_t)frameBuffer->getScreenHeight(true))){
|
||||||
|
printf("\33[31m\t[CComponents] WARNING! Position <= 0 [%s - %d]\n\tx = %d y = %d\n\tdx = %d dy = %d\n\033[37m",
|
||||||
|
__func__, __LINE__,
|
||||||
|
fbdata.x, fbdata.y,
|
||||||
|
fbdata.dx, fbdata.dy);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//paint framebuffer stuff and fill buffer
|
//paint framebuffer stuff and fill buffer
|
||||||
void CComponents::paintFbItems(bool do_save_bg)
|
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 (v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BGSCREEN){
|
if (!CheckFbData(v_fbdata[i])){
|
||||||
if ((v_fbdata[i].x <= 0) || (v_fbdata[i].y <= 0))
|
DisplayErrorMessage("Screensave error, please show log and report!");
|
||||||
printf("\33[31m\t[CComponents] WARNING! Position <= 0 [%s - %d], x = %d y = %d\n\033[37m", __func__, __LINE__, v_fbdata[i].x, v_fbdata[i].y);
|
break;
|
||||||
|
}
|
||||||
#ifdef DEBUG_CC
|
#ifdef DEBUG_CC
|
||||||
printf("\t[CComponents]\n\t[%s - %d] firstPaint->save screen: %d, fbdata_type: %d\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n",
|
printf("\t[CComponents]\n\t[%s - %d] firstPaint->save screen: %d, fbdata_type: %d\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n",
|
||||||
__func__,
|
__func__,
|
||||||
@@ -103,27 +118,23 @@ void CComponents::paintFbItems(bool do_save_bg)
|
|||||||
v_fbdata[i].dx,
|
v_fbdata[i].dx,
|
||||||
v_fbdata[i].dy);
|
v_fbdata[i].dy);
|
||||||
#endif
|
#endif
|
||||||
saved_screen.x = v_fbdata[i].x;
|
saved_screen.x = v_fbdata[i].x;
|
||||||
saved_screen.y = v_fbdata[i].y;
|
saved_screen.y = v_fbdata[i].y;
|
||||||
saved_screen.dx = v_fbdata[i].dx;
|
saved_screen.dx = v_fbdata[i].dx;
|
||||||
saved_screen.dy = v_fbdata[i].dy;
|
saved_screen.dy = v_fbdata[i].dy;
|
||||||
clearSavedScreen();
|
clearSavedScreen();
|
||||||
saved_screen.pixbuf = getScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy);
|
saved_screen.pixbuf = getScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy);
|
||||||
firstPaint = false;
|
firstPaint = false;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i=0; i< v_fbdata.size() ;i++){
|
for(size_t i=0; i< v_fbdata.size(); i++){
|
||||||
// Don't paint if dx or dy are 0
|
// Don't paint on dimension or position error dx or dy are 0
|
||||||
if ((v_fbdata[i].dx == 0) || (v_fbdata[i].dy == 0)){
|
if (!CheckFbData(v_fbdata[i])){
|
||||||
#ifdef DEBUG_CC
|
DisplayErrorMessage("Display error, please show log and report!");
|
||||||
printf("\t[CComponents] WARNING: [%s - %d], dx = %d dy = %d\n", __func__, __LINE__, v_fbdata[i].dx, v_fbdata[i].dy);
|
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fbtype = v_fbdata[i].fbdata_type;
|
int fbtype = v_fbdata[i].fbdata_type;
|
||||||
#ifdef DEBUG_CC
|
#ifdef DEBUG_CC
|
||||||
printf("\t[CComponents]\n\t[%s - %d], fbdata_[%d]\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n",
|
printf("\t[CComponents]\n\t[%s - %d], fbdata_[%d]\n\tx = %d\n\ty = %d\n\tdx = %d\n\tdy = %d\n",
|
||||||
|
@@ -104,6 +104,9 @@ class CComponents
|
|||||||
///parameter do_save_bg=true, saves background of element to pixel buffer, this can be restore with hide()
|
///parameter do_save_bg=true, saves background of element to pixel buffer, this can be restore with hide()
|
||||||
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
|
||||||
|
bool CheckFbData(const comp_fbdata_t& fbdata);
|
||||||
|
|
||||||
///clean up old screen buffer saved in v_fbdata
|
///clean up old screen buffer saved in v_fbdata
|
||||||
virtual void clearFbData();
|
virtual void clearFbData();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user