Skip to content

Commit 35ce016

Browse files
committed
Update idletimer.cpp
Make it work without global variable initialization. This is due to golang/go#10023 (duplicate of golang/go#4069) and solves go-qml#142.
1 parent d594148 commit 35ce016

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cpp/idletimer.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ class IdleTimer : public QObject
1212
public:
1313

1414
static IdleTimer *singleton() {
15-
static IdleTimer singleton;
16-
return &singleton;
15+
//static IdleTimer singleton;
16+
if (_singleton == nullptr)
17+
_singleton = new IdleTimer;
18+
return _singleton;
1719
}
1820

1921
void init(int32_t *guiIdleRun)
@@ -38,13 +40,17 @@ class IdleTimer : public QObject
3840
}
3941
}
4042

43+
static IdleTimer* _singleton;
44+
4145
private:
4246

4347
int32_t *guiIdleRun;
4448

4549
QBasicTimer timer;
4650
};
4751

52+
IdleTimer* IdleTimer::_singleton;
53+
4854
void idleTimerInit(int32_t *guiIdleRun)
4955
{
5056
IdleTimer::singleton()->init(guiIdleRun);

0 commit comments

Comments
 (0)