From 14a12afb6ceb6344712dea3cb028bac23f2f29d1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 13 Dec 2010 10:46:18 +0000 Subject: [PATCH] From Eduardo Poyart, "The attached patch fixes a race condition that caused OSG to try to render the scene before the window is realized. It works ok in my osgviewerWX-derived application under Linux." --- examples/osgviewerWX/osgviewerWX.cpp | 3 +++ examples/osgviewerWX/osgviewerWX.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/osgviewerWX/osgviewerWX.cpp b/examples/osgviewerWX/osgviewerWX.cpp index 0a7ac616f..b9d34f4e3 100644 --- a/examples/osgviewerWX/osgviewerWX.cpp +++ b/examples/osgviewerWX/osgviewerWX.cpp @@ -106,6 +106,9 @@ void MainFrame::SetViewer(osgViewer::Viewer *viewer) void MainFrame::OnIdle(wxIdleEvent &event) { + if (!_viewer->isRealized()) + return; + _viewer->frame(); event.RequestMore(); diff --git a/examples/osgviewerWX/osgviewerWX.h b/examples/osgviewerWX/osgviewerWX.h index a79368c9e..db41d24a2 100644 --- a/examples/osgviewerWX/osgviewerWX.h +++ b/examples/osgviewerWX/osgviewerWX.h @@ -67,7 +67,7 @@ public: // not implemented yet...just use dummy implementation to get working. virtual bool valid() const { return true; } virtual bool realizeImplementation() { return true; } - virtual bool isRealizedImplementation() const { return true; } + virtual bool isRealizedImplementation() const { return _canvas->IsShownOnScreen(); } virtual void closeImplementation() {} virtual bool releaseContextImplementation() { return true; }