Do not abort if the Aurorae theme could not be loaded. So a missing theme will result in a translucent decoration and not in a crashing kwin.

svn path=/trunk/KDE/kdebase/workspace/; revision=1068533
icc-effect-5.14.5
Martin Gräßlin 2010-01-01 12:47:48 +00:00
parent 82093ae630
commit c92e314c9f
2 changed files with 16 additions and 4 deletions

View File

@ -36,6 +36,7 @@ namespace Aurorae
AuroraeFactory::AuroraeFactory()
: QObject()
, KDecorationFactoryUnstable()
, m_valid(false)
{
init();
}
@ -55,7 +56,7 @@ void AuroraeFactory::init()
}
if (path.isEmpty()) {
kDebug(1216) << "Could not find decoration svg: aborting";
abort();
return;
}
m_frame.setImagePath(path);
m_frame.setCacheAllRenderedFrames(true);
@ -73,6 +74,7 @@ void AuroraeFactory::init()
initButtonFrame("help");
readThemeConfig();
m_valid = true;
}
void AuroraeFactory::readThemeConfig()
@ -263,7 +265,7 @@ void AuroraeButton::animationFinished(int id)
void AuroraeButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
if (decoration()->isPreview()) {
if (decoration()->isPreview() || !AuroraeFactory::instance()->isValid()) {
return;
}
@ -557,6 +559,9 @@ bool AuroraeClient::decorationBehaviour(DecorationBehaviour behavior) const
int AuroraeClient::layoutMetric(LayoutMetric lm, bool respectWindowState,
const KCommonDecorationButton *button) const
{
if (!AuroraeFactory::instance()->isValid()) {
return KCommonDecoration::layoutMetric(lm, respectWindowState, button);
}
bool maximized = maximizeMode() == MaximizeFull &&
!options()->moveResizeMaximizedWindows();
const ThemeConfig &conf = AuroraeFactory::instance()->themeConfig();
@ -725,7 +730,7 @@ KCommonDecorationButton *AuroraeClient::createButton(ButtonType type)
void AuroraeClient::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
if (isPreview()) {
if (isPreview() || !AuroraeFactory::instance()->isValid()) {
return;
}
bool maximized = maximizeMode() == MaximizeFull &&
@ -843,6 +848,9 @@ void AuroraeClient::generateTextPixmap(QPixmap& pixmap, bool active)
{
QPainter painter(&pixmap);
pixmap.fill(Qt::transparent);
if (!AuroraeFactory::instance()->isValid()) {
return;
}
const ThemeConfig &conf = AuroraeFactory::instance()->themeConfig();
painter.setFont(options()->font(active));
if (conf.useTextShadow()) {
@ -900,7 +908,7 @@ void AuroraeClient::updateWindowShape()
int w=widget()->width();
int h=widget()->height();
if (maximized || compositingActive()) {
if (maximized || compositingActive() || !AuroraeFactory::instance()->isValid()) {
QRegion mask(0,0,w,h);
setMask(mask);
return;

View File

@ -50,6 +50,9 @@ public:
ThemeConfig &themeConfig() {
return m_themeConfig;
}
bool isValid() const {
return m_valid;
}
private:
AuroraeFactory();
@ -68,6 +71,7 @@ private:
// buttons
QHash< QString, Plasma::FrameSvg* > m_buttons;
bool m_valid;
};
class AuroraeButton : public KCommonDecorationButton