Bug 273848 - Oxygen style does not draw QDockWidgets correctly if they are detached
Summary: Oxygen style does not draw QDockWidgets correctly if they are detached
Status: RESOLVED FIXED
Alias: None
Product: Oxygen
Classification: Plasma
Component: style (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Hugo Pereira Da Costa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-22 14:33 UTC by Thomas Fischer
Modified: 2011-07-05 13:25 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Minimal example of a program with a QDockWidget and a KPart inside (1.45 KB, application/octet-stream)
2011-05-22 14:33 UTC, Thomas Fischer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Fischer 2011-05-22 14:33:58 UTC
Created attachment 60213 [details]
Minimal example of a program with a QDockWidget and a KPart inside

Version:           unspecified (using KDE 4.6.3) 
OS:                Linux

Based on this bugreport for KBibTeX (https://gna.org/bugs/?18141), I came across the following problem: Using a QDockWidget in a window and having a KPart inside this widget, the KPart is no longer drawn when the dock widget is detached. Re-attaching the docklet makes the widget reappear. Even if the widget is detached and not drawn, mouse and keyboard input is still working.

This problem does not happen with any other Qt/KDE style like QtCurve or Plastique. Therefore, I assume it is directly related to Oxygen.

On the command line, I get errors like this (repeated multiple times):
X Error: BadMatch (invalid parameter attributes) 8
  Extension:    142 (MIT-SHM)
  Minor opcode: 3 (X_ShmPutImage)
  Resource id:  0x5600053

I wrote a small example program (attached to this report), which I ran through valgrind. I got, among others, output like this:

==5843== Invalid read of size 8
==5843==    at 0x4ABB32A: qt_blend_argb32_on_argb32_ssse3(unsigned char*, int, unsigned char const*, int, int, int, int) (emmintrin.h:679)
==5843==    by 0x4CCFA0B: QRasterPaintEnginePrivate::drawImage(QPointF const&, QImage const&, void (*)(unsigned char*, int, unsigned char const*, int, int, int, int), QRect const&, int, QRect const&) (qpaintengine_raster.cpp:1070)
==5843==    by 0x4CD16F3: QRasterPaintEngine::drawImage(QPointF const&, QImage const&) (qpaintengine_raster.cpp:2516)
==5843==    by 0x4CDC7AD: QRasterPaintEngine::drawPixmap(QPointF const&, QPixmap const&) (qpaintengine_raster.cpp:2391)
==5843==    by 0x4C44235: QPainter::drawPixmap(QPointF const&, QPixmap const&) (qpainter.cpp:5263)
==5843==    by 0x7DD318F: ??? (in /usr/lib/kde4/plugins/styles/oxygen.so)
==5843==    by 0x7DB35A0: ??? (in /usr/lib/kde4/plugins/styles/oxygen.so)
==5843==    by 0x59A5092: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (qmetaobject.cpp:237)
==5843==    by 0x59A7E2B: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (qmetaobject.cpp:1578)
==5843==    by 0x59A9238: QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) (qmetaobject.cpp:1151)
==5843==    by 0x4E32F72: QStyle::standardIcon(QStyle::StandardPixmap, QStyleOption const*, QWidget const*) const (qstyle.cpp:2279)
==5843==    by 0x4F2F2E3: QDockWidgetPrivate::updateButtons() (qdockwidget.cpp:669)
==5843==  Address 0xa1ea810 is 896 bytes inside a block of size 900 alloc'd
==5843==    at 0x4025E85: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==5843==    by 0x4BA10C6: QImageData::create(QSize const&, QImage::Format, int) (qimage.cpp:243)
==5843==    by 0x4BA1507: QImage::QImage(int, int, QImage::Format) (qimage.cpp:843)
==5843==    by 0x4BD430C: QRasterPixmapData::fill(QColor const&) (qpixmap_raster.cpp:211)
==5843==    by 0x4BC34C3: QPixmap::fill(QColor const&) (qpixmap.cpp:1002)
==5843==    by 0x7DDBD18: ??? (in /usr/lib/kde4/plugins/styles/oxygen.so)
==5843==    by 0x7DD314A: ??? (in /usr/lib/kde4/plugins/styles/oxygen.so)
==5843==    by 0x7DB35A0: ??? (in /usr/lib/kde4/plugins/styles/oxygen.so)
==5843==    by 0x59A5092: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (qmetaobject.cpp:237)
==5843==    by 0x59A7E2B: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (qmetaobject.cpp:1578)
==5843==    by 0x59A9238: QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) (qmetaobject.cpp:1151)
==5843==    by 0x4E32F72: QStyle::standardIcon(QStyle::StandardPixmap, QStyleOption const*, QWidget const*) const (qstyle.cpp:2279)

==5843== Invalid read of size 4
==5843==    at 0x4F4855D: QFrame::frameStyle() const (qframe.cpp:252)
==5843==    by 0x7DBC846: ??? (in /usr/lib/kde4/plugins/styles/oxygen.so)
==5843==    by 0x4B2591F: QWidget::event(QEvent*) (qwidget.cpp:8345)
==5843==    by 0x4AC437E: QApplicationPrivate::notify_helper(QObject*, QEvent*) (qapplication.cpp:4462)
==5843==    by 0x4ACC1BB: QApplication::notify(QObject*, QEvent*) (qapplication.cpp:4427)
==5843==    by 0x47A0374: KApplication::notify(QObject*, QEvent*) (kapplication.cpp:311)
==5843==    by 0x599DB24: QCoreApplication::notifyInternal(QObject*, QEvent*) (qcoreapplication.cpp:731)
==5843==    by 0x4B1BA58: QWidget::ensurePolished() const (qcoreapplication.h:215)
==5843==    by 0x4B2A17E: QWidget::setVisible(bool) (qwidget.cpp:7611)
==5843==    by 0xC07476C: QWidget::show() (qwidget.h:487)
==5843==    by 0xC15EFD3: KateViewInternal::KateViewInternal(KateView*) (kateviewinternal.cpp:144)
==5843==    by 0xC14D391: KateView::KateView(KateDocument*, QWidget*) (kateview.cpp:135)
==5843==  Address 0x9b60b7c is not stack'd, malloc'd or (recently) free'd



Reproducible: Always




I am using KDE 4.6.3 and Qt 4.7.3 on Gentoo Linux.
Comment 1 Hugo Pereira Da Costa 2011-05-22 20:17:11 UTC
this is due to the

  widget->setAttribute( Qt::WA_TranslucentBackground );

flag set on QDockWidgets by oxygen, in order to have use alpha channel to get nice rounded corners.

Interestingly, the issue does not happen with oxygen-transparent.
So I believe this is due to some inconsitency in widget depth, when reparenting widgets (from non argb attached dock to argb detached dock), which does not occur when both (attached and detached) are argb.

Makes sense ? 

Now I wonder why it only happens with ktextedit and not, e.g. in dolphin.
Comment 2 Hugo Pereira Da Costa 2011-05-24 17:18:54 UTC
Still investigating (both Oxygen and KateView code), and so far I'm quite at a loss about what's going wrong. 

Any chance that you install oxygen's debug symbol (I guess they come with kde4-workspace), so that lines like: 

==5843==    by 0x7DD318F: ??? (in /usr/lib/kde4/plugins/styles/oxygen.so)

become more informative ? 

Thanks in advance,

Hugo

(oh well, I guess I can run Valgrind on my side too)
Comment 3 Hugo Pereira Da Costa 2011-05-24 17:29:12 UTC
Ok. None of the "invalid" read of your valgrind report show up in mine. 

I believe this is because I'm not using raster engine, and yet, I have the same bug as you. So that the valgrind report might well be unrelated :(
Comment 4 Hugo Pereira Da Costa 2011-05-25 11:20:40 UTC
Some additional info:

at least here, 

setenv XLIB_SKIP_ARGB_VISUALS 1
(or set XLIB_SKIP_ARGB_VISUALS=1)

fixes the issue. Can you confirm ? 

So definitly something ARGB related. 
Still: why only KateView (the embeded editor) ? 

Also, I really think it is an "upstream" bug, triggered by Oxygen (more precisely, by the fact that the "main" window does not have the WA_TranslucentBackground flag set, and that the "detached" Dock widget has.

So, either Qt or Kate. 
Can you post a bug report to either (or both), passing them a link to this one and keeping me in the loop ? Maybe we could get more inputs on the issue, since so far I have been unable to fix this on my own. 

(And I'd really like to avoid removing the WA_TranslucentBackground flag from detached docks, cause they look quite ugly without it. And that would just be a workaround, not an actual bug fix).

Thanks in advance,

Hugo
Comment 5 Thomas Fischer 2011-05-31 10:49:15 UTC
> setenv XLIB_SKIP_ARGB_VISUALS 1
> (or set XLIB_SKIP_ARGB_VISUALS=1)
> 
> fixes the issue. Can you confirm ? 
Yes, I can confirm.

> So definitly something ARGB related. 
> Still: why only KateView (the embeded editor) ?
I had the same problem with Okular's part in KBibTeX. In the example for this bug report I used Kate's part for simplicity reasons.
Try to change the example program to view a PDF file.

> So, either Qt or Kate.
I guess, Qt or KParts (or whatever else Okular and Kate have in common).

> Can you post a bug report to either (or both), passing them a link to this one
> and keeping me in the loop ? Maybe we could get more inputs on the issue, since
> so far I have been unable to fix this on my own. 
I will test Okular in my example program before filing a bug for Kate, as it may not be Kate specific.

Thanks for your help!

P.S. Do you mind setting the bug status to NEEDSINFO or VERIFIED? I cannot do it and the bug exists (so it is confirmed, but not located).
Comment 6 Hugo Pereira Da Costa 2011-05-31 17:40:28 UTC
Well could not see "Verified" in the list, but changed the status to "Assigned" (to me :))

Thanks for the feedback on kpart. I'll investigate this code too as soon as I have time. (I was looking in kate's code before).

Will keep you posted.

Hugo
Comment 7 Hugo Pereira Da Costa 2011-06-08 11:42:02 UTC
Thomas, do you have an updated version of your test code with okular part at hand, for me to test further ? 

Thanks in advance,

Hugo
Comment 8 Thomas Fischer 2011-06-14 23:40:51 UTC
(In reply to comment #7)
> Thomas, do you have an updated version of your test code with okular part at
> hand, for me to test further ? 
I tried to expand my test program to use Okular's part, but then I cannot reproduce the error any longer.
You may want to give KBibTeX a try (installing LaTeX or BibTeX is not a requirement):
http://home.gna.org/kbibtex/download.html#svn

Save the following BibTeX snipplet as kde.bib using a normal text editor:

@article{test,
url={http://www.kde.org},
pdf={http://ev.kde.org/rules/supporting_members.pdf}
}

After starting KBibTeX, ensure that the "Document Preview" is visible on the right side (make it visible via Settings->Show Panels). Open kde.bib and select the single entry. Either the webpage or the PDF file should be loaded in the preview. Drag the docklet to make it a window of its own. The content turns solid gray/blank.

At least in my case and for the original bug report this is a reproducible way to get this error.
Comment 9 Hugo Pereira Da Costa 2011-06-14 23:52:23 UTC
> Save the following BibTeX snipplet as kde.bib using a normal text editor:
>
> @article{test,
> url={http://www.kde.org},
> pdf={http://ev.kde.org/rules/supporting_members.pdf}
> }
Thanks !
I did try kbibtex, since I'm a regular latex/bibtex user, but so far was 
unable to find a dock with a pdf viewer inside. Your instructions will 
help. Will keep you posted !
Comment 10 Philipp A. 2011-06-23 15:56:54 UTC
got that too when trying to embed a katepart into an editor.
Comment 11 Hugo Pereira Da Costa 2011-07-04 09:29:50 UTC
just to keep you posted:
I could reproduce the issue with kbibtex.
Am working on it, and have a (robust) solution at hand, it is just a question of testing.

It will most likely make it to kde4.7.0
Comment 12 Hugo Pereira Da Costa 2011-07-04 10:25:55 UTC
Git commit 1d53154f55d9d9e97ba75a9dab92b0a9e430de0a by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 11:09.
Pushed by hpereiradacosta into branch 'master'.

do not set translucent background on dock widgets.
CCBUG: 273848

M  +25   -19   kstyles/oxygen/oxygenstyle.cpp     

http://commits.kde.org/kde-workspace/1d53154f55d9d9e97ba75a9dab92b0a9e430de0a
Comment 13 Hugo Pereira Da Costa 2011-07-04 10:25:55 UTC
Git commit e84a0b5f521b15f2fb4caf2b884f351b47804060 by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 11:23.
Pushed by hpereiradacosta into branch 'master'.

cleanup commented code
CCBUG: 273848

M  +0    -14   kstyles/oxygen/oxygenstyle.cpp     

http://commits.kde.org/kde-workspace/e84a0b5f521b15f2fb4caf2b884f351b47804060
Comment 14 Hugo Pereira Da Costa 2011-07-04 10:25:55 UTC
Git commit 785ae16c4c5661d4ea5c2e6768fd8c0112069b4c by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 12:01.
Pushed by hpereiradacosta into branch 'master'.

fixed colors to ::roundCorner gradient.
CCBUG: 273848

M  +3    -3    kstyles/oxygen/oxygenstylehelper.cpp     

http://commits.kde.org/kde-workspace/785ae16c4c5661d4ea5c2e6768fd8c0112069b4c
Comment 15 Hugo Pereira Da Costa 2011-07-04 10:25:56 UTC
Git commit c7eb8290502b0f9ab998738b0d171dba8e7863dd by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 12:24.
Pushed by hpereiradacosta into branch 'master'.

store independent pixmap handles for dock widgets, to paint corners on it.
CCBUG: 273848

M  +39   -15   kstyles/oxygen/oxygenshadowhelper.cpp     
M  +9    -3    kstyles/oxygen/oxygenshadowhelper.h     

http://commits.kde.org/kde-workspace/c7eb8290502b0f9ab998738b0d171dba8e7863dd
Comment 16 Hugo Pereira Da Costa 2011-07-04 10:28:45 UTC
ok. Commits shown in comments #12 to #15 should fix it.
Tested on test program and kbibtex, there seem to be no issue.

I'll test on it with trunk for a couple of days, and if no issues shows I'll backport to kde4.7

Feedback welcome, if you're running on trunk and have a chance to update.

Cheers,

Hugo
Comment 17 Hugo Pereira Da Costa 2011-07-05 13:22:48 UTC
Git commit fd276e27a8796f074c27381094e317a768fc4ad2 by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 11:23.
Pushed by hpereiradacosta into branch 'KDE/4.7'.

cleanup commented code
CCBUG: 273848

M  +0    -14   kstyles/oxygen/oxygenstyle.cpp     

http://commits.kde.org/kde-workspace/fd276e27a8796f074c27381094e317a768fc4ad2
Comment 18 Hugo Pereira Da Costa 2011-07-05 13:22:48 UTC
Git commit 2d4a6cb1f8b5e576391837dca7b19ad0773f0562 by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 12:24.
Pushed by hpereiradacosta into branch 'KDE/4.7'.

store independent pixmap handles for dock widgets, to paint corners on it.
CCBUG: 273848

M  +39   -15   kstyles/oxygen/oxygenshadowhelper.cpp     
M  +9    -3    kstyles/oxygen/oxygenshadowhelper.h     

http://commits.kde.org/kde-workspace/2d4a6cb1f8b5e576391837dca7b19ad0773f0562
Comment 19 Hugo Pereira Da Costa 2011-07-05 13:22:48 UTC
Git commit 8d2214883b28db1d5269c78a8f9d445a6a0928ff by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 12:02.
Pushed by hpereiradacosta into branch 'KDE/4.7'.

added "roundCorner" to shadows passed to kwin. This allows to use mask for detached dockwidgets, and still have nice
bevelled corners.
CCBUG: 273848

M  +11   -2    kstyles/oxygen/oxygenshadowhelper.cpp     
M  +5    -2    kstyles/oxygen/oxygenshadowhelper.h     

http://commits.kde.org/kde-workspace/8d2214883b28db1d5269c78a8f9d445a6a0928ff
Comment 20 Hugo Pereira Da Costa 2011-07-05 13:22:48 UTC
Git commit 599085676d3d7bdbabe67b15e6408c84e293519b by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 11:09.
Pushed by hpereiradacosta into branch 'KDE/4.7'.

do not set translucent background on dock widgets.
CCBUG: 273848

M  +25   -19   kstyles/oxygen/oxygenstyle.cpp     

http://commits.kde.org/kde-workspace/599085676d3d7bdbabe67b15e6408c84e293519b
Comment 21 Hugo Pereira Da Costa 2011-07-05 13:22:48 UTC
Git commit 3f26cbc80ca8a78bdccb591e52b7c088b8529c07 by Hugo Pereira Da Costa.
Committed on 04/07/2011 at 12:01.
Pushed by hpereiradacosta into branch 'KDE/4.7'.

fixed colors to ::roundCorner gradient.
CCBUG: 273848

M  +3    -3    kstyles/oxygen/oxygenstylehelper.cpp     

http://commits.kde.org/kde-workspace/3f26cbc80ca8a78bdccb591e52b7c088b8529c07
Comment 22 Hugo Pereira Da Costa 2011-07-05 13:25:20 UTC
worked fine after a day or so of testing (no regression for other widgets), so I backported and close the bug.

Feel free to re-open if anything is still not correct.