Browse Source

Assorted fixes

rdb 9 years ago
parent
commit
8d05ef3022

+ 1 - 1
dtool/src/dtoolbase/pdtoa.cxx

@@ -250,7 +250,7 @@ inline static unsigned CountDecimalDigit32(uint32_t n) {
 }
 }
 
 
 inline static void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) {
 inline static void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) {
-  static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
+  static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 0, 0, 0, 0, 0 };
   const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);
   const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);
   const DiyFp wp_w = Mp - W;
   const DiyFp wp_w = Mp - W;
   uint32_t p1 = static_cast<uint32_t>(Mp.f >> -one.e);
   uint32_t p1 = static_cast<uint32_t>(Mp.f >> -one.e);

+ 1 - 1
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -6262,7 +6262,7 @@ write_getset(ostream &out, Object *obj, Property *property) {
       out <<
       out <<
         "  " << cClassName  << " *local_this = NULL;\n"
         "  " << cClassName  << " *local_this = NULL;\n"
         "  if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"
         "  if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"
-        "    return NULL;\n"
+        "    return -1;\n"
         "  }\n"
         "  }\n"
         "  return (Py_ssize_t)" << len_remap->get_call_str("local_this", pexprs) << ";\n";
         "  return (Py_ssize_t)" << len_remap->get_call_str("local_this", pexprs) << ";\n";
     } else {
     } else {

+ 0 - 2
dtool/src/interrogatedb/py_panda.cxx

@@ -172,7 +172,6 @@ void *DTOOL_Call_GetPointerThis(PyObject *self) {
   return NULL;
   return NULL;
 }
 }
 
 
-#ifndef NDEBUG
 /**
 /**
  * This is similar to a PyErr_Occurred() check, except that it also checks
  * This is similar to a PyErr_Occurred() check, except that it also checks
  * Notify to see if an assertion has occurred.  If that is the case, then it
  * Notify to see if an assertion has occurred.  If that is the case, then it
@@ -193,7 +192,6 @@ bool _Dtool_CheckErrorOccurred() {
   }
   }
   return false;
   return false;
 }
 }
-#endif  // NDEBUG
 
 
 /**
 /**
  * Raises an AssertionError containing the last thrown assert message, and
  * Raises an AssertionError containing the last thrown assert message, and

+ 8 - 3
makepanda/makepandacore.py

@@ -16,10 +16,10 @@ else:
     import cPickle as pickle
     import cPickle as pickle
     import thread
     import thread
 
 
-SUFFIX_INC = [".cxx",".c",".h",".I",".yxx",".lxx",".mm",".rc",".r"]
+SUFFIX_INC = [".cxx",".cpp",".c",".h",".I",".yxx",".lxx",".mm",".rc",".r"]
 SUFFIX_DLL = [".dll",".dlo",".dle",".dli",".dlm",".mll",".exe",".pyd",".ocx"]
 SUFFIX_DLL = [".dll",".dlo",".dle",".dli",".dlm",".mll",".exe",".pyd",".ocx"]
 SUFFIX_LIB = [".lib",".ilb"]
 SUFFIX_LIB = [".lib",".ilb"]
-VCS_DIRS = set(["CVS", "CVSROOT", ".git", ".hg"])
+VCS_DIRS = set(["CVS", "CVSROOT", ".git", ".hg", "__pycache__"])
 VCS_FILES = set([".cvsignore", ".gitignore", ".gitmodules", ".hgignore"])
 VCS_FILES = set([".cvsignore", ".gitignore", ".gitmodules", ".hgignore"])
 STARTTIME = time.time()
 STARTTIME = time.time()
 MAINTHREAD = threading.currentThread()
 MAINTHREAD = threading.currentThread()
@@ -1392,7 +1392,12 @@ def PkgConfigGetDefSymbols(pkgname, tool = "pkg-config"):
     for l in result.split(" "):
     for l in result.split(" "):
         if (l.startswith("-D")):
         if (l.startswith("-D")):
             d = l.replace("-D", "").replace("\"", "").strip().split("=")
             d = l.replace("-D", "").replace("\"", "").strip().split("=")
-            if (len(d) == 1):
+
+            if d[0] in ('NDEBUG', '_DEBUG'):
+                # Setting one of these flags by accident could cause serious harm.
+                if GetVerbose():
+                    print("Ignoring %s flag provided by %s" % (l, tool))
+            elif len(d) == 1:
                 defs[d[0]] = ""
                 defs[d[0]] = ""
             else:
             else:
                 defs[d[0]] = d[1]
                 defs[d[0]] = d[1]

+ 1 - 1
panda/src/egg/eggCompositePrimitive.h

@@ -38,7 +38,7 @@ PUBLISHED:
   MAKE_SEQ(get_components, get_num_components, get_component);
   MAKE_SEQ(get_components, get_num_components, get_component);
   INLINE void set_component(int i, const EggAttributes *attrib);
   INLINE void set_component(int i, const EggAttributes *attrib);
 
 
-  MAKE_PROPERTY(components, get_num_components, get_component, set_component);
+  MAKE_SEQ_PROPERTY(components, get_num_components, get_component, set_component);
 
 
   INLINE bool triangulate_into(EggGroupNode *container) const;
   INLINE bool triangulate_into(EggGroupNode *container) const;
   PT(EggCompositePrimitive) triangulate_in_place();
   PT(EggCompositePrimitive) triangulate_in_place();

+ 2 - 2
panda/src/express/pointerTo.I

@@ -15,7 +15,7 @@
  *
  *
  */
  */
 template<class T>
 template<class T>
-INLINE PointerTo<T>::
+ALWAYS_INLINE PointerTo<T>::
 PointerTo(To *ptr) : PointerToBase<T>(ptr) {
 PointerTo(To *ptr) : PointerToBase<T>(ptr) {
 }
 }
 
 
@@ -136,7 +136,7 @@ operator = (const PointerTo<T> &copy) {
  *
  *
  */
  */
 template<class T>
 template<class T>
-INLINE ConstPointerTo<T>::
+ALWAYS_INLINE ConstPointerTo<T>::
 ConstPointerTo(const TYPENAME ConstPointerTo<T>::To *ptr) :
 ConstPointerTo(const TYPENAME ConstPointerTo<T>::To *ptr) :
   PointerToBase<T>((TYPENAME ConstPointerTo<T>::To *)ptr)
   PointerToBase<T>((TYPENAME ConstPointerTo<T>::To *)ptr)
 {
 {

+ 4 - 2
panda/src/express/pointerTo.h

@@ -58,7 +58,8 @@ class PointerTo : public PointerToBase<T> {
 public:
 public:
   typedef TYPENAME PointerToBase<T>::To To;
   typedef TYPENAME PointerToBase<T>::To To;
 PUBLISHED:
 PUBLISHED:
-  INLINE PointerTo(To *ptr = (To *)NULL);
+  ALWAYS_INLINE PointerTo() DEFAULT_CTOR;
+  ALWAYS_INLINE PointerTo(To *ptr);
   INLINE PointerTo(const PointerTo<T> &copy);
   INLINE PointerTo(const PointerTo<T> &copy);
   INLINE ~PointerTo();
   INLINE ~PointerTo();
 
 
@@ -119,7 +120,8 @@ class ConstPointerTo : public PointerToBase<T> {
 public:
 public:
   typedef TYPENAME PointerToBase<T>::To To;
   typedef TYPENAME PointerToBase<T>::To To;
 PUBLISHED:
 PUBLISHED:
-  INLINE ConstPointerTo(const To *ptr = (const To *)NULL);
+  ALWAYS_INLINE ConstPointerTo() DEFAULT_CTOR;
+  ALWAYS_INLINE ConstPointerTo(const To *ptr);
   INLINE ConstPointerTo(const PointerTo<T> &copy);
   INLINE ConstPointerTo(const PointerTo<T> &copy);
   INLINE ConstPointerTo(const ConstPointerTo<T> &copy);
   INLINE ConstPointerTo(const ConstPointerTo<T> &copy);
   INLINE ~ConstPointerTo();
   INLINE ~ConstPointerTo();

+ 23 - 3
panda/src/express/pointerToBase.I

@@ -17,7 +17,15 @@
 template<class T>
 template<class T>
 INLINE PointerToBase<T>::
 INLINE PointerToBase<T>::
 PointerToBase(To *ptr) {
 PointerToBase(To *ptr) {
-  reassign(ptr);
+  _void_ptr = (void *)ptr;
+  if (ptr != (To *)NULL) {
+    ptr->ref();
+#ifdef DO_MEMORY_USAGE
+    if (MemoryUsage::get_track_memory_usage()) {
+      update_type(ptr);
+    }
+#endif
+  }
 }
 }
 
 
 /**
 /**
@@ -26,7 +34,16 @@ PointerToBase(To *ptr) {
 template<class T>
 template<class T>
 INLINE PointerToBase<T>::
 INLINE PointerToBase<T>::
 PointerToBase(const PointerToBase<T> &copy) {
 PointerToBase(const PointerToBase<T> &copy) {
-  reassign(copy);
+  _void_ptr = copy._void_ptr;
+  if (_void_ptr != NULL) {
+    To *ptr = (To *)_void_ptr;
+    ptr->ref();
+#ifdef DO_MEMORY_USAGE
+    if (MemoryUsage::get_track_memory_usage()) {
+      update_type(ptr);
+    }
+#endif
+  }
 }
 }
 
 
 /**
 /**
@@ -35,7 +52,10 @@ PointerToBase(const PointerToBase<T> &copy) {
 template<class T>
 template<class T>
 INLINE PointerToBase<T>::
 INLINE PointerToBase<T>::
 ~PointerToBase() {
 ~PointerToBase() {
-  reassign((To *)NULL);
+  if (_void_ptr != NULL) {
+    unref_delete((To *)_void_ptr);
+    _void_ptr = NULL;
+  }
 }
 }
 
 
 #ifdef USE_MOVE_SEMANTICS
 #ifdef USE_MOVE_SEMANTICS

+ 1 - 0
panda/src/express/pointerToBase.h

@@ -31,6 +31,7 @@ public:
   typedef T To;
   typedef T To;
 
 
 protected:
 protected:
+  ALWAYS_INLINE PointerToBase() DEFAULT_CTOR;
   INLINE PointerToBase(To *ptr);
   INLINE PointerToBase(To *ptr);
   INLINE PointerToBase(const PointerToBase<T> &copy);
   INLINE PointerToBase(const PointerToBase<T> &copy);
   INLINE ~PointerToBase();
   INLINE ~PointerToBase();

+ 0 - 2
panda/src/pnmimagetypes/pnmFileTypeStbImage.h

@@ -22,8 +22,6 @@
 #include "pnmReader.h"
 #include "pnmReader.h"
 #include "pnmWriter.h"
 #include "pnmWriter.h"
 
 
-#include "stb_image.h"
-
 /**
 /**
  * For reading images via the public domain stb_image.h library.  This is used
  * For reading images via the public domain stb_image.h library.  This is used
  * when compiling without support for more specific libraries that are more
  * when compiling without support for more specific libraries that are more

+ 0 - 10
panda/src/putil/buttonHandle.I

@@ -11,16 +11,6 @@
  * @date 2000-03-01
  * @date 2000-03-01
  */
  */
 
 
-/**
- * The default constructor must do nothing, because we can't guarantee
- * ordering of static initializers.  If the constructor tried to initialize
- * its value, it might happen after the value had already been set previously
- * by another static initializer!
- */
-INLINE ButtonHandle::
-ButtonHandle() {
-}
-
 /**
 /**
  * Constructs a ButtonHandle with the corresponding index number, which may
  * Constructs a ButtonHandle with the corresponding index number, which may
  * have been returned by an earlier call to ButtonHandle::get_index().
  * have been returned by an earlier call to ButtonHandle::get_index().

+ 5 - 1
panda/src/putil/buttonHandle.h

@@ -25,7 +25,11 @@
  */
  */
 class EXPCL_PANDA_PUTIL ButtonHandle FINAL {
 class EXPCL_PANDA_PUTIL ButtonHandle FINAL {
 PUBLISHED:
 PUBLISHED:
-  INLINE ButtonHandle();
+  // The default constructor must do nothing, because we can't guarantee
+  // ordering of static initializers.  If the constructor tried to initialize
+  // its value, it  might happen after the value had already been set
+  // previously by another static initializer!
+  INLINE ButtonHandle() DEFAULT_CTOR;
   CONSTEXPR ButtonHandle(int index);
   CONSTEXPR ButtonHandle(int index);
   INLINE ButtonHandle(const ButtonHandle &copy);
   INLINE ButtonHandle(const ButtonHandle &copy);
   ButtonHandle(const string &name);
   ButtonHandle(const string &name);

+ 4 - 2
panda/src/putil/pythonCallbackObject.cxx

@@ -126,8 +126,10 @@ do_python_callback(CallbackData *cbdata) {
   Py_DECREF(args);
   Py_DECREF(args);
 
 
   if (result == (PyObject *)NULL) {
   if (result == (PyObject *)NULL) {
-    util_cat.error()
-      << "Exception occurred in " << *this << "\n";
+    if (PyErr_Occurred() != PyExc_SystemExit) {
+      util_cat.error()
+        << "Exception occurred in " << *this << "\n";
+    }
   } else {
   } else {
     Py_DECREF(result);
     Py_DECREF(result);
   }
   }

+ 2 - 0
panda/src/putil/pythonCallbackObject.h

@@ -34,6 +34,8 @@ PUBLISHED:
   void set_function(PyObject *function);
   void set_function(PyObject *function);
   PyObject *get_function();
   PyObject *get_function();
 
 
+  MAKE_PROPERTY(function, get_function, set_function);
+
 public:
 public:
   virtual void do_callback(CallbackData *cbdata);
   virtual void do_callback(CallbackData *cbdata);
 
 

+ 1 - 0
panda/src/recorder/mouseRecorder.h

@@ -77,6 +77,7 @@ public:
   virtual void write_datagram(BamWriter *manager, Datagram &dg);
   virtual void write_datagram(BamWriter *manager, Datagram &dg);
   virtual void write_recorder(BamWriter *manager, Datagram &dg);
   virtual void write_recorder(BamWriter *manager, Datagram &dg);
 
 
+  INLINE virtual int get_ref_count() const FINAL { return ReferenceCount::get_ref_count(); };
   INLINE virtual void ref() const FINAL { ReferenceCount::ref(); };
   INLINE virtual void ref() const FINAL { ReferenceCount::ref(); };
   INLINE virtual bool unref() const FINAL { return ReferenceCount::unref(); };
   INLINE virtual bool unref() const FINAL { return ReferenceCount::unref(); };
 
 

+ 1 - 0
panda/src/recorder/recorderBase.h

@@ -61,6 +61,7 @@ public:
 
 
   // We can't let RecorderBase inherit from ReferenceCount, so we define these
   // We can't let RecorderBase inherit from ReferenceCount, so we define these
   // so we can still manage the reference count.
   // so we can still manage the reference count.
+  virtual int get_ref_count() const=0;
   virtual void ref() const=0;
   virtual void ref() const=0;
   virtual bool unref() const=0;
   virtual bool unref() const=0;
 
 

+ 1 - 0
panda/src/recorder/socketStreamRecorder.h

@@ -74,6 +74,7 @@ public:
   static void register_with_read_factory();
   static void register_with_read_factory();
   virtual void write_recorder(BamWriter *manager, Datagram &dg);
   virtual void write_recorder(BamWriter *manager, Datagram &dg);
 
 
+  INLINE virtual int get_ref_count() const FINAL { return ReferenceCount::get_ref_count(); };
   INLINE virtual void ref() const FINAL { ReferenceCount::ref(); };
   INLINE virtual void ref() const FINAL { ReferenceCount::ref(); };
   INLINE virtual bool unref() const FINAL { return ReferenceCount::unref(); };
   INLINE virtual bool unref() const FINAL { return ReferenceCount::unref(); };