mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 11:09:37 -06:00
Wait for initialization when adding assets at runtime. Correctly destroy the RenderableGalaxy shader when deinitializing (closes #1601)
This commit is contained in:
@@ -56,6 +56,8 @@ public:
|
||||
void enqueue(std::function<void()> f);
|
||||
void clearTasks();
|
||||
|
||||
bool hasOutstandingTasks() const;
|
||||
|
||||
private:
|
||||
friend class Worker;
|
||||
|
||||
|
||||
@@ -494,6 +494,11 @@ void RenderableGalaxy::deinitializeGL() {
|
||||
_raycaster = nullptr;
|
||||
}
|
||||
|
||||
global::renderEngine->removeRenderProgram(_pointsProgram.get());
|
||||
_pointsProgram = nullptr;
|
||||
global::renderEngine->removeRenderProgram(_billboardsProgram.get());
|
||||
_billboardsProgram = nullptr;
|
||||
|
||||
glDeleteVertexArrays(1, &_pointsVao);
|
||||
glDeleteBuffers(1, &_positionVbo);
|
||||
glDeleteBuffers(1, &_colorVbo);
|
||||
|
||||
@@ -100,6 +100,13 @@ void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) {
|
||||
}
|
||||
|
||||
std::vector<SceneGraphNode*> MultiThreadedSceneInitializer::takeInitializedNodes() {
|
||||
// Some of the scene graph nodes might still be in the initialization queue and we
|
||||
// should wait for those to finish or we end up in some half-initialized state since
|
||||
// other parts of the application already know about their existence
|
||||
while (_threadPool.hasOutstandingTasks()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
std::lock_guard g(_mutex);
|
||||
std::vector<SceneGraphNode*> nodes = std::move(_initializedNodes);
|
||||
return nodes;
|
||||
|
||||
@@ -99,4 +99,8 @@ void ThreadPool::clearTasks() {
|
||||
} // release lock
|
||||
}
|
||||
|
||||
bool ThreadPool::hasOutstandingTasks() const {
|
||||
return !tasks.empty();
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user