Browse Source

static init issues

David Rose 17 years ago
parent
commit
f086784b4f

+ 0 - 35
panda/src/express/config_express.cxx

@@ -66,41 +66,6 @@ ConfigVariableInt multifile_encryption_iteration_count
           "be loaded quickly, without paying the cost of an expensive hash on "
           "each subfile in order to decrypt it."));
 
-ConfigVariableBool vfs_case_sensitive
-("vfs-case-sensitive", true,
- PRC_DESC("Set this true to make the VirtualFileSystem present the native "
-          "OS-provided filesystem as if it were a case-sensitive file "
-          "system, even if it is not (e.g. on Windows).  This variable "
-          "has no effect if the native filesystem is already case-sensitive, "
-          "and it has no effect on mounted multifile systems, which are "
-          "always case-sensitive."));
-
-ConfigVariableBool vfs_implicit_pz
-("vfs-implicit-pz", true,
- PRC_DESC("When this is true, the VirtualFileSystem will pretend a named "
-          "file exists even if it doesn't, as long as a filename with the "
-          "same name and the additional extension .pz does exist.  In this "
-          "case, the VirtualFileSystem will implicitly open the .pz file "
-          "and decompress it on-the-fly."));
-
-ConfigVariableBool vfs_implicit_mf
-("vfs-implicit-mf", true,
- PRC_DESC("When this is true, the VirtualFileSystem will automatically "
-          "mount multifiles on-the-fly when they are used as directories.  "
-          "For instance, opening the file /c/files/foo.mf/dirname/mytex.jpg "
-          "will implicitly retrieve a file named 'dirname/mytex.jpg' "
-          "within the multifile /c/files/foo.mf, even if the multifile "
-          "has not already been mounted.  This makes all of your multifiles "
-          "act like directories."));
-
-ConfigVariableBool use_vfs
-("use-vfs", true,
- PRC_DESC("Set this true to use the VirtualFileSystem mechanism for loading "
-          "models, etc.  Since the VirtualFileSystem is now the de facto "
-          "filesystem for Panda, you should always keep this true, since "
-          "there is now code that assumes it to be true.  This variable "
-          "is now deprecated."));
-
 ConfigVariableBool collect_tcp
 ("collect-tcp", false,
  PRC_DESC("Set this true to enable accumulation of several small consecutive "

+ 0 - 6
panda/src/express/config_express.h

@@ -47,12 +47,6 @@ extern ConfigVariableBool keep_temporary_files;
 
 extern ConfigVariableInt multifile_encryption_iteration_count;
 
-extern ConfigVariableBool vfs_case_sensitive;
-extern ConfigVariableBool vfs_implicit_pz;
-extern ConfigVariableBool vfs_implicit_mf;
-
-extern EXPCL_PANDAEXPRESS ConfigVariableBool use_vfs;
-
 extern EXPCL_PANDAEXPRESS ConfigVariableBool collect_tcp;
 extern EXPCL_PANDAEXPRESS ConfigVariableDouble collect_tcp_interval;
 

+ 5 - 5
panda/src/express/virtualFileMountSystem.cxx

@@ -27,7 +27,7 @@ bool VirtualFileMountSystem::
 has_file(const Filename &file) const {
   Filename pathname(_physical_filename, file);
 #ifdef WIN32
-  if (vfs_case_sensitive) {
+  if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) {
     Filename case_pathname = pathname;
     if (!case_pathname.make_true_case()) {
       return false;
@@ -53,7 +53,7 @@ bool VirtualFileMountSystem::
 is_directory(const Filename &file) const {
 #ifdef WIN32
   // First ensure that the file exists to validate its case.
-  if (vfs_case_sensitive) {
+  if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) {
     if (!has_file(file)) {
       return false;
     }
@@ -73,7 +73,7 @@ bool VirtualFileMountSystem::
 is_regular_file(const Filename &file) const {
 #ifdef WIN32
   // First ensure that the file exists to validate its case.
-  if (vfs_case_sensitive) {
+  if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) {
     if (!has_file(file)) {
       return false;
     }
@@ -95,7 +95,7 @@ istream *VirtualFileMountSystem::
 open_read_file(const Filename &file) const {
 #ifdef WIN32
   // First ensure that the file exists to validate its case.
-  if (vfs_case_sensitive) {
+  if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) {
     if (!has_file(file)) {
       return NULL;
     }
@@ -185,7 +185,7 @@ bool VirtualFileMountSystem::
 scan_directory(vector_string &contents, const Filename &dir) const {
 #ifdef WIN32
   // First ensure that the file exists to validate its case.
-  if (vfs_case_sensitive) {
+  if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) {
     if (!has_file(dir)) {
       return false;
     }

+ 29 - 1
panda/src/express/virtualFileSystem.cxx

@@ -33,7 +33,32 @@ VirtualFileSystem *VirtualFileSystem::_global_ptr = NULL;
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 VirtualFileSystem::
-VirtualFileSystem() {
+VirtualFileSystem() :
+  vfs_case_sensitive
+("vfs-case-sensitive", true,
+ PRC_DESC("Set this true to make the VirtualFileSystem present the native "
+          "OS-provided filesystem as if it were a case-sensitive file "
+          "system, even if it is not (e.g. on Windows).  This variable "
+          "has no effect if the native filesystem is already case-sensitive, "
+          "and it has no effect on mounted multifile systems, which are "
+          "always case-sensitive.")),
+  vfs_implicit_pz
+  ("vfs-implicit-pz", true,
+   PRC_DESC("When this is true, the VirtualFileSystem will pretend a named "
+            "file exists even if it doesn't, as long as a filename with the "
+            "same name and the additional extension .pz does exist.  In this "
+            "case, the VirtualFileSystem will implicitly open the .pz file "
+            "and decompress it on-the-fly.")),
+  vfs_implicit_mf
+  ("vfs-implicit-mf", true,
+   PRC_DESC("When this is true, the VirtualFileSystem will automatically "
+            "mount multifiles on-the-fly when they are used as directories.  "
+            "For instance, opening the file /c/files/foo.mf/dirname/mytex.jpg "
+            "will implicitly retrieve a file named 'dirname/mytex.jpg' "
+            "within the multifile /c/files/foo.mf, even if the multifile "
+            "has not already been mounted.  This makes all of your multifiles "
+            "act like directories."))
+{
   _cwd = "/";
   _mount_seq = 0;
 }
@@ -570,6 +595,9 @@ write(ostream &out) const {
 VirtualFileSystem *VirtualFileSystem::
 get_global_ptr() {
   if (_global_ptr == (VirtualFileSystem *)NULL) {
+    // Make sure this is initialized.
+    init_libexpress();
+
     _global_ptr = new VirtualFileSystem;
     
     // Set up the default mounts.  First, there is always the root

+ 8 - 0
panda/src/express/virtualFileSystem.h

@@ -98,6 +98,14 @@ public:
   static void parse_option(const string &option,
                            int &flags, string &password);
 
+public:
+  // These are declared as class instances, instead of as globals, to
+  // guarantee they will be initialized by the time the
+  // VirtualFileSystem's constructor runs.
+  ConfigVariableBool vfs_case_sensitive;
+  ConfigVariableBool vfs_implicit_pz;
+  ConfigVariableBool vfs_implicit_mf;
+
 private:
   Filename normalize_mount_point(const string &mount_point) const;
   bool do_mount(VirtualFileMount *mount, const string &mount_point, int flags);