瀏覽代碼

Auto temp logfile path

rdb 16 年之前
父節點
當前提交
af7827c42a
共有 3 個文件被更改,包括 37 次插入1 次删除
  1. 17 0
      direct/src/plugin/load_plugin.cxx
  2. 1 0
      direct/src/plugin/p3dX11SplashWindow.cxx
  3. 19 1
      direct/src/plugin_npapi/startup.cxx

+ 17 - 0
direct/src/plugin/load_plugin.cxx

@@ -292,7 +292,24 @@ load_plugin(const string &p3d_plugin_filename) {
   // Successfully loaded.
   plugin_loaded = true;
 
+#ifdef P3D_PLUGIN_LOGFILE2
   string logfilename = P3D_PLUGIN_LOGFILE2;
+#else
+  string logfilename;
+#endif  // P3D_PLUGIN_LOGFILE2
+
+  if (logfilename.empty()) {
+#ifdef _WIN32
+    static const size_t buffer_size = 4096;
+    char buffer[buffer_size];
+    if (GetTempPath(buffer_size, buffer) != 0) {
+      logfilename = buffer;
+      logfilename += "panda3d.2.log";
+    }
+#else
+    logfilename = "/tmp/panda3d.2.log";
+#endif  // _WIN32
+  }
 
   if (!P3D_initialize(P3D_API_VERSION, logfilename.c_str())) {
     // Oops, failure to initialize.

+ 1 - 0
direct/src/plugin/p3dX11SplashWindow.cxx

@@ -347,6 +347,7 @@ subprocess_run() {
       }
       _width = event.xconfigure.width;
       _height = event.xconfigure.height;
+      override = true;
     }
     
     double install_progress = _install_progress;

+ 19 - 1
direct/src/plugin_npapi/startup.cxx

@@ -28,7 +28,25 @@ static bool logfile_is_open = false;
 static void
 open_logfile() {
   if (!logfile_is_open) {
-    logfile.open(P3D_PLUGIN_LOGFILE1);
+#ifdef P3D_PLUGIN_LOGFILE1
+    string logfilename = P3D_PLUGIN_LOGFILE1;
+#else
+    string logfilename;
+#endif  // P3D_PLUGIN_LOGFILE1
+
+    if (logfilename.empty()) {
+#ifdef _WIN32
+      static const size_t buffer_size = 4096;
+      char buffer[buffer_size];
+      if (GetTempPath(buffer_size, buffer) != 0) {
+        logfilename = buffer;
+        logfilename += "panda3d.1.log";
+      }
+#else
+      logfilename = "/tmp/panda3d.1.log";
+#endif  // _WIN32
+    }
+    logfile.open(logfilename.c_str());
     logfile_is_open = true;
   }
 }