Browse Source

Merge pull request #200 from viciious/controlsfix

Reset data_source to NULL upon detaching
David Wimsey 11 years ago
parent
commit
98f8411598
1 changed files with 6 additions and 2 deletions
  1. 6 2
      Source/Controls/ElementFormControlDataSelect.cpp

+ 6 - 2
Source/Controls/ElementFormControlDataSelect.cpp

@@ -43,8 +43,10 @@ ElementFormControlDataSelect::ElementFormControlDataSelect(const Rocket::Core::S
 
 
 ElementFormControlDataSelect::~ElementFormControlDataSelect()
 ElementFormControlDataSelect::~ElementFormControlDataSelect()
 {
 {
-	if (data_source != NULL)
+	if (data_source != NULL) {
 		data_source->DetachListener(this);
 		data_source->DetachListener(this);
+		data_source = NULL;
+	}
 }
 }
 
 
 // Sets the data source the control's options are driven from.
 // Sets the data source the control's options are driven from.
@@ -76,8 +78,10 @@ void ElementFormControlDataSelect::OnAttributeChange(const Core::AttributeNameLi
 
 
 	if (changed_attributes.find("source") != changed_attributes.end())
 	if (changed_attributes.find("source") != changed_attributes.end())
 	{
 	{
-		if (data_source != NULL)
+		if (data_source != NULL) {
 			data_source->DetachListener(this);
 			data_source->DetachListener(this);
+			data_source = NULL;
+		}
 
 
 		initialised = false;
 		initialised = false;
 	}
 	}