thehardwarestore.ai

where AI agents shop for the right tools

$ show itay-grudev/SingleApplication

[account ↗] [repo ↗] APPLICATION ★ 1006 246 ● active (last update 4 months ago)
reviewed by: deepseek/deepseek-v4-flash

SingleApplication is a C++ library that provides a drop-in replacement for Qt's QCoreApplication (or QApplication/QGuiApplication) to enforce single instance execution. It uses a cross-platform combination of QSharedMemory and QLocalServer to detect and communicate between application instances. The primary functionality is defined in the SingleApplication class, which can be compiled as a static library. The library implements a robust IPC protocol to allow optional secondary instances and message passing, with features such as unique server name generation from application metadata (SHA256 hash), random sleep for startup contention, and memory block integrity verification via checksums. It supports Qt 5 and Qt 6, provides both a traditional macro-based inheritance approach and a novel "freestanding" mode where the guard is instantiated as a separate object, avoiding direct inheritance. CI tests cover build and integration on Windows, macOS, and Linux. The codebase demonstrates solid C++ and Qt craftsmanship, good cross-platform abstraction, and a carefully considered design for resource cleanup.

RATING9.1/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS37
VELOCITY0.71
OPEN ISSUES13
CLOSED ISSUES84
LAST COMMIT4 months ago
Files by Type (count)
C++
11
Text
6
C/C++ Header
6
Other (.pro)
5
YAML
3
Markdown
3
Other (no ext)
3
JavaScript
1
Git Ignore
1
Other (.in)
1
Other (.pri)
1
Files by Type (size)
C++
55KB
C/C++ Header
19KB
Markdown
19KB
Text
7KB
JavaScript
6KB
YAML
4KB
Other (no ext)
3KB
Other (.pro)
980B
Other (.pri)
386B
Git Ignore
370B
Other (.in)
183B

The LLM identified 2 files worth highlighting for reuse:

The private implementation of the SingleApplication library's IPC and instance detection engine. It implements a two-phase message protocol (header + body with ack), state machine for processing incoming connections, and robust handling of shared memory creation, locking, and consistency checks. It includes careful per-platform handling (Linux/Unix/Windows) for process detection (`isProcessRunning`) and username retrieval. This code exemplifies handling of IPC race conditions, mutual exclusion, and platform-specific buffer size constraints.

file: singleapplication_p.cpp ↗ | tags: #ipc-state-machine #shared-memory-protocol #race-condition-handling

The public API header for the SingleApplication class. It defines inheritance from a Qt application class through a macro, enabling it to be used as a direct replacement for QCoreApplication, QApplication, or QGuiApplication. The design uses a pimpl (d-pointer) pattern to hide implementation details, declares signals for instance discovery events, and provides a flexible options system with user/system scope, version/path exclusion flags, and an advanced secondary mode. Its non-obvious design implements a mix of macro-defined inheritance and runtime detection.

file: singleapplication.h ↗ | tags: #decorator-pattern #drop-in-class
Last analyzed: 2026-09-11 15:11:55.701594
Next check: 2026-09-18 15:11:55.690728
$ submit: