mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 15:32:52 +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.
Origin commit data
------------------
Branch: ni/coolstream
Commit: f813b9ea98
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-02-23 (Sun, 23 Feb 2014)
Origin message was:
------------------
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 was generated by Migit
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc_base.h"
|
||||
|
||||
#include <gui/widget/messagebox.h>
|
||||
using namespace std;
|
||||
|
||||
//abstract basic class CComponents
|
||||
@@ -83,15 +83,30 @@ void CComponents::initVarBasic()
|
||||
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
|
||||
void CComponents::paintFbItems(bool do_save_bg)
|
||||
{
|
||||
//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++){
|
||||
if (v_fbdata[i].fbdata_type == CC_FBDATA_TYPE_BGSCREEN){
|
||||
if ((v_fbdata[i].x <= 0) || (v_fbdata[i].y <= 0))
|
||||
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);
|
||||
if (!CheckFbData(v_fbdata[i])){
|
||||
DisplayErrorMessage("Screensave error, please show log and report!");
|
||||
break;
|
||||
}
|
||||
#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",
|
||||
__func__,
|
||||
@@ -103,27 +118,23 @@ void CComponents::paintFbItems(bool do_save_bg)
|
||||
v_fbdata[i].dx,
|
||||
v_fbdata[i].dy);
|
||||
#endif
|
||||
saved_screen.x = v_fbdata[i].x;
|
||||
saved_screen.y = v_fbdata[i].y;
|
||||
saved_screen.dx = v_fbdata[i].dx;
|
||||
saved_screen.dy = v_fbdata[i].dy;
|
||||
clearSavedScreen();
|
||||
saved_screen.pixbuf = getScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy);
|
||||
firstPaint = false;
|
||||
break;
|
||||
}
|
||||
saved_screen.x = v_fbdata[i].x;
|
||||
saved_screen.y = v_fbdata[i].y;
|
||||
saved_screen.dx = v_fbdata[i].dx;
|
||||
saved_screen.dy = v_fbdata[i].dy;
|
||||
clearSavedScreen();
|
||||
saved_screen.pixbuf = getScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy);
|
||||
firstPaint = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t i=0; i< v_fbdata.size() ;i++){
|
||||
// Don't paint if dx or dy are 0
|
||||
if ((v_fbdata[i].dx == 0) || (v_fbdata[i].dy == 0)){
|
||||
#ifdef DEBUG_CC
|
||||
printf("\t[CComponents] WARNING: [%s - %d], dx = %d dy = %d\n", __func__, __LINE__, v_fbdata[i].dx, v_fbdata[i].dy);
|
||||
#endif
|
||||
for(size_t i=0; i< v_fbdata.size(); i++){
|
||||
// Don't paint on dimension or position error dx or dy are 0
|
||||
if (!CheckFbData(v_fbdata[i])){
|
||||
DisplayErrorMessage("Display error, please show log and report!");
|
||||
continue;
|
||||
}
|
||||
|
||||
int fbtype = v_fbdata[i].fbdata_type;
|
||||
#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",
|
||||
|
@@ -104,6 +104,9 @@ class CComponents
|
||||
///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);
|
||||
|
||||
///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
|
||||
virtual void clearFbData();
|
||||
|
||||
|
Reference in New Issue
Block a user