Comments (8)
Technically I found a workaround for releasing QSharedMemory
after a process has crashed. On Windows it's not a problem, but on Linux by initializing it, then deleting forces the kernel to clean up the shared memory. This way the moment e initialize it again it's the first time it's initialized. Take a look at the code below.
SingleApplication/singleapplication.cpp
Lines 67 to 75 in 6dde626
Lockfiles on the other hand suffer from the same problem when an instance has crashed. Originally I tried implementing it with a lockfile, but found that to be too unreliable. But maybe we can give it another look.
Another option would be to handle the SingleAplication functionality completely through QLocalSocket
. If there is a primary instance to connect to - use it. Otherwise create one. I think we can use the fact that you can't bind two programs to the same address for single instance protection.
from singleapplication.
One issue when using local sockets that I know of is if an app is busy and doesn't reply to the message in time. It can happen if the main event loop is blocked doing a task. To account for this we'll have to always start a separate thread for the SingleApplication QLocalServer.
from singleapplication.
I can confirm, it looks like SingleApplication doesn't work anymore with Qt 6.6...
from singleapplication.
from singleapplication.
Works great on Linux, thanks, I'll try on other platforms tomorrow!
from singleapplication.
Fixed in #177 and released in v3.5.0
.
from singleapplication.
Thanks @jonaski
from singleapplication.
Thiago just posted on the Qt dev mailing-list, see https://lists.qt-project.org/pipermail/development/2023-November/044680.html and https://codereview.qt-project.org/c/qt/qtbase/+/518039
Shortly summarized:
QSharedMemory is flawed by design and unless someone else steps up to fix QSharedMemory, it will be deprecated in Qt 6 and removed in Qt 7.
I would like to dig into this myself, but I'm already working 4-7 hours every day on open source work in addition to a full time job (which is non-Qt), and I'm already way behind on other stuff so I can't find the time now.
from singleapplication.
Related Issues (20)
- ocr maybe error? HOT 1
- No primaryScreen property HOT 1
- QWidget: Cannot create a QWidget without QApplication HOT 4
- undefined reference to `SingleApplication::SingleApplication(int&, char**, bool, QFlags<SingleApplication::Mode>, int, QString const&)' HOT 5
- Long screenshot shortcuts cannot be changed(长截图快捷键无法更改) HOT 1
- The new license might no longer be GPL-compatible HOT 14
- Restart application failed HOT 5
- key too long on macos HOT 10
- [Proposal] Never fail to launch app HOT 6
- wrong issue to wrong repo
- Could not find advapi32_LIBRARY using the following names: advapi32 HOT 2
- Define ownership of QSharedMemory* pointer HOT 1
- Check if d->attach() is successful HOT 1
- args_for_main.join( ) puts a separator on every space HOT 3
- Consider making SingleApplication as a hook HOT 1
- Kill recovery not working HOT 11
- Randomly freeze in QSharedMemory::attach() which finally calls QSharedMemory::lock
- A liitle confused about Mode::SecondaryNotification HOT 1
- SendMessage doesn't send (with Fix) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from singleapplication.