Bug 345553

Summary: QApplication::setPalette causes massive cpu load on KTextEditor::EditorPrivate::updateColorPalette
Product: [Frameworks and Libraries] frameworks-ktexteditor Reporter: Thomas Lübking <thomas.luebking>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Thomas Lübking 2015-03-26 16:08:20 UTC
Virtuality UI style swaps the palette of modal dialogs, for that purpose (to cover style sheet abuse... ;-) it needs to temporarily alter the application palette.

For kwrite & kate that caused quite some overhead, where I initially believed that this was an issue in kfiledialog and/or kcm, maybe sycoca, but then on kate w/ quite some docs open, the dialog wouldn't show up *after minutes* and so I checked where things were taking a nap.

It hangs around in KTextEditor::ViewPrivate::updateRendererConfig and one backtrace gave me 
text re-shaping.

The  QApplication::setPalette() call would happen twice at best in this occasion, so it's not like virtuality swaps the palette some thousand times.

Deactivating the feature shows the dialog instantly, so i'm pretty sure this is the problem.

Since application palette changes might occur for other reasons (and at runtime) I assume this should be sorted out. Any idea what might be the cause (Arch doesn't provide debug enabled libs, i'd have to compile libKF5TextEditor locally for a better backtrace if required)

---------

Backtrace:

#0  0xb725c7aa in ?? () from /usr/lib/libKF5TextEditor.so.5
#1  0xb725ca3a in ?? () from /usr/lib/libKF5TextEditor.so.5
#2  0xb7257f4f in ?? () from /usr/lib/libKF5TextEditor.so.5
#3  0xb7258e94 in ?? () from /usr/lib/libKF5TextEditor.so.5
#4  0xb726076c in ?? () from /usr/lib/libKF5TextEditor.so.5
#5  0xb72613cd in ?? () from /usr/lib/libKF5TextEditor.so.5
#6  0xb72bb5f3 in ?? () from /usr/lib/libKF5TextEditor.so.5
#7  0xb72bb8dd in ?? () from /usr/lib/libKF5TextEditor.so.5
#8  0xb72a3cd6 in KTextEditor::ViewPrivate::updateRendererConfig() () from /usr/lib/libKF5TextEditor.so.5
#9  0xb7256f13 in ?? () from /usr/lib/libKF5TextEditor.so.5
#10 0xb7307216 in KateRendererConfig::updateConfig() () from /usr/lib/libKF5TextEditor.so.5
#11 0xb731cd43 in KTextEditor::EditorPrivate::updateColorPalette() () from /usr/lib/libKF5TextEditor.so.5
#12 0xb731cd84 in KTextEditor::EditorPrivate::eventFilter(QObject*, QEvent*) () from /usr/lib/libKF5TextEditor.so.5
#13 0xb579065b in QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#14 0xb6144676 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#15 0xb6149ec1 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#16 0xb57909ea in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#17 0xb6145400 in QApplicationPrivate::setPalette_helper(QPalette const&, char const*, bool) () from /usr/lib/libQt5Widgets.so.5
#18 0xb61458fe in QApplication::setPalette(QPalette const&, char const*) () from /usr/lib/libQt5Widgets.so.5
#19 0xae897058 in BE::Style::swapPalette(QWidget*) () from /usr/lib/qt/plugins/styles/libvirtuality.so
#20 0xae898731 in BE::Style::eventFilter(QObject*, QEvent*) () from /usr/lib/qt/plugins/styles/libvirtuality.so


Bit deeper steps (otherwise as above):

#3  0xb4721d7f in ?? () from /usr/lib/libharfbuzz.so.0
#4  0xb470718f in hb_shape_plan_execute () from /usr/lib/libharfbuzz.so.0
#5  0xb4706587 in hb_shape_full () from /usr/lib/libharfbuzz.so.0
#6  0xb5c5c85e in QTextEngine::shapeTextWithHarfbuzzNG(QScriptItem const&, unsigned short const*, int, QFontEngine*, QVector<unsigned int> const&, bool) const () from /usr/lib/libQt5Gui.so.5
#7  0xb5c605b1 in QTextEngine::shapeText(int) const () from /usr/lib/libQt5Gui.so.5
#8  0xb5c612d8 in QTextEngine::shape(int) const () from /usr/lib/libQt5Gui.so.5
#9  0xb5c739d8 in QTextLine::layout_helper(int) () from /usr/lib/libQt5Gui.so.5
#10 0xb5c74ec0 in QTextLine::setLineWidth(double) () from /usr/lib/libQt5Gui.so.5

Reproducible: Always
Comment 1 Dominik Haumann 2016-05-28 12:40:33 UTC
This was fixed end of January 2016, please update the KDE Frameworks to a recent version.

*** This bug has been marked as a duplicate of bug 358526 ***