From cdb840d2008e97b2ade05cdd4695562cb6fd0486 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Sun, 27 Apr 2008 22:34:24 +0000 Subject: [PATCH] Print warnings if trying to assign invalid sizes to a panel or trying to generate a panel background with an invalid size. Prevents attempts to paint on an invalid pixmap leading to XRender errors. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=801852 --- panelsvg.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/panelsvg.cpp b/panelsvg.cpp index d7259c671..c13607c5b 100644 --- a/panelsvg.cpp +++ b/panelsvg.cpp @@ -194,7 +194,10 @@ QString PanelSvg::prefix() void PanelSvg::resizePanel(const QSizeF& size) { - if (!size.isValid() || size.width() < 1 || size.height() < 1 || size == d->panels[d->prefix]->panelSize) { + bool sizeValid = size.width() > 0 && size.height() > 0; + if (!sizeValid || size == d->panels[d->prefix]->panelSize) { + if (!sizeValid) + kWarning() << "Invalid size" << size; return; } @@ -298,6 +301,11 @@ void PanelSvg::Private::generateBackground(PanelData *panel) if (panel->cachedBackground) { return; } + if (!panel->panelSize.isValid()) { + kWarning() << "Invalid panel size" << panel->panelSize; + panel->cachedBackground = new QPixmap(); + return; + } const int contentWidth = panel->panelSize.width() - panel->leftWidth - panel->rightWidth; const int contentHeight = panel->panelSize.height() - panel->topHeight - panel->bottomHeight;