Added delay between sequential threading model changes to prevent the system from locking up
with 'm' is held down, which previous would cause the threading model to be thrashed.
This commit is contained in:
parent
4637b78bd1
commit
6a67b66e8e
@ -34,7 +34,11 @@ class ThreadingHandler : public osgGA::GUIEventHandler
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ThreadingHandler() {}
|
ThreadingHandler()
|
||||||
|
{
|
||||||
|
_tickOrLastKeyPress = osg::Timer::instance()->tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
|
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
|
||||||
{
|
{
|
||||||
@ -45,8 +49,14 @@ public:
|
|||||||
{
|
{
|
||||||
case(osgGA::GUIEventAdapter::KEYUP):
|
case(osgGA::GUIEventAdapter::KEYUP):
|
||||||
{
|
{
|
||||||
if (ea.getKey()=='m')
|
|
||||||
|
double delta = osg::Timer::instance()->delta_s(_tickOrLastKeyPress, osg::Timer::instance()->tick());
|
||||||
|
|
||||||
|
if (ea.getKey()=='m' && delta>1.0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
_tickOrLastKeyPress = osg::Timer::instance()->tick();
|
||||||
|
|
||||||
switch(viewer->getThreadingModel())
|
switch(viewer->getThreadingModel())
|
||||||
{
|
{
|
||||||
case(osgViewer::Viewer::SingleThreaded):
|
case(osgViewer::Viewer::SingleThreaded):
|
||||||
@ -101,8 +111,7 @@ public:
|
|||||||
usage.addKeyboardMouseBinding("e","Toggle the placement of the end of frame barrier.");
|
usage.addKeyboardMouseBinding("e","Toggle the placement of the end of frame barrier.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::Timer_t _tickOrLastKeyPress;
|
||||||
|
|
||||||
bool _done;
|
bool _done;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user