need to vector model_path etc. through function after all, to avoid static-init problems

This commit is contained in:
David Rose 2008-10-22 22:11:16 +00:00
parent 9831c3b93f
commit 8639f98ae9
9 changed files with 48 additions and 44 deletions

View File

@ -58,7 +58,7 @@ PT(AudioManager) AudioManager::create_AudioManager() {
"lib"+string(audio_library_name)+".so");
dl_name.to_os_specific();
audio_debug(" dl_name=\""<<dl_name<<"\"");
void* lib = load_dso(plugin_path.get_value(), dl_name);
void* lib = load_dso(get_plugin_path().get_value(), dl_name);
if (!lib) {
audio_error(" LoadLibrary() failed, will use NullAudioManager");
audio_error(" "<<load_dso_error());

View File

@ -403,7 +403,7 @@ load_named_module(const string &name) {
Filename dlname = Filename::dso_filename("lib" + name + ".so");
display_cat.info()
<< "loading display module: " << 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) {
display_cat.info()
<< "Unable to load: " << load_dso_error() << endl;

View File

@ -946,8 +946,8 @@ report_texture_unreadable(const Filename &filename) const {
// search path.
gobj_cat.error()
<< "Unable to find texture \"" << filename << "\""
<< " on texture_path " << texture_path
<< " or model_path " << model_path <<"\n";
<< " on texture_path " << get_texture_path()
<< " or model_path " << get_model_path() <<"\n";
} else {
// A fully-specified filename is not searched along the path, so
// don't mislead the user with the error message.
@ -1046,7 +1046,7 @@ load_filters() {
Filename dlname = Filename::dso_filename("lib" + name + ".so");
gobj_cat->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;

View File

@ -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()

View File

@ -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() << ": "

View File

@ -61,25 +61,6 @@ ConfigVariableEnum<BamTextureMode> 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", "<auto>",
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", "<auto>",
PRC_DESC("The directories to search for plugin shared libraries."));
}
return *plugin_path;
}
ConfigVariableDouble sleep_precision

View File

@ -39,13 +39,6 @@ NotifyCategoryDecl(bam, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL);
extern EXPCL_PANDA_PUTIL ConfigVariableEnum<BamEndian> bam_endian;
extern EXPCL_PANDA_PUTIL ConfigVariableEnum<BamTextureMode> 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();

View File

@ -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";

View File

@ -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()