Fix daemon persist bug and document instance() (#2185)

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
Haris Gušić
2021-12-23 22:07:24 +01:00
committed by GitHub
parent 960710206e
commit 5c8a2b25bb

View File

@@ -142,6 +142,18 @@ bool FlameshotDaemon::isThisInstanceHostingWidgets()
return instance() && !instance()->m_widgets.isEmpty();
}
/**
* @brief Return the daemon instance.
*
* If this instance of flameshot is the daemon, a singleton instance of
* `FlameshotDaemon` is returned. As a side effect`start` will called if it
* wasn't called earlier. If this instance of flameshot is not the daemon,
* `nullptr` is returned.
*
* This strategy is used because the daemon needs to receive signals from D-Bus,
* for which an instance of a `QObject` is required. The singleton serves as
* that object.
*/
FlameshotDaemon* FlameshotDaemon::instance()
{
// Because we don't use DBus on MacOS, each instance of flameshot is its own
@@ -159,7 +171,7 @@ FlameshotDaemon* FlameshotDaemon::instance()
*/
void FlameshotDaemon::quitIfIdle()
{
if (m_persist && !instance()) {
if (m_persist) {
return;
}
if (!m_hostingClipboard && m_widgets.isEmpty()) {