[Cmake-commits] [cmake-commits] king committed cmMakefile.cxx 1.519 1.520

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Sep 16 09:51:50 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv6593/Source

Modified Files:
	cmMakefile.cxx 
Log Message:
Initialize directory scope with closure of parent

The commit "Improve dynamic variable scope implementation" optimized
function scopes using an efficient parent scope pointer.  However, the
parent scope used to initialize a new directory might not exist later
(like add_subdirectory called inside a function of the parent scope).
This caused CMake to crash when following the dangling pointer to the
original parent scope.

We fix the problem in this commit by always computing the closure of the
parent scope at directory initialization time so that no parent scope
pointer is needed.  See issue #9538.


Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.519
retrieving revision 1.520
diff -C 2 -d -r1.519 -r1.520
*** cmMakefile.cxx	10 Sep 2009 20:59:44 -0000	1.519
--- cmMakefile.cxx	16 Sep 2009 13:51:47 -0000	1.520
***************
*** 1429,1434 ****
    cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile();
  
!   // copy the definitions
!   this->Internal->VarStack.top().Reset(&parent->Internal->VarStack.top());
  
    // copy include paths
--- 1429,1434 ----
    cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile();
  
!   // Initialize definitions with the closure of the parent scope.
!   this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure();
  
    // copy include paths
***************
*** 3423,3426 ****
--- 3423,3434 ----
      up->Set(var, varDef);
      }
+   else if(cmMakefile* parent =
+           this->LocalGenerator->GetParent()->GetMakefile())
+     {
+     // Update the definition in the parent directory top scope.  This
+     // directory's scope was initialized by the closure of the parent
+     // scope, so we do not need to localize the definition first.
+     parent->Internal->VarStack.top().Set(var, varDef);
+     }
  }
  



More information about the Cmake-commits mailing list