Explorar el Código

notify: make Notify::config_initialized() static

This may be slightly more efficient.
rdb hace 5 años
padre
commit
fd5ec07a47

+ 1 - 1
dtool/src/prc/configPageManager.cxx

@@ -720,7 +720,7 @@ scan_up_from(Filename &result, const Filename &dir,
  */
 void ConfigPageManager::
 config_initialized() {
-  Notify::ptr()->config_initialized();
+  Notify::config_initialized();
 
 #ifndef NDEBUG
   ConfigVariableString panda_package_version

+ 7 - 5
dtool/src/prc/notify.cxx

@@ -430,7 +430,7 @@ config_initialized() {
   // notify-output even after the initial import of Panda3D modules.  However,
   // it cannot be changed after the first time it is set.
 
-  if (_ostream_ptr == &cerr) {
+  if (_global_ptr == nullptr || _global_ptr->_ostream_ptr == &cerr) {
     static ConfigVariableFilename notify_output
       ("notify-output", "",
        "The filename to which to write all the output of notify");
@@ -440,12 +440,14 @@ config_initialized() {
 
     std::string value = notify_output.get_value();
     if (!value.empty() && !initialized.test_and_set()) {
+      Notify *ptr = Notify::ptr();
+
       if (value == "stdout") {
         cout.setf(std::ios::unitbuf);
-        set_ostream_ptr(&cout, false);
+        ptr->set_ostream_ptr(&cout, false);
 
       } else if (value == "stderr") {
-        set_ostream_ptr(&cerr, false);
+        ptr->set_ostream_ptr(&cerr, false);
 
       } else {
         Filename filename = value;
@@ -462,7 +464,7 @@ config_initialized() {
           dup2(logfile_fd, STDERR_FILENO);
           close(logfile_fd);
 
-          set_ostream_ptr(&cerr, false);
+          ptr->set_ostream_ptr(&cerr, false);
         }
 #else
         pofstream *out = new pofstream;
@@ -471,7 +473,7 @@ config_initialized() {
           delete out;
         } else {
           out->setf(std::ios::unitbuf);
-          set_ostream_ptr(out, true);
+          ptr->set_ostream_ptr(out, true);
         }
 #endif  // BUILD_IPHONE
       }

+ 2 - 2
dtool/src/prc/notifyCategory.cxx

@@ -184,11 +184,11 @@ update_severity_cache() {
 
       // Take this opportunity to have Notify check whether the notify-output
       // variable changed.
-      Notify::ptr()->config_initialized();
+      Notify::config_initialized();
     }
   } else {
     _severity_cache = _severity;
-    Notify::ptr()->config_initialized();
+    Notify::config_initialized();
   }
 
   mark_cache_valid(_local_modified);

+ 1 - 1
dtool/src/prc/pnotify.h

@@ -72,7 +72,7 @@ public:
 
   static NotifySeverity string_severity(const std::string &string);
 
-  void config_initialized();
+  static void config_initialized();
 
 private:
   std::ostream *_ostream_ptr;