Question
CS4 Crashes when attempting to change color of characters in story
Below is a function that we have been using since forever. It changes the color of a specified number of characters in a story starting at a specific position in the textmodel.<br /><br />The crash happens when processing the command (immediately after "11" is displayed).<br /><br />classID is kTextAttrColorBoss.<br /><br />Any help would be greatly appreciated.<br /><br />ErrorCode ApplyTextAttributes(ITextModel * pTextModel, int32 position, int32 length, UID swatchUID, ClassID classID)<br />{<br /> ErrorCode rc = kFailure;<br /> do<br /> {<br /> InterfacePtr<ITextAttrUID> textAttrUID_Color(::CreateObject2<ITextAttrUID>(classID));<br /> if (textAttrUID_Color == nil)<br /> {<br />// ASSERT_FAIL("TSCore::CreateCharStyle: color invalid");<br />// CAlert::ErrorAlert("textAttrUID obj is nuil");<br /> break;<br /> }<br /><br /> if (swatchUID == kInvalidUID)<br /> {<br /> ASSERT_FAIL("TSCore::CreateCharStyle: ResolveRGBColorSwatch failed");<br />// CAlert::ErrorAlert("Invalid color UID");<br /> break;<br /> }<br /> <br /> // Set our color attribute and store it:<br /> textAttrUID_Color->SetUIDData(swatchUID);<br /> <br /> InterfacePtr<ICommand> pApplyTextAttrCmd ( Utils<ITextAttrUtils>()->BuildApplyTextAttrCmd(pTextModel, position, length, textAttrUID_Color, kCharAttrStrandBoss) );<br /> //pApplyTextAttrCmd->SetUndoability(ICommand::kUndoNotRequired); <br />CAlert::WarningAlert("11");<br /> rc = CmdUtils::ProcessCommand(pApplyTextAttrCmd);<br />CAlert::WarningAlert("12");<br /> if (rc != kSuccess)<br /> CAlert::WarningAlert("Error on ApplyTextAttrCmd");<br /> }while(false);<br /> <br /> return rc; <br />}