removed potentially dangerous dangling pointer

This commit is contained in:
Guido Ranzuglia granzuglia 2010-04-08 13:17:29 +00:00
parent 3c5f55b77f
commit 241a587d9f
2 changed files with 9 additions and 14 deletions

View File

@ -37,6 +37,7 @@
#include <QLineEdit>
#include <QVBoxLayout>
#include <QSlider>
#include <vcg/space/color4.h>
#include "rfx_dialog.h"
class RfxColorBox : public QWidget
@ -51,15 +52,9 @@ public:
Returns the current color as an array of float value between 0 and 1.
@return the current color as float array.
*/
float* getColorf(){
float r, g, b, a;
r = this->_redS->value() / 255.0f;
g = this->_greenS->value() / 255.0f;
b = this->_blueS->value() / 255.0f;
a = this->_alphaS->value() / 255.0f;
float vals[4] = {r, g, b, a};
return vals;
inline vcg::Color4f getColorf(){
vcg::Color4f c(_redS->value() / 255.0f,_greenS->value() / 255.0f,_blueS->value() / 255.0f,_alphaS->value() / 255.0f);
return c;
}
public slots:

View File

@ -552,11 +552,11 @@ void RfxDialog::ChangeValue(const QString& val)
} else {
RfxColorBox *cBox = dynamic_cast<RfxColorBox*>(sender);
if (cBox != NULL) {
float* newVal = cBox->getColorf();
oldVal[0] = newVal[0];
oldVal[1] = newVal[1];
oldVal[2] = newVal[2];
oldVal[3] = newVal[3];
vcg::Color4f newVal = cBox->getColorf();
oldVal[0] = newVal.X();
oldVal[1] = newVal.Y();
oldVal[2] = newVal.Z();
oldVal[3] = newVal.W();
uni->PassToShader();
mGLWin->updateGL();
return;