Skip to content

Commit

Permalink
Fix daemon persist bug and document instance() (#2185)
Browse files Browse the repository at this point in the history
Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
  • Loading branch information
veracioux authored Dec 23, 2021
1 parent 9607102 commit 5c8a2b2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/core/flameshotdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -159,7 +171,7 @@ FlameshotDaemon* FlameshotDaemon::instance()
*/
void FlameshotDaemon::quitIfIdle()
{
if (m_persist && !instance()) {
if (m_persist) {
return;
}
if (!m_hostingClipboard && m_widgets.isEmpty()) {
Expand Down

0 comments on commit 5c8a2b2

Please sign in to comment.