Bug 305590

Summary: Abusive behaviour - 100% cpu load from application.
Product: [Plasma] Oxygen Reporter: Kent H. Bengtsson <kent.henrik.bengtsson>
Component: styleAssignee: Hugo Pereira Da Costa <hugo.pereira.da.costa>
Status: RESOLVED FIXED    
Severity: critical CC: cfeck, germano.massullo, hugo.pereira.da.costa
Priority: NOR    
Version: 4.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 4.9.1
Sentry Crash Report:

Description Kent H. Bengtsson 2012-08-22 11:09:36 UTC
FreeCAD causes a 100% cpu load in conjunction with Oxygen. Confirmed in irc channel. See additional information for test case and this link:
https://sourceforge.net/apps/phpbb/free-cad/viewtopic.php?f=4&t=2815

Reproducible: Always




[quote="wmayer"]Here is a test application that shows that it's clearly not a FreeCAD bug but KDE/oxygen issue:

main.cpp
[code]

/**
 * This test application demonstrates a bug with KDE that happens if all of these points are fulfilled:
 * 1. Using KDE desktop environment
 * 2. Using Oxygen windows style
 * 3. Enabling the tab bar of QMdiArea
 * 4. Maximaize the main window after start 
 */

#include <QtCore>
#include <QtGui>
#include <QtWebKit>

class GUIApplication : public QApplication
{
public:
    GUIApplication(int & argc, char ** argv)
        : QApplication(argc, argv)
    {
    }

    bool notify (QObject * receiver, QEvent * event)
    {
        int type = event->type();
        if (type != 113 && type != 1)
            printf("Event type %d\n", type);
        return QApplication::notify(receiver, event);
    }
};

int main(int argc, char** argv)
{
    GUIApplication app(argc, argv);
    QMainWindow mw;
    mw.show();
    QMdiArea* mdiArea = new QMdiArea();
    mdiArea->setTabPosition(QTabWidget::South);
    // Having the tabbar enabled casuses a full CPU load later when resizing
    mdiArea->setViewMode(QMdiArea::TabbedView);
    mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, false);
    mdiArea->setActivationOrder(QMdiArea::ActivationHistoryOrder);
    mw.setCentralWidget(mdiArea);
    
    QMainWindow* view = new QMainWindow(&mw);
    QWebView* web = new QWebView(view);
    view->setCentralWidget(web);
    web->load(QUrl("http://www.heise.de"));

    QMdiSubWindow* child = new QMdiSubWindow(mdiArea->viewport());
    child->setAttribute(Qt::WA_DeleteOnClose);
    child->setWidget(view);
    mdiArea->addSubWindow(child);
    view->showMaximized();
    
    
    return app.exec();
}
[/code]

test.pro
[code]
TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .
QT += webkit

# Input
SOURCES += main.cpp
[/code][/quote]
Comment 1 Christoph Feck 2012-08-22 12:08:44 UTC
Interestingly, it also happens with Skulpture style, but not with Plastique. Since the test involves QMdiSubWindow, I guess it is caused by the MDI shadows, which Skulpture and Oxygen uses.
Comment 2 Christoph Feck 2012-08-22 13:39:53 UTC
That was tricky.

QMdiArea is a scroll area. Qt will resize a maximized window automatically, when the scroll area changes in size. When the scroll bars are set to "as needed", then the viewport can get smaller, if there is a window outside the current viewport. Skulpture tried to clip shadows, so that the shadows won't got outside the bounds of the area. But it did clip to the complete area, insted of the viewport. This caused an infinite "scroll bar on / off" loop.

Hugo, I will commit a fix to Skulpture 0.2 branch soon, and CC here, so that you can "side port" the fix to Oxygen.
Comment 3 Christoph Feck 2012-08-22 14:04:29 UTC
Meh, git doesn't send to bko for scratch projects ... anyway, see commit at http://quickgit.kde.org/index.php?p=scratch%2Fcfeck%2Fskulpture.git&a=commit&h=4e36baf0032c9f2e1c78cf11175e726d9582778a
Comment 4 Christoph Feck 2012-08-27 20:16:35 UTC
https://git.reviewboard.kde.org/r/106240/
Comment 5 Hugo Pereira Da Costa 2012-08-27 20:39:20 UTC
@Christoph
Thanks for tracking this down and fixing.
Working on side-porting it right now.

Hugo (back from vacation :))
Comment 6 Hugo Pereira Da Costa 2012-08-27 21:13:32 UTC
Git commit 79ae754d1f22a788e7a8c3b1e267ce137f35bf23 by Hugo Pereira Da Costa.
Committed on 27/08/2012 at 23:11.
Pushed by hpereiradacosta into branch 'master'.

Fix endless recursion with MDI shadows
Thanks Christoph Feck !
REVIEW: 106240

M  +3    -1    kstyles/oxygen/oxygenmdiwindowshadow.cpp

http://commits.kde.org/kde-workspace/79ae754d1f22a788e7a8c3b1e267ce137f35bf23
Comment 7 Hugo Pereira Da Costa 2012-08-27 21:28:15 UTC
Git commit bc15060f6aa1cf3a699202918e94cc08b01f9fa8 by Hugo Pereira Da Costa.
Committed on 27/08/2012 at 23:11.
Pushed by hpereiradacosta into branch 'KDE/4.9'.

Fix endless recursion with MDI shadows
Thanks Christoph Feck !
REVIEW: 106240

M  +3    -1    kstyles/oxygen/oxygenmdiwindowshadow.cpp

http://commits.kde.org/kde-workspace/bc15060f6aa1cf3a699202918e94cc08b01f9fa8
Comment 8 Hugo Pereira Da Costa 2012-08-27 21:28:49 UTC
... closing.