[DialogShadows] Cache access to QX11Info::display()

It's called several times and even in a loop.

REVIEW: 127893
This commit is contained in:
Kai Uwe Broulik 2016-05-11 19:58:55 +02:00
parent e8c5ee60a8
commit e159643ec4

View File

@ -410,35 +410,38 @@ void DialogShadows::Private::freeX11Pixmaps()
if (!m_isX11) { if (!m_isX11) {
return; return;
} }
auto *display = QX11Info::display();
if (!display) {
return;
}
foreach (const QPixmap &pixmap, m_shadowPixmaps) { foreach (const QPixmap &pixmap, m_shadowPixmaps) {
if (!QX11Info::display()) {
return;
}
if (!pixmap.isNull()) { if (!pixmap.isNull()) {
XFreePixmap(QX11Info::display(), reinterpret_cast<unsigned long>(createPixmap(pixmap))); XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(pixmap)));
} }
} }
if (!m_emptyCornerPix.isNull()) { if (!m_emptyCornerPix.isNull()) {
XFreePixmap(QX11Info::display(), reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerPix))); XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerPix)));
} }
if (!m_emptyCornerBottomPix.isNull()) { if (!m_emptyCornerBottomPix.isNull()) {
XFreePixmap(QX11Info::display(), reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerBottomPix))); XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerBottomPix)));
} }
if (!m_emptyCornerLeftPix.isNull()) { if (!m_emptyCornerLeftPix.isNull()) {
XFreePixmap(QX11Info::display(), reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerLeftPix))); XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerLeftPix)));
} }
if (!m_emptyCornerRightPix.isNull()) { if (!m_emptyCornerRightPix.isNull()) {
XFreePixmap(QX11Info::display(), reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerRightPix))); XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerRightPix)));
} }
if (!m_emptyCornerTopPix.isNull()) { if (!m_emptyCornerTopPix.isNull()) {
XFreePixmap(QX11Info::display(), reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerTopPix))); XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(m_emptyCornerTopPix)));
} }
if (!m_emptyVerticalPix.isNull()) { if (!m_emptyVerticalPix.isNull()) {
XFreePixmap(QX11Info::display(), reinterpret_cast<unsigned long>(createPixmap(m_emptyVerticalPix))); XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(m_emptyVerticalPix)));
} }
if (!m_emptyHorizontalPix.isNull()) { if (!m_emptyHorizontalPix.isNull()) {
XFreePixmap(QX11Info::display(), reinterpret_cast<unsigned long>(createPixmap(m_emptyHorizontalPix))); XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(m_emptyHorizontalPix)));
} }
#endif #endif
} }