diff --git a/dtool/src/dconfig/configTable.cxx b/dtool/src/dconfig/configTable.cxx index d4470d4835..58bcbb0947 100644 --- a/dtool/src/dconfig/configTable.cxx +++ b/dtool/src/dconfig/configTable.cxx @@ -590,6 +590,7 @@ ConfigTable* ConfigTable::Instance(void) { _instance = new ConfigTable; _instance->GetData(); _instance->_initializing = false; + Notify::ptr()->config_initialized(); } return _instance; } diff --git a/dtool/src/dconfig/notify.cxx b/dtool/src/dconfig/notify.cxx index 942baa01a4..a605ff6b4c 100644 --- a/dtool/src/dconfig/notify.cxx +++ b/dtool/src/dconfig/notify.cxx @@ -7,6 +7,8 @@ #include "config_notify.h" #include "dconfig.h" +#include + #include Notify *Notify::_global_ptr = (Notify *)NULL; @@ -436,3 +438,36 @@ string_severity(const string &str) { return NS_unspecified; } } + +//////////////////////////////////////////////////////////////////// +// Function: Notify::config_initialized +// Access: Public +// Description: Intended to be called only by Config, this is a +// callback that indicated to Notify when Config has +// done initializing and Notify can safely set up some +// internal state variables that depend on Config +// variables. +//////////////////////////////////////////////////////////////////// +void Notify:: +config_initialized() { + static bool already_initialized = false; + if (already_initialized) { + nout << "Notify::config_initialized() called more than once.\n"; + return; + } + already_initialized = true; + + if (_ostream_ptr == &cerr) { + Filename notify_output = config_notify.GetString("notify-output", ""); + if (!notify_output.empty()) { + notify_output.set_text(); + ofstream *out = new ofstream; + if (!notify_output.open_write(*out)) { + nout << "Unable to open file " << notify_output << " for output.\n"; + delete out; + } else { + set_ostream_ptr(out, true); + } + } + } +} diff --git a/dtool/src/dconfig/notify.h b/dtool/src/dconfig/notify.h index 5147ea4c37..bb5f4cb6f3 100644 --- a/dtool/src/dconfig/notify.h +++ b/dtool/src/dconfig/notify.h @@ -61,6 +61,7 @@ PUBLISHED: static void write_string(const string &str); static Notify *ptr(); +public: static long get_literal_flag(); bool assert_failure(const char *expression, int line, @@ -68,6 +69,8 @@ PUBLISHED: static NotifySeverity string_severity(const string &string); + void config_initialized(); + private: ostream *_ostream_ptr; bool _owns_ostream_ptr;