From 91e35599dcfe554498483f651b7f2c394fd5d414 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 18 Feb 2008 13:52:26 +0000 Subject: [PATCH] From Brede Johansen, "Here's a fix to the changes regarding the new dispose() function. The last primary node inside a push-pop level would not get the dispose() call. This would result in information from some ancillary records, like the matrix (transform), being lost. Changes are made to the latest version in the repository. Thanks to Terry for the help to find and fix the bug and test the changes." --- src/osgPlugins/OpenFlight/ControlRecords.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/osgPlugins/OpenFlight/ControlRecords.cpp b/src/osgPlugins/OpenFlight/ControlRecords.cpp index 31d07c95b..3eb05b1d6 100644 --- a/src/osgPlugins/OpenFlight/ControlRecords.cpp +++ b/src/osgPlugins/OpenFlight/ControlRecords.cpp @@ -63,11 +63,19 @@ class PopLevel : public Record virtual void read(RecordInputStream& /*in*/, Document& document) { - // Finally call dispose() for primary with push, pop level pair. - PrimaryRecord* primary = document.getTopOfLevelStack(); - if (primary) + PrimaryRecord* parentPrimary = document.getTopOfLevelStack(); + PrimaryRecord* currentPrimary = document.getCurrentPrimaryRecord(); + + // Call dispose() for primary without push, pop level pair. + if (currentPrimary && currentPrimary!=parentPrimary) { - primary->dispose(document); + currentPrimary->dispose(document); + } + + // Call dispose() for primary with push, pop level pair. + if (parentPrimary) + { + parentPrimary->dispose(document); } document.popLevel();