[apps/graph] Handle undefined function

Change-Id: Id26e0f81ba5c1446655f33b2c63f97ab5b684e41
This commit is contained in:
Émilie Feral
2016-10-20 16:00:11 +02:00
parent 5693b9f95f
commit e5ff8f65c3
10 changed files with 66 additions and 18 deletions

View File

@@ -28,9 +28,13 @@ void FunctionNameView::drawRect(KDContext * ctx, KDRect rect) const {
KDColor background = backgroundColor();
// Position the name of the function
const char * functionName = m_function->name();
KDCoordinate baseline = m_function->layout()->baseline();
KDSize textSize = KDText::stringSize(functionName);
KDSize expressionSize = m_function->layout()->size();
KDCoordinate baseline = textSize.height();
KDSize expressionSize = textSize;
if (m_function->layout()) {
baseline = m_function->layout()->baseline();
expressionSize = m_function->layout()->size();
}
KDPoint origin(0.5f*(k_colorIndicatorThickness + m_frame.width() - 4*textSize.width()),
baseline-textSize.height()+0.5f*(m_frame.height() - expressionSize.height()));
ctx->drawString(functionName, origin, functionNameColor, background);