Bug 1118164 - Tracelogging: Don't fail if there is no logger, r=bbouvier
authorHannes Verschore <hv1989@gmail.com>
Wed, 07 Jan 2015 11:14:29 +0100
changeset 235458 39b05ad67a2f1cf14b76c349a40e9718949de383
parent 235457 6e4dce410c272c458fd4772644e759d043ba0e8b
child 235459 839f6e4f322a626c9565455e29988ecbb3b9f407
push id366
push usercmanchester@mozilla.com
push dateThu, 08 Jan 2015 16:40:24 +0000
reviewersbbouvier
bugs1118164
milestone37.0a1
Bug 1118164 - Tracelogging: Don't fail if there is no logger, r=bbouvier
js/src/vm/TraceLogging.cpp
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -882,41 +882,53 @@ js::TraceLogEnableTextId(JSContext *cx, 
 void
 js::TraceLogDisableTextId(JSContext *cx, uint32_t textId)
 {
     traceLoggers.disableTextId(cx, textId);
 }
 
 TraceLoggerEvent::TraceLoggerEvent(TraceLoggerThread *logger, TraceLoggerTextId textId)
 {
-    payload_ = logger->getOrCreateEventPayload(textId);
-    if (payload_)
-        payload_->use();
+    payload_ = nullptr;
+    if (logger) {
+        payload_ = logger->getOrCreateEventPayload(textId);
+        if (payload_)
+            payload_->use();
+    }
 }
 
 TraceLoggerEvent::TraceLoggerEvent(TraceLoggerThread *logger, TraceLoggerTextId type,
                                    JSScript *script)
 {
-    payload_ = logger->getOrCreateEventPayload(type, script);
-    if (payload_)
-        payload_->use();
+    payload_ = nullptr;
+    if (logger) {
+        payload_ = logger->getOrCreateEventPayload(type, script);
+        if (payload_)
+            payload_->use();
+    }
 }
 
 TraceLoggerEvent::TraceLoggerEvent(TraceLoggerThread *logger, TraceLoggerTextId type,
                                    const JS::ReadOnlyCompileOptions &compileOptions)
 {
-    payload_ = logger->getOrCreateEventPayload(type, compileOptions);
-    if (payload_)
-        payload_->use();
+    payload_ = nullptr;
+    if (logger) {
+        payload_ = logger->getOrCreateEventPayload(type, compileOptions);
+        if (payload_)
+            payload_->use();
+    }
 }
 
 TraceLoggerEvent::TraceLoggerEvent(TraceLoggerThread *logger, const char *text)
 {
-    payload_ = logger->getOrCreateEventPayload(text);
-    if (payload_)
-        payload_->use();
+    payload_ = nullptr;
+    if (logger) {
+        payload_ = logger->getOrCreateEventPayload(text);
+        if (payload_)
+            payload_->use();
+    }
 }
 
 TraceLoggerEvent::~TraceLoggerEvent()
 {
     if (payload_)
         payload_->release();
 }