catch some m_item nullptr accesses

BUG: 318941
FIXED-IN: 4.10.3
REVIEW: 110254
This commit is contained in:
Thomas Lübking 2013-05-01 13:25:59 +02:00
parent 52a831d89f
commit 4794cce5e5

View file

@ -242,8 +242,10 @@ AuroraeClient::AuroraeClient(KDecorationBridge *bridge, KDecorationFactory *fact
AuroraeClient::~AuroraeClient() AuroraeClient::~AuroraeClient()
{ {
m_item->setParent(NULL); if (m_item) {
m_item->deleteLater(); m_item->setParent(NULL);
m_item->deleteLater();
}
m_scene->setParent(NULL); m_scene->setParent(NULL);
m_scene->deleteLater(); m_scene->deleteLater();
m_view->setParent(NULL); m_view->setParent(NULL);
@ -276,7 +278,8 @@ void AuroraeClient::init()
QPalette pal2 = widget()->palette(); QPalette pal2 = widget()->palette();
pal2.setColor(widget()->backgroundRole(), Qt::transparent); pal2.setColor(widget()->backgroundRole(), Qt::transparent);
widget()->setPalette(pal2); widget()->setPalette(pal2);
m_scene->addItem(m_item); if (m_item)
m_scene->addItem(m_item);
slotAlphaChanged(); slotAlphaChanged();
AuroraeFactory::instance()->theme()->setCompositingActive(compositingActive()); AuroraeFactory::instance()->theme()->setCompositingActive(compositingActive());
@ -505,10 +508,12 @@ void AuroraeClient::themeChanged()
{ {
m_scene->clear(); m_scene->clear();
m_item = AuroraeFactory::instance()->createQmlDecoration(this); m_item = AuroraeFactory::instance()->createQmlDecoration(this);
if (m_item) { if (!m_item) {
m_item->setWidth(m_scene->sceneRect().width()); return;
m_item->setHeight(m_scene->sceneRect().height());
} }
m_item->setWidth(m_scene->sceneRect().width());
m_item->setHeight(m_scene->sceneRect().height());
m_scene->addItem(m_item); m_scene->addItem(m_item);
connect(m_item, SIGNAL(alphaChanged()), SLOT(slotAlphaChanged())); connect(m_item, SIGNAL(alphaChanged()), SLOT(slotAlphaChanged()));
slotAlphaChanged(); slotAlphaChanged();
@ -565,6 +570,10 @@ QVariant AuroraeClient::readConfig(const QString &key, const QVariant &defaultVa
void AuroraeClient::slotAlphaChanged() void AuroraeClient::slotAlphaChanged()
{ {
if (!m_item) {
setAlphaEnabled(false);
return;
}
QVariant alphaProperty = m_item->property("alpha"); QVariant alphaProperty = m_item->property("alpha");
if (alphaProperty.isValid() && alphaProperty.canConvert<bool>()) { if (alphaProperty.isValid() && alphaProperty.canConvert<bool>()) {
setAlphaEnabled(alphaProperty.toBool()); setAlphaEnabled(alphaProperty.toBool());