mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 22:30:30 +01:00
[apps/graph] Recompute expression and layout when a function sets a new content
Change-Id: I15f39c72cfed28fe6eca5b401eb8da149d30fe12
This commit is contained in:
@@ -11,14 +11,20 @@ Graph::Function::Function(const char * text, KDColor color) :
|
||||
}
|
||||
|
||||
void Graph::Function::setContent(const char * c) {
|
||||
#if __GLIBC__
|
||||
#if __GLIBC__
|
||||
// FIXME: This is ugly.
|
||||
strncpy(m_text, c, sizeof(m_text));
|
||||
#else
|
||||
strlcpy(m_text, c, sizeof(m_text));
|
||||
#endif
|
||||
m_expression = expression();
|
||||
m_layout = layout();
|
||||
if (m_expression != nullptr) {
|
||||
delete m_expression;
|
||||
}
|
||||
m_expression = Expression::parse(m_text);
|
||||
if (m_layout != nullptr) {
|
||||
delete m_layout;
|
||||
}
|
||||
m_layout = expression()->createLayout();
|
||||
}
|
||||
|
||||
void Graph::Function::setColor(KDColor color) {
|
||||
@@ -26,7 +32,6 @@ void Graph::Function::setColor(KDColor color) {
|
||||
}
|
||||
|
||||
Graph::Function::~Function() {
|
||||
//FIXME: Free m_text!
|
||||
if (m_layout != nullptr) {
|
||||
delete m_layout;
|
||||
}
|
||||
@@ -44,16 +49,10 @@ const char * Graph::Function::name() {
|
||||
}
|
||||
|
||||
Expression * Graph::Function::expression() {
|
||||
if (m_expression == nullptr) {
|
||||
m_expression = Expression::parse(m_text);
|
||||
}
|
||||
return m_expression;
|
||||
}
|
||||
|
||||
ExpressionLayout * Graph::Function::layout() {
|
||||
if (m_layout == nullptr) {
|
||||
m_layout = expression()->createLayout();
|
||||
}
|
||||
return m_layout;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user