Skip to content

Commit

Permalink
extend API of TimerFunction class
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Mar 31, 2017
1 parent 784edd3 commit 4784751
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Gui/ActionFunction.cpp
Expand Up @@ -119,7 +119,9 @@ class TimerFunctionPrivate
{
public:
boost::function<void()> timeoutFunc;
boost::function<void(QObject*)> timeoutFuncQObject;
bool autoDelete;
QPointer<QObject> argQObject;
};
}

Expand All @@ -139,6 +141,13 @@ void TimerFunction::setFunction(boost::function<void()> func)
d->timeoutFunc = func;
}

void TimerFunction::setFunction(boost::function<void(QObject*)> func, QObject* args)
{
Q_D(TimerFunction);
d->timeoutFuncQObject = func;
d->argQObject = args;
}

void TimerFunction::setAutoDelete(bool on)
{
Q_D(TimerFunction);
Expand All @@ -148,7 +157,10 @@ void TimerFunction::setAutoDelete(bool on)
void TimerFunction::timeout()
{
Q_D(TimerFunction);
d->timeoutFunc();
if (d->timeoutFunc)
d->timeoutFunc();
else if (d->timeoutFuncQObject)
d->timeoutFuncQObject(d->argQObject);
if (d->autoDelete)
deleteLater();
}
Expand Down
1 change: 1 addition & 0 deletions src/Gui/ActionFunction.h
Expand Up @@ -98,6 +98,7 @@ class GuiExport TimerFunction : public QObject
virtual ~TimerFunction();

void setFunction(boost::function<void()> func);
void setFunction(boost::function<void(QObject*)> func, QObject* args);
void setAutoDelete(bool);

private Q_SLOTS:
Expand Down

2 comments on commit 4784751

@sukoi26
Copy link

@sukoi26 sukoi26 commented on 4784751 Apr 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing
#include <QPointer>

@luzpaz
Copy link
Contributor

@luzpaz luzpaz commented on 4784751 Apr 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was added in c80f6f0

Please sign in to comment.