Bug in FormulaDelegate : string copy was made in a wrong way

This commit is contained in:
Grégory Soutadé 2017-01-01 17:34:56 +01:00
parent 320d8689f6
commit d046f4e399
2 changed files with 10 additions and 7 deletions

View File

@ -1,9 +1,11 @@
v0.7 (11/11/2016)
v0.7 (01/01/2017)
** User **
Set background calendar color to red or yellow when one account is negative or less than 200
Set background calendar color to red or yellow when one account is negative or less than 200
** Dev **
** Bugs **
Bug in expression parser, negative mark before parenthesis considered as positive.
Bug in FormulaDelegate : string copy was made in a wrong way
v0.6 (08/10/2016)
** User **

View File

@ -23,6 +23,7 @@
#include "FormulaDelegate.hpp"
#include <ParseExp.hpp>
#include "../wxUI.hpp"
#include <cstring>
#include <iostream>
QWidget * FormulaDelegate::createEditor (QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const
@ -38,17 +39,17 @@ void FormulaDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
double res = 0.0;
QString value = line->text();
struct ParseExp::parse_opt opt, *r;
const char* c;
char* str, *str2;
bool ok;
std::string ss;
value = value.trimmed();
if (value.startsWith("="))
{
value = value.replace(",", ".");
c = value.toStdString().c_str();
str2 = str = new char[strlen(c)];
strcpy(str, c+1);
ss = value.toStdString();
str2 = str = new char[ss.length()];
std::strcpy(str, ss.c_str()+1);
memset(&opt, 0, sizeof(opt));
r = &opt;
try {