<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -96,8 +96,11 @@ public class ChemModel extends ChemObject implements Serializable, IChemModel, I
 	 */
 	public void setMoleculeSet(IMoleculeSet setOfMolecules)
 	{
+	    if (this.setOfMolecules != null)
+	        this.setOfMolecules.removeListener(this);
 		this.setOfMolecules = setOfMolecules;
-		this.setOfMolecules.addListener(this);
+		if (this.setOfMolecules != null)
+		    this.setOfMolecules.addListener(this);
 		notifyChanged();
 	}
 
@@ -124,7 +127,11 @@ public class ChemModel extends ChemObject implements Serializable, IChemModel, I
 	 */
 	public void setRingSet(IRingSet ringSet)
 	{
+	    if (this.ringSet != null)
+	        this.ringSet.removeListener(this);
 		this.ringSet = ringSet;
+		if (this.ringSet != null)
+		    this.ringSet.addListener(this);
 		notifyChanged();
 	}
 
@@ -147,9 +154,12 @@ public class ChemModel extends ChemObject implements Serializable, IChemModel, I
      * @see      #getCrystal
      */
     public void setCrystal(ICrystal crystal) {
+        if (this.crystal != null)
+            this.crystal.removeListener(this);
         this.crystal = crystal;
-	this.crystal.addListener(this);
-	notifyChanged();
+        if (this.crystal != null)
+            this.crystal.addListener(this);
+        notifyChanged();
     }
 
     /**
@@ -171,9 +181,12 @@ public class ChemModel extends ChemObject implements Serializable, IChemModel, I
      * @see       #getReactionSet
      */
     public void setReactionSet(IReactionSet sor) {
+        if (this.setOfReactions != null)
+            this.setOfReactions.removeListener(this);
         this.setOfReactions = sor;
-	this.setOfReactions.addListener(this);
-	notifyChanged();
+        if (this.setOfReactions != null)
+            this.setOfReactions.addListener(this);
+        notifyChanged();
     }
     
     /**</diff>
      <filename>src/main/org/openscience/cdk/ChemModel.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b8331764c29f74a50385e69c0bc8f7be098f7d8f</id>
    </parent>
  </parents>
  <author>
    <name>Egon Willighagen</name>
    <email>egonw@users.sourceforge.net</email>
  </author>
  <url>http://github.com/egonw/cdk/commit/0c8a88fec80b2460d6aee526084cbbab1c9424c9</url>
  <id>0c8a88fec80b2460d6aee526084cbbab1c9424c9</id>
  <committed-date>2009-11-01T08:33:09-08:00</committed-date>
  <authored-date>2009-11-01T06:43:37-08:00</authored-date>
  <message>Fixed propagation of change events to IChemModel when modifications are made in child IChemObjects

Signed-off-by: Rajarshi  Guha &lt;rajarshi.guha@gmail.com&gt;</message>
  <tree>db5c643db1e43e621a732cacce0c69cf426ff989</tree>
  <committer>
    <name>Rajarshi  Guha</name>
    <email>rajarshi.guha@gmail.com</email>
  </committer>
</commit>
