Add workaround for QMenuBar::setVisible bug in 5.7.0
ClosedPublic

Authored by davidedmundson on Jan 25 2017, 12:05 PM.

Details

Summary

QMenuBar::setVisible() only checks isNativeMenuBar on OS X
leading to both the normal in-appmenu and the platform menu both being
visible - especially as KXmlGui explicitly has a setVisible call.

This only affects Qt 5.7.0.
For Qt < 5.7.0 we don't have any DBusMenu support.
For Qt >= 5.7.1 the problem is fixed.

This patch adds a (horrible) event filter on any QMenuBar's and blocks
any setVisible calls.

Qt 5.7.0
void QMenuBar::setVisible(bool visible)
{

if (isNativeMenuBar()) {
    if (!visible)
        QWidget::setVisible(false);
    return;
}
QWidget::setVisible(visible);

}

Qt 5.7.1
void QMenuBar::setVisible(bool visible)
{

if (isNativeMenuBar()) {
    if (!visible)
        QWidget::setVisible(false);
    return;
}
QWidget::setVisible(visible);

}

Test Plan

Ran on a system with Qt 5.7.0
No longer get double menus

Diff Detail

Repository
R135 Integration for Qt applications in Plasma
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davidedmundson retitled this revision from to Add workaround for QMenuBar::setVisible bug in 5.7.0.
davidedmundson updated this object.
davidedmundson edited the test plan for this revision. (Show Details)
davidedmundson added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptJan 25 2017, 12:05 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik accepted this revision.Jan 25 2017, 12:15 PM
broulik added a reviewer: broulik.
broulik added a subscriber: broulik.

Works for me. Cool.

I asked Dmitry (who did the Qt menu stuff) and he's fine with it. Let's go with it, thanks.

You can close Bug 375498 then

This revision is now accepted and ready to land.Jan 25 2017, 12:15 PM
This revision was automatically updated to reflect the committed changes.