Browse Source

workaround for windows crash

David Rose 24 years ago
parent
commit
3fccb0f373

+ 10 - 10
dtool/src/interrogate/interrogateBuilder.cxx

@@ -1575,28 +1575,28 @@ get_function(CPPInstance *function, string description,
     InterrogateDatabase::get_ptr()->get_next_index();
   _functions_by_name[function_name] = index;
 
-  InterrogateFunction ifunction;
-  ifunction._name = function->get_local_name(scope);
-  ifunction._scoped_name = descope(function->get_local_name(&parser));
+  InterrogateFunction *ifunction = new InterrogateFunction;
+  ifunction->_name = function->get_local_name(scope);
+  ifunction->_scoped_name = descope(function->get_local_name(&parser));
 
   if (function->_leading_comment != (CPPCommentBlock *)NULL) {
-    ifunction._comment = trim_blanks(function->_leading_comment->_comment);
+    ifunction->_comment = trim_blanks(function->_leading_comment->_comment);
   }
 
   ostringstream prototype;
   function->output(prototype, 0, &parser, false);
   prototype << ";";
-  ifunction._prototype = prototype.str();
+  ifunction->_prototype = prototype.str();
 
   if (struct_type != (CPPStructType *)NULL) {
     // The function is a method.
-    ifunction._flags |= InterrogateFunction::F_method;
-    ifunction._class = get_type(struct_type, false);
+    ifunction->_flags |= InterrogateFunction::F_method;
+    ifunction->_class = get_type(struct_type, false);
   }
 
-  ifunction._flags |= flags;
-  ifunction._instances.insert(InterrogateFunction::Instances::value_type(function_signature, function));
-  ifunction._expression = expression;
+  ifunction->_flags |= flags;
+  ifunction->_instances.insert(InterrogateFunction::Instances::value_type(function_signature, function));
+  ifunction->_expression = expression;
 
   InterrogateDatabase::get_ptr()->add_function(index, ifunction);
 

+ 10 - 9
dtool/src/interrogatedb/interrogateDatabase.cxx

@@ -309,7 +309,7 @@ get_function(FunctionIndex function) {
   if (fi == _function_map.end()) {
     return bogus_function;
   }
-  return (*fi).second;
+  return *(*fi).second;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -529,12 +529,12 @@ add_type(TypeIndex index, const InterrogateType &type) {
 //               the given index number.
 ////////////////////////////////////////////////////////////////////
 void InterrogateDatabase::
-add_function(FunctionIndex index, const InterrogateFunction &function) {
+add_function(FunctionIndex index, InterrogateFunction *function) {
   bool inserted =
     _function_map.insert(FunctionMap::value_type(index, function)).second;
   assert(inserted);
 
-  if (function.is_global()) {
+  if (function->is_global()) {
     _global_functions.push_back(index);
   }
   _all_functions.push_back(index);
@@ -608,7 +608,7 @@ update_type(TypeIndex type) {
 InterrogateFunction &InterrogateDatabase::
 update_function(FunctionIndex function) {
   check_latest();
-  return _function_map[function];
+  return *_function_map[function];
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -734,7 +734,7 @@ remap_indices(int first_index, IndexRemapper &remap) {
     (*wi).second.remap_indices(remap);
   }
   for (fi = _function_map.begin(); fi != _function_map.end(); ++fi) {
-    (*fi).second.remap_indices(remap);
+    (*fi).second->remap_indices(remap);
   }
   for (ti = _type_map.begin(); ti != _type_map.end(); ++ti) {
     (*ti).second.remap_indices(remap);
@@ -794,7 +794,7 @@ write(ostream &out, InterrogateModuleDef *def) const {
   out << _function_map.size() << "\n";
   FunctionMap::const_iterator fi;
   for (fi = _function_map.begin(); fi != _function_map.end(); ++fi) {
-    out << (*fi).first << " " << (*fi).second << "\n";
+    out << (*fi).first << " " << *(*fi).second << "\n";
   }
 
   out << _wrapper_map.size() << "\n";
@@ -955,9 +955,10 @@ read_new(istream &in, InterrogateModuleDef *def) {
 
     while (num_functions > 0) {
       FunctionIndex index;
-      InterrogateFunction function(def);
-      in >> index >> function;
+      InterrogateFunction *function = new InterrogateFunction(def);
+      in >> index >> *function;
       if (in.fail()) {
+        delete function;
         return false;
       }
 
@@ -1125,7 +1126,7 @@ merge_from(const InterrogateDatabase &other) {
        fi != other._function_map.end();
        ++fi) {
     FunctionIndex other_function_index = (*fi).first;
-    const InterrogateFunction &other_function = (*fi).second;
+    InterrogateFunction *other_function = (*fi).second;
     add_function(other_function_index, other_function);
     update_function(other_function_index).remap_indices(remap);
   }

+ 2 - 2
dtool/src/interrogatedb/interrogateDatabase.h

@@ -89,7 +89,7 @@ public:
   // Functions to build the database.
   int get_next_index();
   void add_type(TypeIndex index, const InterrogateType &type);
-  void add_function(FunctionIndex index, const InterrogateFunction &function);
+  void add_function(FunctionIndex index, InterrogateFunction *function);
   void add_wrapper(FunctionWrapperIndex index,
                    const InterrogateFunctionWrapper &wrapper);
   void add_manifest(ManifestIndex index, const InterrogateManifest &manifest);
@@ -124,7 +124,7 @@ private:
   // This data is loaded from the various database files.
   typedef map<TypeIndex, InterrogateType> TypeMap;
   TypeMap _type_map;
-  typedef map<FunctionIndex, InterrogateFunction> FunctionMap;
+  typedef map<FunctionIndex, InterrogateFunction *> FunctionMap;
   FunctionMap _function_map;
   typedef map<FunctionWrapperIndex, InterrogateFunctionWrapper> FunctionWrapperMap;
   FunctionWrapperMap _wrapper_map;