Bug 458882

Summary: Menu Bar display only if executed as root (sudo/su)
Product: [Applications] krita Reporter: Leonard <leomonta2002>
Component: UsabilityAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: artem.anufrij, beojan, halla, mhasadi78, nicolas.fella, saileshpoudel0, zxq5
Priority: NOR    
Version: 5.1.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: krita executa as normal user
On top the menubar showing on krita ran as super user, on bottom krita ran as normal user

Description Leonard 2022-09-08 15:58:59 UTC
Created attachment 151926 [details]
krita executa as normal user

SUMMARY
***
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE (Even if i don't think that this is not easily reproducible)
1. Open krita from CLI as non root user 
2. Open krita from CLI as root user (su or sudo)

OBSERVED RESULT
The menu bar ('File' 'Edit' 'View' etc..) is not visible like normal
nor with the 'application menu' button of KDE Plasma
As super user the menu bar appear (ignoring the 'application menu' button)

EXPECTED RESULT
The Menu bar should appear regardless of being executed as super user or not
And the Menu bar should be visible from the 'application menu' button on Plasma

SOFTWARE/OS VERSIONS 
Linux/KDE Plasma: Arch 5.19.7-arch1-1
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.97.0
Qt Version: 5.15.5

ADDITIONAL INFORMATION
using wayland or X11 does not change behavior
I already tried removing and reinstalling krita via pacman to no avail
deleted both kritarc in the .config folder (kritarc and kritadisplayrc)
Changed the voice 'MenuBar=Disabled' to 'MenuBar=Enabled' in the kritarc
but the file is reset as soon as krita starts
Comment 1 Leonard 2022-09-08 16:06:56 UTC
Created attachment 151927 [details]
On top the menubar showing on krita ran as super user, on bottom krita ran as normal user
Comment 2 Qualimer Judith 2022-09-09 00:49:08 UTC
Quick question - do you have a global menu applet enabled in your Plasma desktop? Does this behaviour persist if you remove it, if so?
Comment 3 Leonard 2022-09-09 13:11:23 UTC
(In reply to Qualimer Judith from comment #2)
> Quick question - do you have a global menu applet enabled in your Plasma
> desktop? Does this behaviour persist if you remove it, if so?

No, I haven't Installed any applet for Plasma that shouldn't be the cause. 
I've been using Linux for a little less than a month, I'm not really sure what a 'global menu applet' is.
Comment 4 Nicolas Fella 2022-09-09 14:03:58 UTC
Judging from your screenshot you are using a titlebar menu button. That means that the in-app menubar is disabled.

If you want the in-app menu bar you need to remove the menu button from the window decoration
Comment 5 Leonard 2022-09-09 14:09:58 UTC
(In reply to Nicolas Fella from comment #4)
> Judging from your screenshot you are using a titlebar menu button. That
> means that the in-app menubar is disabled.
> 
> If you want the in-app menu bar you need to remove the menu button from the
> window decoration

I prefer the menu button over the in-app menubar but the problem is that neither of them work as non root user
Comment 6 Halla Rempt 2022-09-12 09:23:57 UTC
The system that allows various menubar options works using dbus, so it sounds like there's a misconfiguration there. Either that, or the integration broke again: it's a very fragile and little used system. Does the appimage work for you?
Comment 7 Halla Rempt 2022-09-16 12:05:01 UTC
*** Bug 459092 has been marked as a duplicate of this bug. ***
Comment 8 dS810 2022-09-16 14:04:19 UTC
(In reply to Halla Rempt from comment #6)
> The system that allows various menubar options works using dbus, so it
> sounds like there's a misconfiguration there. Either that, or the
> integration broke again: it's a very fragile and little used system. Does
> the appimage work for you?

AppImage looks fine on arch linux. Package from repository doesn't
Comment 9 Halla Rempt 2022-09-16 16:58:30 UTC
Um, then please do also report an Arch bug?
Comment 10 Antonio Rojas 2022-09-16 19:19:33 UTC
This is caused by https://invent.kde.org/qt/qt/qtbase/-/commit/1b3f742baf1ed2e4171ced79541f1e4647058a0a

The following minimal Qt patch is enough to break the global menu in Krita (and only in Krita)

diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
index f0d1722c95..fa92a0dfa6 100644
--- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
@@ -298,6 +302,13 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
 }
 #endif // QT_CONFIG(dbus)
 
+QGenericUnixServices::QGenericUnixServices()
+{
+#if QT_CONFIG(dbus)
+    QDBusMessage message;
+    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+#endif
+}
 QByteArray QGenericUnixServices::desktopEnvironment() const
 {
     static const QByteArray result = detectDesktopEnvironment();
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/src/platformsupport/services/genericunix/qgenericunixservices_p.h
index 8ac3de6f03..30924e64bd 100644
--- a/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+++ b/src/platformsupport/services/genericunix/qgenericunixservices_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
 class QGenericUnixServices : public QPlatformServices
 {
 public:
-    QGenericUnixServices() {}
+    QGenericUnixServices();
 
     QByteArray desktopEnvironment() const override;
Comment 11 Leonard 2022-09-16 19:30:29 UTC
I'm happy to see that at least a the culprit was found.
In the mean time i gave up on the "app menu" button entirely.
I turned off the button and after rebooting the Menu Bar reappears on krita,
(Ctrl + Shift + M does not work btw)

Sorry for the inconvenience
Comment 12 Antonio Rojas 2022-09-17 07:13:08 UTC
*** Bug 459251 has been marked as a duplicate of this bug. ***
Comment 13 Halla Rempt 2022-09-17 09:51:10 UTC
We've had many  reports like this over the years. https://bugs.kde.org/show_bug.cgi?id=408015 is an example: there David Edmundson resolved the issue with a hack: https://invent.kde.org/kde/krita/commit/be0976cb715884a8445c9c980d841866bebc8390.

dbus has big problems if a process creates two QApplication objects. It somehow latches onto the first one. And we cannot work around that, we have to have this probing QApplication instance. 

I don't think we can do anything about this from within Krita :-(

*** This bug has been marked as a duplicate of bug 408015 ***
Comment 14 beojan 2022-09-22 22:27:49 UTC
> dbus has big problems if a process creates two QApplication objects. It
> somehow latches onto the first one. And we cannot work around that, we have
> to have this probing QApplication instance. 
> 
> I don't think we can do anything about this from within Krita :-(

Why can't the global `KisApplication::instance()` be used instead of creating an additional QApplication instance?

The Qt documentation contains this sentence as part of the QApplication reference:

> For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time.
Comment 15 Halla Rempt 2022-09-23 18:05:21 UTC
Because the first QApplication instance is used to probe, and then destructed, and then a new one is created.
Comment 16 beojan 2022-09-26 18:01:35 UTC
Could the main KisApplication instance be constructed earlier, so it can be used for the probing?

Alternatively, could the probing be done without constructing a QApplication instance (maybe by using other libraries)?
Comment 17 Antonio Rojas 2022-10-23 07:39:25 UTC
*** Bug 460871 has been marked as a duplicate of this bug. ***
Comment 18 zxq5 2024-03-12 23:37:20 UTC
also getting this issue on plasma 6.0.1 on arch