diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index c7baf7484c..9386c77f76 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -58,7 +58,7 @@ PT(AudioManager) AudioManager::create_AudioManager() { "lib"+string(audio_library_name)+".so"); dl_name.to_os_specific(); audio_debug(" dl_name=\""<info() << "loading texture filter: " << dlname.to_os_specific() << endl; - void *tmp = load_dso(plugin_path.get_value(), dlname); + void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == (void *)NULL) { gobj_cat.info() << "Unable to load: " << load_dso_error() << endl; diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 7149f583bd..c5ac5b35d1 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -199,6 +199,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { if (search) { // Look for the file along the model path. + const ConfigVariableSearchPath &model_path = get_model_path(); int num_dirs = model_path.get_num_directories(); for (int i = 0; i < num_dirs; ++i) { Filename pathname(model_path.get_directory(i), this_filename); @@ -348,7 +349,7 @@ load_file_types() { Filename dlname = Filename::dso_filename("lib" + name + ".so"); loader_cat.info() << "loading file type module: " << name << endl; - void *tmp = load_dso(plugin_path.get_value(), dlname); + void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == (void *)NULL) { loader_cat.warning() << "Unable to load " << dlname.to_os_specific() diff --git a/panda/src/pgraph/loaderFileTypeRegistry.cxx b/panda/src/pgraph/loaderFileTypeRegistry.cxx index b9a992e75b..742cd20014 100644 --- a/panda/src/pgraph/loaderFileTypeRegistry.cxx +++ b/panda/src/pgraph/loaderFileTypeRegistry.cxx @@ -170,7 +170,7 @@ get_type_from_extension(const string &extension) { loader_cat->info() << "loading file type module: " << name << endl; - void *tmp = load_dso(plugin_path.get_value(), dlname); + void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == (void *)NULL) { loader_cat->warning() << "Unable to load " << dlname.to_os_specific() << ": " diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index edc3e9861b..baf71a8744 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -61,25 +61,6 @@ ConfigVariableEnum bam_texture_mode PRC_DESC("Set this to specify how textures should be written into Bam files." "See the panda source or documentation for available options.")); -ConfigVariableSearchPath model_path -("model-path", - PRC_DESC("The default directories to search for all models and general " - "files loaded into Panda.")); - -ConfigVariableSearchPath texture_path -("texture-path", - PRC_DESC("A special directory path to search for textures only. " - "Textures are also searched for along the model-path, so the " - "use of texture-path is only useful if you have special " - "directories that only contain textures.")); - -ConfigVariableSearchPath sound_path -("sound-path", - PRC_DESC("The directories to search for sound and music files to be loaded.")); -ConfigVariableSearchPath plugin_path -("plugin-path", "", - PRC_DESC("The directories to search for plugin shared libraries.")); - ConfigureFn(config_util) { @@ -96,27 +77,56 @@ ConfigureFn(config_util) { // // ConfigVariableBool track_memory_usage("track-memory-usage", false); -// There is no longer any need for C++ code to call these functions to -// access the various path variables; instead, new C++ code should -// just access the path variables directly. ConfigVariableSearchPath & get_model_path() { - return model_path; + static ConfigVariableSearchPath *model_path = NULL; + if (model_path == NULL) { + model_path = new ConfigVariableSearchPath + ("model-path", + PRC_DESC("The default directories to search for all models and general " + "files loaded into Panda.")); + } + + return *model_path; } ConfigVariableSearchPath & get_texture_path() { - return texture_path; + static ConfigVariableSearchPath *texture_path = NULL; + if (texture_path == NULL) { + texture_path = new ConfigVariableSearchPath + ("texture-path", + PRC_DESC("A special directory path to search for textures only. " + "Textures are also searched for along the model-path, so the " + "use of texture-path is only useful if you have special " + "directories that only contain textures.")); + } + + return *texture_path; } ConfigVariableSearchPath & get_sound_path() { - return sound_path; + static ConfigVariableSearchPath *sound_path = NULL; + if (sound_path == NULL) { + sound_path = new ConfigVariableSearchPath + ("sound-path", + PRC_DESC("The directories to search for sound and music files to be loaded.")); + } + + return *sound_path; } ConfigVariableSearchPath & get_plugin_path() { - return plugin_path; + static ConfigVariableSearchPath *plugin_path = NULL; + if (plugin_path == NULL) { + plugin_path = new ConfigVariableSearchPath + ("plugin-path", "", + PRC_DESC("The directories to search for plugin shared libraries.")); + } + + return *plugin_path; } ConfigVariableDouble sleep_precision diff --git a/panda/src/putil/config_util.h b/panda/src/putil/config_util.h index e498d95a83..798c7e7c03 100644 --- a/panda/src/putil/config_util.h +++ b/panda/src/putil/config_util.h @@ -39,13 +39,6 @@ NotifyCategoryDecl(bam, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); extern EXPCL_PANDA_PUTIL ConfigVariableEnum bam_endian; extern EXPCL_PANDA_PUTIL ConfigVariableEnum bam_texture_mode; -extern EXPCL_PANDA_PUTIL ConfigVariableSearchPath model_path; -extern EXPCL_PANDA_PUTIL ConfigVariableSearchPath texture_path; -extern EXPCL_PANDA_PUTIL ConfigVariableSearchPath sound_path; -extern EXPCL_PANDA_PUTIL ConfigVariableSearchPath plugin_path; - -// The above variables are also shadowed by these functions, so that -// they can easily be accessed in the interpreter (e.g. Python). BEGIN_PUBLISH EXPCL_PANDA_PUTIL ConfigVariableSearchPath &get_model_path(); EXPCL_PANDA_PUTIL ConfigVariableSearchPath &get_texture_path(); diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index e3d0aad571..26a92a4be4 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -2279,7 +2279,7 @@ get_icon(const Filename &filename) { // filename, we can't load a virtual file and we can't use the // virtual file system. Filename resolved = filename; - if (!resolved.resolve_filename(model_path)) { + if (!resolved.resolve_filename(get_model_path())) { // The filename doesn't exist. windisplay_cat.warning() << "Could not find icon filename " << filename << "\n"; @@ -2326,7 +2326,7 @@ get_cursor(const Filename &filename) { // filename, we can't load a virtual file and we can't use the // virtual file system. Filename resolved = filename; - if (!resolved.resolve_filename(model_path)) { + if (!resolved.resolve_filename(get_model_path())) { // The filename doesn't exist. windisplay_cat.warning() << "Could not find cursor filename " << filename << "\n"; diff --git a/pandatool/src/egg-palettize/txaFileFilter.cxx b/pandatool/src/egg-palettize/txaFileFilter.cxx index b16ac1772a..06693d9490 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.cxx +++ b/pandatool/src/egg-palettize/txaFileFilter.cxx @@ -132,8 +132,8 @@ read_txa_file() { "is in effect.")); Filename filename = txa_file; - vfs->resolve_filename(filename, texture_path); - vfs->resolve_filename(filename, model_path); + vfs->resolve_filename(filename, get_texture_path()); + vfs->resolve_filename(filename, get_model_path()); if (!vfs->exists(filename)) { txafile_cat.warning()