else { NS_RELEASE(inst); }
nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,                                            const nsIID &aIID,                                            void **aResult)  {      if (aResult == NULL) {          return NS_ERROR_NULL_POINTER;      }      *aResult = NULL;        if (nsnull != aOuter && !aIID.Equals(kISupportsIID)) {        // aggregation with IID != nsISupports        return NS_ERROR_ILLEGAL_VALUE;    }    nsObject *inst = nsnull;    if (mClassID.Equals(kCWindow)) {        inst = (nsObject*)new nsWindow(aOuter);    }    else if (mClassID.Equals(kCChild)) {        inst = (nsObject*)new ChildWindow(aOuter);    }    else if (mClassID.Equals(kCButton)) {        inst = (nsObject*)new nsButton(aOuter);    }    else if (mClassID.Equals(kCCheckButton)) {        inst = (nsObject*)new nsCheckButton(aOuter);    }    else if (mClassID.Equals(kCCombobox)) {        inst = (nsObject*)new nsComboBox(aOuter);    }    else if (mClassID.Equals(kCRadioButton)) {        inst = (nsObject*)new nsRadioButton(aOuter);    }    else if (mClassID.Equals(kCRadioGroup)) {        inst = (nsObject*)new nsRadioGroup(aOuter);    }    else if (mClassID.Equals(kCFileOpen)) {        inst = (nsObject*)new nsFileWidget(aOuter);    }    else if (mClassID.Equals(kCListbox)) {        inst = (nsObject*)new nsListBox(aOuter);    }    else if (mClassID.Equals(kCHorzScrollbar)) {        inst = (nsObject*)new nsScrollbar(aOuter, PR_FALSE);    }    else if (mClassID.Equals(kCVertScrollbar)) {        inst = (nsObject*)new nsScrollbar(aOuter, PR_TRUE);    }    else if (mClassID.Equals(kCTextArea)) {        inst = (nsObject*)new nsTextAreaWidget(aOuter);    }    else if (mClassID.Equals(kCTextField)) {        inst = (nsObject*)new nsTextWidget(aOuter);    }    else if (mClassID.Equals(kCTabWidget)) {        inst = (nsObject*)new nsTabWidget(aOuter);    }    else if (mClassID.Equals(kCTooltipWidget)) {        inst = (nsObject*)new nsTooltipWidget(aOuter);    }    else if (mClassID.Equals(kCAppShell)) {        inst = (nsObject*)new nsAppShell(aOuter);    }    else if (mClassID.Equals(kCLookAndFeel)) {        inst = (nsObject*)new nsLookAndFeel(aOuter);    }      if (inst == NULL) {          return NS_ERROR_OUT_OF_MEMORY;      }      nsresult res = inst->QueryObject(aIID, aResult);    if (res != NS_OK) {          // We didn't get the right interface, so clean up          delete inst;      }      return res;  }  