git » kwindowsystem.git » commit 3134f37

Fix Kobi crash (FS#43621) (KDEBUG#337626)

author Andrea Scarpino
2015-01-29 10:36:10 UTC
committer Andrea Scarpino
2015-01-29 10:36:10 UTC
parent 8727d107438f180ca78d9c07e0193cf8c2f82771

Fix Kobi crash (FS#43621) (KDEBUG#337626)

PKGBUILD +5 -3
kdebug-337626.patch +49 -0

diff --git a/PKGBUILD b/PKGBUILD
index 4514e5a..fc89c3f 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,7 +2,7 @@
 
 pkgname=kwindowsystem
 pkgver=5.6.0
-pkgrel=2
+pkgrel=3
 pkgdesc='Access to the windowing system'
 arch=('i686' 'x86_64')
 url='https://projects.kde.org/projects/frameworks/kwindowsystem'
@@ -11,15 +11,17 @@ depends=('qt5-x11extras' 'libxfixes')
 makedepends=('extra-cmake-modules' 'qt5-tools')
 groups=('kf5')
 source=("http://download.kde.org/stable/frameworks/${pkgver%.*}/${pkgname}-${pkgver}.tar.xz"
-        'kdebug-340348.patch')
+        'kdebug-340348.patch' 'kdebug-337626.patch')
 md5sums=('bcfa5cd27b2735ffb26379b24b437190'
-         '464d5aefb97a2bcb3395d2a6239f670a')
+         '464d5aefb97a2bcb3395d2a6239f670a'
+         'e8c9ffc08782f99cdb88a706c4496f29')
 
 prepare() {
   mkdir build
 
   cd ${pkgname}-${pkgver}
   patch -p1 -i "${srcdir}"/kdebug-340348.patch
+  patch -p1 -i "${srcdir}"/kdebug-337626.patch
 }
 
 build() {
diff --git a/kdebug-337626.patch b/kdebug-337626.patch
new file mode 100644
index 0000000..781b739
--- /dev/null
+++ b/kdebug-337626.patch
@@ -0,0 +1,49 @@
+commit 9dbb47b07d4b4ec1e3e46098f955d36a318794bb
+Author: Thomas Lübking <thomas.luebking@gmail.com>
+Date:   Mon Nov 17 20:06:20 2014 +0100
+
+    ensure to keep image data alive w/ the image
+    
+    raster QPixmaps re-use the image data (implicitly shared)
+    deleting them w/ scope will thus cause invalidated
+    memory in the returned pixmap
+    
+    BUG: 337626
+    REVIEW: 121158
+
+diff --git a/src/kxutils.cpp b/src/kxutils.cpp
+index 44885e0..c75c08e 100644
+--- a/src/kxutils.cpp
++++ b/src/kxutils.cpp
+@@ -107,19 +107,14 @@ template <typename T> T fromNative(xcb_pixmap_t pixmap)
+     case 30: {
+         // Qt doesn't have a matching image format. We need to convert manually
+         uint32_t *pixels = reinterpret_cast<uint32_t *>(xcb_get_image_data(xImage.data()));
+-        for (int i = 0; i < xImage.data()->length; ++i) {
++        for (uint i = 0; i < xImage.data()->length; ++i) {
+             int r = (pixels[i] >> 22) & 0xff;
+             int g = (pixels[i] >> 12) & 0xff;
+             int b = (pixels[i] >>  2) & 0xff;
+ 
+             pixels[i] = qRgba(r, g, b, 0xff);
+         }
+-        QImage image(reinterpret_cast<uchar *>(pixels), geo->width, geo->height,
+-                     xcb_get_image_data_length(xImage.data()) / geo->height, QImage::Format_ARGB32_Premultiplied);
+-        if (image.isNull()) {
+-            return T();
+-        }
+-        return T::fromImage(image);
++        // fall through, Qt format is still Format_ARGB32_Premultiplied
+     }
+     case 32:
+         format = QImage::Format_ARGB32_Premultiplied;
+@@ -136,7 +131,8 @@ template <typename T> T fromNative(xcb_pixmap_t pixmap)
+         }
+     }
+     QImage image(xcb_get_image_data(xImage.data()), geo->width, geo->height,
+-                 xcb_get_image_data_length(xImage.data()) / geo->height, format);
++                 xcb_get_image_data_length(xImage.data()) / geo->height, format, free, xImage.data());
++    xImage.take();
+     if (image.isNull()) {
+         return T();
+     }