Merge lp:~aacid/ubuntu-ui-toolkit/betterConnectForAboutToBeDestroyed into lp:ubuntu-ui-toolkit/staging

Proposed by Albert Astals Cid on 2015-08-19
Status: Merged
Approved by: Zsombor Egri on 2015-08-19
Approved revision: 1613
Merged at revision: 1613
Proposed branch: lp:~aacid/ubuntu-ui-toolkit/betterConnectForAboutToBeDestroyed
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 44 lines (+4/-12)
2 files modified
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+4/-11)
src/Ubuntu/Components/plugin/ucubuntushape.h (+0/-1)
To merge this branch: bzr merge lp:~aacid/ubuntu-ui-toolkit/betterConnectForAboutToBeDestroyed
Reviewer Review Type Date Requested Status
Zsombor Egri (community) 2015-08-19 Approve on 2015-08-19
PS Jenkins bot continuous-integration Approve on 2015-08-19
Review via email: mp+268454@code.launchpad.net

Commit Message

Properly free shapeTextures[index]

The old code assumes that the UbuntuShape will still be around when the opengl context is destroyed, but that seldom happens so connect the signal to a lambda that will be there and does the cleanup properly

Without this patch testDirectionalDragArea from unity8 was hitting the qFatal because it ran out of space in shapeTextures

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
2--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-12 10:15:43 +0000
3+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-19 10:04:29 +0000
4@@ -984,15 +984,6 @@
5 updateFromImageProperties(qobject_cast<QQuickItem*>(sender()));
6 }
7
8-void UCUbuntuShape::_q_openglContextDestroyed()
9-{
10- // Delete the shape textures that are stored per context and shared by all the shape items.
11- const int index = getShapeTexturesIndex(qobject_cast<QOpenGLContext*>(sender()));
12- Q_ASSERT(index >= 0);
13- shapeTextures[index].openglContext = NULL;
14- glDeleteTextures(shapeTextureCount, shapeTextures[index].textureId);
15-}
16-
17 void UCUbuntuShape::_q_gridUnitChanged()
18 {
19 const float gridUnitInDevicePixels = UCUnits::instance().gridUnit() / qGuiApp->devicePixelRatio();
20@@ -1145,8 +1136,10 @@
21 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shapeTextureSize, shapeTextureSize, 0, GL_RGBA,
22 GL_UNSIGNED_BYTE, shapeTextureData[i]);
23 }
24- QObject::connect(openglContext, SIGNAL(aboutToBeDestroyed()), this,
25- SLOT(_q_openglContextDestroyed()), Qt::DirectConnection);
26+ connect(openglContext, &QOpenGLContext::aboutToBeDestroyed, [index] {
27+ shapeTextures[index].openglContext = NULL;
28+ glDeleteTextures(shapeTextureCount, shapeTextures[index].textureId);
29+ } );
30 }
31 const quint32 shapeTextureId = shapeTextures[index].textureId[m_aspect != DropShadow ? 0 : 1];
32
33
34=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.h'
35--- src/Ubuntu/Components/plugin/ucubuntushape.h 2015-08-06 13:16:24 +0000
36+++ src/Ubuntu/Components/plugin/ucubuntushape.h 2015-08-19 10:04:29 +0000
37@@ -296,7 +296,6 @@
38
39 private Q_SLOTS:
40 void _q_imagePropertiesChanged();
41- void _q_openglContextDestroyed();
42 void _q_gridUnitChanged();
43 void _q_providerDestroyed(QObject* object=0);
44 void _q_textureChanged();

Subscribers

People subscribed via source and target branches