Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in the single-instance mode #184

Open
tsujan opened this issue Oct 31, 2019 · 8 comments
Open

Problem in the single-instance mode #184

tsujan opened this issue Oct 31, 2019 · 8 comments

Comments

@tsujan
Copy link
Member

tsujan commented Oct 31, 2019

Let me explain the problem by describing how it can be reproduced.

Steps to Reproduce (for bugs)
  1. Uncheck Options → Advanced → Allow multiple instances… and close screengrab.
  2. In a terminal, type screengrab --help or even screengrab --fgf and press Enter.
  3. 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.

@luis-pereira
Copy link
Member

@tsujan Thinking loud: Maybe LXQt::SingleApplication can help.

@tsujan
Copy link
Member Author

tsujan commented Oct 31, 2019

@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.

@tsujan
Copy link
Member Author

tsujan commented Oct 31, 2019

@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.

@agaida
Copy link
Member

agaida commented Oct 31, 2019

% 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?

@tsujan
Copy link
Member Author

tsujan commented Oct 31, 2019

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.

@agaida
Copy link
Member

agaida commented Oct 31, 2019

ok, in that case i understood you right and agree wholehearted 🙂

Edit: and to be honest - i would ignore it for now.

@tsujan
Copy link
Member Author

tsujan commented Oct 31, 2019

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.

@luis-pereira
Copy link
Member

It's a minor issue. Can wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants