Skip to content

Commit fd5ec07

Browse files
committed
notify: make Notify::config_initialized() static
This may be slightly more efficient.
1 parent df6c79f commit fd5ec07

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

dtool/src/prc/configPageManager.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ scan_up_from(Filename &result, const Filename &dir,
720720
*/
721721
void ConfigPageManager::
722722
config_initialized() {
723-
Notify::ptr()->config_initialized();
723+
Notify::config_initialized();
724724

725725
#ifndef NDEBUG
726726
ConfigVariableString panda_package_version

dtool/src/prc/notify.cxx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ config_initialized() {
430430
// notify-output even after the initial import of Panda3D modules. However,
431431
// it cannot be changed after the first time it is set.
432432

433-
if (_ostream_ptr == &cerr) {
433+
if (_global_ptr == nullptr || _global_ptr->_ostream_ptr == &cerr) {
434434
static ConfigVariableFilename notify_output
435435
("notify-output", "",
436436
"The filename to which to write all the output of notify");
@@ -440,12 +440,14 @@ config_initialized() {
440440

441441
std::string value = notify_output.get_value();
442442
if (!value.empty() && !initialized.test_and_set()) {
443+
Notify *ptr = Notify::ptr();
444+
443445
if (value == "stdout") {
444446
cout.setf(std::ios::unitbuf);
445-
set_ostream_ptr(&cout, false);
447+
ptr->set_ostream_ptr(&cout, false);
446448

447449
} else if (value == "stderr") {
448-
set_ostream_ptr(&cerr, false);
450+
ptr->set_ostream_ptr(&cerr, false);
449451

450452
} else {
451453
Filename filename = value;
@@ -462,7 +464,7 @@ config_initialized() {
462464
dup2(logfile_fd, STDERR_FILENO);
463465
close(logfile_fd);
464466

465-
set_ostream_ptr(&cerr, false);
467+
ptr->set_ostream_ptr(&cerr, false);
466468
}
467469
#else
468470
pofstream *out = new pofstream;
@@ -471,7 +473,7 @@ config_initialized() {
471473
delete out;
472474
} else {
473475
out->setf(std::ios::unitbuf);
474-
set_ostream_ptr(out, true);
476+
ptr->set_ostream_ptr(out, true);
475477
}
476478
#endif // BUILD_IPHONE
477479
}

dtool/src/prc/notifyCategory.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ update_severity_cache() {
184184

185185
// Take this opportunity to have Notify check whether the notify-output
186186
// variable changed.
187-
Notify::ptr()->config_initialized();
187+
Notify::config_initialized();
188188
}
189189
} else {
190190
_severity_cache = _severity;
191-
Notify::ptr()->config_initialized();
191+
Notify::config_initialized();
192192
}
193193

194194
mark_cache_valid(_local_modified);

dtool/src/prc/pnotify.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class EXPCL_DTOOL_PRC Notify {
7272

7373
static NotifySeverity string_severity(const std::string &string);
7474

75-
void config_initialized();
75+
static void config_initialized();
7676

7777
private:
7878
std::ostream *_ostream_ptr;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy