Make sure we do not get references on temporary objects

icc-effect-5.26.4
Aleix Pol 2021-05-13 18:38:42 +02:00
parent f70256931c
commit 50dd08531e
8 changed files with 19 additions and 17 deletions

View File

@ -2612,7 +2612,8 @@ QRect AbstractClient::iconGeometry() const
AbstractClient *candidatePanel = nullptr;
QRect candidateGeom;
for (auto i = windowManagementInterface()->minimizedGeometries().constBegin(), end = windowManagementInterface()->minimizedGeometries().constEnd(); i != end; ++i) {
const auto minGeometries = windowManagementInterface()->minimizedGeometries();
for (auto i = minGeometries.constBegin(), end = minGeometries.constEnd(); i != end; ++i) {
AbstractClient *client = waylandServer()->findClient(i.key());
if (!client) {
continue;

View File

@ -295,7 +295,7 @@ void Workspace::activateClient(AbstractClient* c, bool force)
if (!c->isOnCurrentActivity()) {
++block_focus;
//DBUS!
Activities::self()->setCurrent(c->activities().first()); //first isn't necessarily best, but it's easiest
Activities::self()->setCurrent(c->activities().constFirst()); //first isn't necessarily best, but it's easiest
--block_focus;
}
#endif

View File

@ -2345,7 +2345,7 @@ void EffectFrameImpl::setIcon(const QIcon& icon)
m_sceneFrame->crossFadeIcon();
}
if (m_iconSize.isEmpty() && !m_icon.availableSizes().isEmpty()) { // Set a size if we don't already have one
setIconSize(m_icon.availableSizes().first());
setIconSize(m_icon.availableSizes().constFirst());
}
m_sceneFrame->freeIconFrame();
}

View File

@ -1837,7 +1837,7 @@ void PresentWindowsEffect::closeWindow()
EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, int ydiff, bool wrap) const
{
if (!w)
return m_motionManager.managedWindows().first();
return m_motionManager.managedWindows().constFirst();
// TODO: Is it possible to select hidden windows?
EffectWindow* next;

View File

@ -39,7 +39,7 @@ int main(int argc, char **argv)
KWinDecorationSettings *settings = new KWinDecorationSettings(&app);
QTextStream ts(stdout);
if (!parser->positionalArguments().isEmpty()) {
QString requestedTheme{parser->positionalArguments().first()};
QString requestedTheme{parser->positionalArguments().constFirst()};
if (requestedTheme.endsWith(QStringLiteral("/*"))) {
// Themes installed through KNewStuff will commonly be given an installed files entry
// which has the main directory name and an asterix to say the cursors are all in that directory,

View File

@ -449,7 +449,8 @@ void AbstractEglTexture::updateTexture(WindowPixmap *pixmap, const QRegion &regi
auto s = pixmap->surface();
if (EglDmabufBuffer *dmabuf = static_cast<EglDmabufBuffer *>(buffer->linuxDmabufBuffer())) {
q->bind();
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES) dmabuf->images()[0]); //TODO
auto images = dmabuf->images();
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES) images[0]); //TODO
q->unbind();
if (m_image != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(m_backend->eglDisplay(), m_image);
@ -589,7 +590,7 @@ bool AbstractEglTexture::loadEglTexture(const QPointer< KWaylandServer::BufferIn
bool AbstractEglTexture::loadDmabufTexture(const QPointer< KWaylandServer::BufferInterface > &buffer)
{
auto *dmabuf = static_cast<EglDmabufBuffer *>(buffer->linuxDmabufBuffer());
if (!dmabuf || dmabuf->images()[0] == EGL_NO_IMAGE_KHR) {
if (!dmabuf || dmabuf->images().isEmpty() || dmabuf->images().constFirst() == EGL_NO_IMAGE_KHR) {
qCritical(KWIN_OPENGL) << "Invalid dmabuf-based wl_buffer";
q->discard();
return false;
@ -601,7 +602,7 @@ bool AbstractEglTexture::loadDmabufTexture(const QPointer< KWaylandServer::Buffe
q->setWrapMode(GL_CLAMP_TO_EDGE);
q->setFilter(GL_NEAREST);
q->bind();
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES) dmabuf->images()[0]);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES) dmabuf->images().constFirst());
q->unbind();
m_size = dmabuf->size();

View File

@ -958,14 +958,14 @@ void SceneXRenderShadow::layoutShadowRects(QRect& top, QRect& topRight,
return;
}
WindowQuad topQuad = quads.select(WindowQuadShadowTop)[0];
WindowQuad topRightQuad = quads.select(WindowQuadShadowTopRight)[0];
WindowQuad topLeftQuad = quads.select(WindowQuadShadowTopLeft)[0];
WindowQuad leftQuad = quads.select(WindowQuadShadowLeft)[0];
WindowQuad rightQuad = quads.select(WindowQuadShadowRight)[0];
WindowQuad bottomQuad = quads.select(WindowQuadShadowBottom)[0];
WindowQuad bottomRightQuad = quads.select(WindowQuadShadowBottomRight)[0];
WindowQuad bottomLeftQuad = quads.select(WindowQuadShadowBottomLeft)[0];
WindowQuad topQuad = quads.select(WindowQuadShadowTop).constFirst();
WindowQuad topRightQuad = quads.select(WindowQuadShadowTopRight).constFirst();
WindowQuad topLeftQuad = quads.select(WindowQuadShadowTopLeft).constFirst();
WindowQuad leftQuad = quads.select(WindowQuadShadowLeft).constFirst();
WindowQuad rightQuad = quads.select(WindowQuadShadowRight).constFirst();
WindowQuad bottomQuad = quads.select(WindowQuadShadowBottom).constFirst();
WindowQuad bottomRightQuad = quads.select(WindowQuadShadowBottomRight).constFirst();
WindowQuad bottomLeftQuad = quads.select(WindowQuadShadowBottomLeft).constFirst();
top = QRect(topQuad.left(), topQuad.top(), (topQuad.right()-topQuad.left()), (topQuad.bottom()-topQuad.top()));
topLeft = QRect(topLeftQuad.left(), topLeftQuad.top(), (topLeftQuad.right()-topLeftQuad.left()), (topLeftQuad.bottom()-topLeftQuad.top()));

View File

@ -89,7 +89,7 @@ int main(int argc, char **argv)
}
bool ok = false;
const auto shadow = readShadow(parser.positionalArguments().first().toULongLong(&ok, 16));
const auto shadow = readShadow(parser.positionalArguments().constFirst().toULongLong(&ok, 16));
if (!ok) {
qDebug() << "!!! Failed to read window id";
return 1;