Commit 4830d8b4 authored by Ralf Habacker's avatar Ralf Habacker

Add UMLScene::getBackgroundColor() as common method to fetch the current scene background color.

This patch helps to avoid a crash caused by UMLScene::activeView() returning zero, which happens
while tracking this bug.

CCBUG:344975
parent 971d5c1c
......@@ -1252,6 +1252,17 @@ void UMLScene::removeWidgetCmd(UMLWidget * o)
m_doc->setModified(true);
}
/**
* Returns background color
*/
const QColor& UMLScene::backgroundColor() const
{
if (activeView())
return activeView()->viewport()->palette().color(QPalette::Background);
else
return m_Options.uiState.backgroundColor;
}
/**
* Returns whether to use the fill/background color
*/
......
......@@ -115,6 +115,8 @@ public:
const QColor& gridDotColor() const;
void setGridDotColor(const QColor& color);
const QColor& backgroundColor() const;
bool snapToGrid() const;
void setSnapToGrid(bool bSnap);
......
......@@ -49,7 +49,7 @@ void ArtifactWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
if (UMLWidget::useFillColor()) {
painter->setBrush(UMLWidget::fillColor());
} else {
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
}
if (umlObject()) {
......
......@@ -662,9 +662,9 @@ void ClassifierWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *
setPenFromSettings(painter);
if (UMLWidget::useFillColor())
painter->setBrush(UMLWidget::fillColor());
else
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
else {
painter->setBrush(m_scene->backgroundColor());
}
if (m_umlObject->baseType() == UMLObject::ot_Package) {
drawAsPackage(painter, option);
UMLWidget::paint(painter, option, widget);
......
......@@ -68,7 +68,7 @@ void ComponentWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
if (UMLWidget::useFillColor()) {
painter->setBrush(UMLWidget::fillColor());
} else {
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
}
const int w = width();
......
......@@ -51,7 +51,7 @@ void DatatypeWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
if (UMLWidget::useFillColor()) {
painter->setBrush(UMLWidget::fillColor());
} else {
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
}
int w = width();
......
......@@ -58,7 +58,7 @@ void EntityWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
if(UMLWidget::useFillColor())
painter->setBrush(UMLWidget::fillColor());
else
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
const int w = width();
const int h = height();
......
......@@ -99,7 +99,7 @@ void EnumWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
if(UMLWidget::useFillColor())
painter->setBrush(UMLWidget::fillColor());
else
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
const int w = width();
const int h = height();
......
......@@ -55,7 +55,7 @@ void NodeWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
if (UMLWidget::useFillColor()) {
painter->setBrush(UMLWidget::fillColor());
} else {
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
}
const int w = width();
const int h = height();
......
......@@ -415,7 +415,7 @@ void ObjectWidget::paintObject(QPainter *painter)
if(UMLWidget::useFillColor())
painter->setBrush(UMLWidget::fillColor());
else
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
const int w = width();
const int h = height();
......
......@@ -62,7 +62,7 @@ void PackageWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
if (UMLWidget::useFillColor())
painter->setBrush(UMLWidget::fillColor());
else
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
int w = width();
int h = height();
......
......@@ -202,7 +202,7 @@ void PinPortBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
if (UMLWidget::useFillColor()) {
painter->setBrush(UMLWidget::fillColor());
} else {
painter->setBrush(m_scene->activeView()->viewport()->palette().color(QPalette::Background));
painter->setBrush(m_scene->backgroundColor());
}
int w = width();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment