[Lldb-commits] [lldb] r149145 - in /lldb/trunk: include/lldb/Core/UserSettingsController.h source/Core/UserSettingsController.cpp

Johnny Chen johnny.chen at apple.com
Fri Jan 27 13:27:40 PST 2012


Author: johnny
Date: Fri Jan 27 15:27:39 2012
New Revision: 149145

URL: http://llvm.org/viewvc/llvm-project?rev=149145&view=rev
Log:
Add an InstanceSettings::NotifyOwnerIsShuttingDown() method so that the owner can notify InstanceSettings instances
that their owner reference is no longer valid.

Modified:
    lldb/trunk/include/lldb/Core/UserSettingsController.h
    lldb/trunk/source/Core/UserSettingsController.cpp

Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=149145&r1=149144&r2=149145&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UserSettingsController.h (original)
+++ lldb/trunk/include/lldb/Core/UserSettingsController.h Fri Jan 27 15:27:39 2012
@@ -400,6 +400,9 @@
     // Begin Pure Virtual Functions
 
     virtual void
+    NotifyOwnerIsShuttingDown ();
+
+    virtual void
     UpdateInstanceSettingsVariable (const ConstString &var_name,
                                     const char *index_value,
                                     const char *value,
@@ -440,6 +443,7 @@
 protected:
 
     UserSettingsController &m_owner;
+    bool m_owner_is_live;
     ConstString m_instance_name;
 };
 

Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=149145&r1=149144&r2=149145&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Fri Jan 27 15:27:39 2012
@@ -83,6 +83,10 @@
 UserSettingsController::~UserSettingsController ()
 {
     Mutex::Locker locker (m_live_settings_mutex);
+
+    // Notify all instance settings that their owner is shutting down, first.
+    for (InstanceSettingsMap::iterator pos = m_live_settings.begin(); pos != m_live_settings.end(); ++pos)
+        pos->second->NotifyOwnerIsShuttingDown();
     m_live_settings.clear();
 }
 
@@ -2458,7 +2462,8 @@
 
 InstanceSettings::InstanceSettings (UserSettingsController &owner, const char *instance_name, bool live_instance) :
     m_owner (owner),
-    m_instance_name (instance_name)
+    m_instance_name (instance_name),
+    m_owner_is_live (true)
 {
     if ((m_instance_name != InstanceSettings::GetDefaultName())
         && (m_instance_name !=  InstanceSettings::InvalidName())
@@ -2468,10 +2473,16 @@
 
 InstanceSettings::~InstanceSettings ()
 {
-    if (m_instance_name != InstanceSettings::GetDefaultName())
+    if (m_instance_name != InstanceSettings::GetDefaultName() && m_owner_is_live)
         m_owner.UnregisterInstanceSettings (this);
 }
 
+void
+InstanceSettings::NotifyOwnerIsShuttingDown()
+{
+    m_owner_is_live = false;
+}
+
 const ConstString &
 InstanceSettings::GetDefaultName ()
 {





More information about the lldb-commits mailing list