summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2016-07-05 19:10:03 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-10-25 12:23:34 -0200
commit7869eeed530147f11035551c3a3fa1f12559570a (patch)
tree8541792cc04f4c978271996fc46458285bc5a6af /src/bindings
parentae3c74d879651a93a95bc83f5829a96459f6878f (diff)
eina_js: Fix log color persistence.
The c_ptr() passed to eina_log_register was being lost when saving the string into the map.
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/js/eina_js/eina_js_log.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bindings/js/eina_js/eina_js_log.cc b/src/bindings/js/eina_js/eina_js_log.cc
index 415a827..ac461d9 100644
--- a/src/bindings/js/eina_js/eina_js_log.cc
+++ b/src/bindings/js/eina_js/eina_js_log.cc
@@ -28,7 +28,7 @@ v8::Local<v8::String> to_v8_string(v8::Isolate *isolate, const char *fmt,
28} 28}
29 29
30static global_ref<v8::Value> js_eina_log_print_cb_data; 30static global_ref<v8::Value> js_eina_log_print_cb_data;
31static std::map<int, std::string> js_eina_log_color_map; 31static std::map<int, const char *> js_eina_log_color_map;
32 32
33static void js_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, 33static void js_eina_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level,
34 const char *file, const char *fnc, int line, 34 const char *file, const char *fnc, int line,
@@ -118,9 +118,9 @@ void register_log_domain_register(v8::Isolate *isolate,
118 118
119 // We duplicate the color string as eina takes a const char* but does take care of 119 // We duplicate the color string as eina takes a const char* but does take care of
120 // its lifetime, assuming a ever lasting string. 120 // its lifetime, assuming a ever lasting string.
121 std::string color = *String::Utf8Value(args[1]); 121 const char *color = strdup(*String::Utf8Value(args[1]));
122 int d = eina_log_domain_register(*String::Utf8Value(args[0]), 122 int d = eina_log_domain_register(*String::Utf8Value(args[0]),
123 color.c_str()); 123 color);
124 js_eina_log_color_map[d] = color; 124 js_eina_log_color_map[d] = color;
125 125
126 auto isolate = args.GetIsolate(); 126 auto isolate = args.GetIsolate();
@@ -146,6 +146,7 @@ void register_log_domain_unregister(v8::Isolate *isolate,
146 146
147 int domain = args[0]->NumberValue(); 147 int domain = args[0]->NumberValue();
148 eina_log_domain_unregister(domain); 148 eina_log_domain_unregister(domain);
149 free((void*)js_eina_log_color_map[domain]);
149 js_eina_log_color_map.erase(domain); 150 js_eina_log_color_map.erase(domain);
150 return compatibility_return(); 151 return compatibility_return();
151 }; 152 };