summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Dywan <christian@twotoasts.de>2018-08-09 12:02:08 +0200
committerGitHub <noreply@github.com>2018-08-09 12:02:08 +0200
commita47795769ffa59adb78055f0e128544211ab52c5 (patch)
tree8689e3a24bbd78857f39b48cad21ac7b6326cc62
parent5fee183fcc4d8bcc57e1074ecb68452a4b11a19a (diff)
downloadmidori-git-a47795769ffa59adb78055f0e128544211ab52c5.tar.gz
Store Loggable state in object data (#10)
Using static variables is wrong here because they're shared by all implementors of the interface.
-rw-r--r--core/loggable.vala8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/loggable.vala b/core/loggable.vala
index 88854791..ea93c8d3 100644
--- a/core/loggable.vala
+++ b/core/loggable.vala
@@ -11,16 +11,17 @@
namespace Midori {
public interface Loggable : Object {
- static string? _domain = null;
- static bool? _logging = null;
public string domain { owned get {
+ string? _domain = get_data<string> ("midori-domain");
if (_domain == null) {
_domain = get_type ().name ().substring (6, -1).down ();
+ set_data<string> ("midori-domain", _domain);
}
return _domain;
} }
- public bool logging { get {
+ public bool logging { owned get {
+ bool? _logging = get_data<bool?> ("midori-logging");
if (_logging == null) {
uint flag = int.MAX;
foreach (var key in keys) {
@@ -31,6 +32,7 @@ namespace Midori {
string debug_string = Environment.get_variable ("G_MESSAGES_DEBUG");
uint flags = parse_debug_string (debug_string, keys);
_logging = (flags & flag) != 0;
+ set_data<bool?> ("midori-logging", _logging);
}
return _logging;
} }