Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
fix: can run twice
Browse files Browse the repository at this point in the history
dde-daemon针对截图做了特殊处理,可以在grabkeyboard的情况下依旧启动截图,
所以截图的startScreenshot函数被调用了两次,破坏了单例。
  • Loading branch information
justforlxz.com committed Jul 2, 2019
1 parent 1d797aa commit 374dfc7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dbusservice/dbusscreenshotservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ DBusScreenshotService::~DBusScreenshotService()
// destructor
}

void DBusScreenshotService::setSingleInstance(bool instance) {
m_singleInstance = instance;
}

void DBusScreenshotService::StartScreenshot() {
qDebug() << "DBus screenshot service! start screenshot";
if (!m_singleInstance)
Expand Down Expand Up @@ -107,4 +111,3 @@ void DBusScreenshotService::SavePathScreenshot(const QString &in0)
parent()->savePathScreenshot(in0);
m_singleInstance = true;
}

2 changes: 2 additions & 0 deletions src/dbusservice/dbusscreenshotservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class DBusScreenshotService: public QDBusAbstractAdaptor
DBusScreenshotService(Screenshot *parent);
~DBusScreenshotService();

void setSingleInstance(bool instance);

inline Screenshot *parent() const
{ return static_cast<Screenshot *>(QObject::parent()); }

Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ int main(int argc, char *argv[])
qDebug() << "dbus register waiting!";
return a.exec();
} else {
dbusService.setSingleInstance(true);
if (cmdParser.isSet(delayOption)) {
qDebug() << "cmd delay screenshot";
w.delayScreenshot(cmdParser.value(delayOption).toInt());
Expand Down

0 comments on commit 374dfc7

Please sign in to comment.