[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/kalgebra/analitza
From: Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date: 2009-03-06 13:25:56
Message-ID: 1236345956.548360.1868.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 935871 by apol:
Ported the expression class private member to QSharedData.
Fixed issue when passing a vector as a piecewise condition.
M +9 -8 expression.cpp
M +2 -1 expression.h
M +1 -0 tests/analitzatest.cpp
--- trunk/KDE/kdeedu/kalgebra/analitza/expression.cpp #935870:935871
@@ -33,7 +33,7 @@
void print_dom(const QDomNode& in, int ind);
-class Expression::ExpressionPrivate
+class Expression::ExpressionPrivate : public QSharedData
{
public:
ExpressionPrivate(Object* t) : m_tree(t) {}
@@ -82,7 +82,6 @@
{
if(d && d->m_tree)
delete d->m_tree;
- delete d;
}
Expression Expression::operator=(const Expression & e)
@@ -126,13 +125,15 @@
correct=false;
}
}
- } else if(where->isContainer()) {
+ }
+
+ if(where->isContainer()) {
Container* cWhere=static_cast<Container*>(where);
if(cWhere->containerType()==Container::piecewise) {
bool isCondition=branch->isContainer() &&
- (static_cast<Container*>(where)->containerType()==Container::piece ||
- static_cast<Container*>(where)->containerType()==Container::otherwise);
+ (static_cast<Container*>(branch)->containerType()==Container::piece ||
+ static_cast<Container*>(branch)->containerType()==Container::otherwise);
if(!isCondition) {
m_err << i18nc("there was an element that was not a conditional inside a \
condition",
"%1 is not a proper condition inside the piecewise", branch->toString());
@@ -400,7 +401,7 @@
void print_dom(const QDomNode& in, int ind)
{
QString a;
-
+
if(ind >100){
qDebug("...");
return;
@@ -408,12 +409,12 @@
for(int i=0; i<ind; i++)
a.append("______|");
-
+
if(in.hasChildNodes())
qDebug("%s%s(%s) -- %d", qPrintable(a), qPrintable(in.toElement().tagName()), \
qPrintable(in.toElement().text()), in.childNodes().length()); else
qDebug("%s%s", qPrintable(a), qPrintable(in.toElement().tagName()));
-
+
for(unsigned int i=0 ; i<in.childNodes().length(); i++){
if(in.childNodes().item(i).isElement())
print_dom(in.childNodes().item(i), ind+1);
--- trunk/KDE/kdeedu/kalgebra/analitza/expression.h #935870:935871
@@ -20,6 +20,7 @@
#define EXPRESSION_H
#include <QStringList>
+#include <QSharedDataPointer>
#include "analitzaexport.h"
#include "object.h"
@@ -177,7 +178,7 @@
Object* branch(const QDomElement& elem);
class ExpressionPrivate;
- ExpressionPrivate *d;
+ QSharedDataPointer<ExpressionPrivate> d;
};
#endif
--- trunk/KDE/kdeedu/kalgebra/analitza/tests/analitzatest.cpp #935870:935871
@@ -266,6 +266,7 @@
QTest::newRow("wrong operation") << QStringList("lcm(vector{0}, vector{0})");
QTest::newRow("wrong sum") << QStringList("sum(x, x:10..0)");
QTest::newRow("recursive var") << QStringList("x:=x+1");
+ QTest::newRow("xxx") << QStringList("piecewise {scalarproduct(vector{x, 1/x})}");
QStringList script;
script << "a:=b";
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic