Problem in the single-instance mode
Let me explain the problem by describing how it can be reproduced.
Steps to Reproduce (for bugs)
- Uncheck Options → Advanced → Allow multiple instances… and close screengrab.
- In a terminal, type
screengrab --helpor evenscreengrab --fgfand pressEnter. - After that, type screengrab and press
Enter.
Then, screengrab won't start and this message will be shown: "QLocalSocket::connectToServer: Connection refused"
Context
The problem is caused by using QSharedMemory for creating a single-instance app. In 2, qipc_sharedmemory_blahblah and qipc_systemsem_blahblah are created in /tmp but aren't removed immediately. In 3, qipc_sharedmemory is removed at last but , because it existed in the first place, the app shows an error message and exits. Only after that, the app will start normally.
Possible Solution
In FeatherPad, I used a lock file instead of QSharedMemory because QSharedMemory proved to be unreliable and buggy. However, I didn't use QCommandLineParser in FeatherPad (I don't like such tools, in general) and the code structure is very different.
So, I don't know of a possible solution yet.
System Information
git LXQt.
@tsujan Thinking loud: Maybe LXQt::SingleApplication can help.
@luis-pereira That's a good idea but needs a total overhaul.
I'll think about it a little and tell you if I don't find a simple solution -- by "simple", I mean a few lines of code.
@luis-pereira I couldn't find a short solution. The problem is that, with --help or a wrong option, the shared memory isn't released.
Would you implement a single-instance by using LXQt::SingleApplication? I don't think I'll find the time needed for code restructuring soon and even if I find it, your work will be cleaner.
% LANG=C screengrab --help
Usage: screengrab [options]
ScreenGrab is a crossplatform application for fast creating screenshots of your desktop.
Options:
-h, --help Displays this help.
-v, --version Displays version information.
-f, --fullscreen Take a fullscreen screenshot
-a, --active Take a screenshot of the active window
-r, --region Take a screenshot of a selection of the screen
-m, --minimized Run the application with a hidden main window
Hmm - if you don't like the current implementation, is it so hard to drop and use the method we use for other LXQt packages?
if you don't like the current implementation
It's isn't about my disliking it. It's simply wrong because the shared memory will be released only if the app runs first.
is it so hard to drop and use the method we use for other LXQt packages?
It's quite possible and should be done but needs a lot of work because the core should be rewritten.
ok, in that case i understood you right and agree wholehearted :slightly_smiling_face:
Edit: and to be honest - i would ignore it for now.
Edit: and to be honest - i would ignore it for now.
It isn't a big issue -- try to run the app twice after --help or --blahblah and it'll run -- but shows a deep problem.
It's a minor issue. Can wait.