Skip to main content
Shreelipi
Known Participant
October 12, 2016
Question

Indesign crashes on processCommand kImportAndPlaceCmdBoss

  • October 12, 2016
  • 1 reply
  • 419 views

I'm using below source code, sometimes it works , sometimes doesn't

Any idea what could be the reason , indesign crashes at processcommand "importAndPlaceCmd" even if it throws any exception it agian crashes at importAndPlaceCmd in catch.

do {

try {

InterfacePtr<IHierarchy> hierarchy(parentUIDRef, UseDefaultIID());

if (hierarchy == nil)

{

throw AppException("hierarchy == nil");

}

InterfacePtr<ITransform> transform(parentUIDRef, UseDefaultIID());

if (transform == nil)

{

throw AppException("transform == nil");

}

PBPMPoint topLeft = boundsInParentCoords.LeftTop();

PBPMPoint rightBottom = boundsInParentCoords.RightBottom();

::TransformParentPointToPasteboard(transform, &topLeft);

::TransformParentPointToPasteboard(transform, &rightBottom);

PMPointList pointList(2);

pointList.push_back(topLeft);

pointList.push_back(rightBottom);

seq = CmdUtils::BeginCommandSequence();

if(seq == nil)

{

throw AppException("seq == null");

}

InterfacePtr<ICommand> importAndPlaceCmd(CmdUtils::CreateCommand(kImportAndPlaceCmdBoss));

if (importAndPlaceCmd == nil)

{

throw AppException("importAndPlaceCmd == nil");

}

InterfacePtr<IPlacePIData> placePIData(importAndPlaceCmd, UseDefaultIID());

if (placePIData == nil)

{

throw AppException("placePIData == nil");

}

placePIData->Set(parentUIDRef, &pointList, kFalse);

InterfacePtr<IImportResourceCmdData> importFileCmdData(importAndPlaceCmd, IID_IIMPORTRESOURCECMDDATA);

if (importFileCmdData == nil)

{

throw AppException("IImportResourceCmdData == nil");

}

URI linkURI;

bool bIDFileToURI = Utils<IURIUtils>()->IDFileToURI(contentFile, linkURI);

if(bIDFileToURI)

{

importFileCmdData->Set(parentUIDRef.GetDataBase(),linkURI, uiFlags, retainFormat, convertQuotes, applyCJKGrid, uidPreview);

}

// Process the command.

if (CmdUtils::ProcessCommand(importAndPlaceCmd) != kSuccess) //Here is crash

{

throw AppException("kImportAndPlaceCmdBoss failed");

}

const UIDList& outItemList = importAndPlaceCmd->GetItemListReference();

if (!(outItemList.Length() > 0))

{

throw AppException("!(outItemList.Length() > 0)");

}

frameUIDRef = importAndPlaceCmd->GetItemListReference().GetRef(0);

Utils<IPageItemTypeUtils> pageItemTypeUtils;

if (pageItemTypeUtils && pageItemTypeUtils->IsGraphicFrame(frameUIDRef))

{

FitImageToFrame(frameUIDRef);

}

InsertNewLine(frameUIDRef);

InsertFooterText(frameUIDRef);

InterfacePtr<ICommand> fitFrameToContentCmd(CmdUtils::CreateCommand(kFitFrameToContentCmdBoss));

ASSERT(fitFrameToContentCmd != nil);

if (fitFrameToContentCmd == nil)

{

break;

}

fitFrameToContentCmd->SetItemList(UIDList(frameUIDRef));

if (CmdUtils::ProcessCommand(fitFrameToContentCmd) != kSuccess)

{

ASSERT_FAIL("kFitFrameToContentCmdBoss failed");

break;

}

CmdUtils::EndCommandSequence((ICommandSequence *)seq);

seq = nil;

}

catch(...)

{

CmdUtils::RollBackCommandSequence((IAbortableCmdSeq*)seq); //crash

CmdUtils::AbortCommandSequence((IAbortableCmdSeq*)seq);

seq = nil;

}

} while(false);

This topic has been closed for replies.

1 reply

Shreelipi
ShreelipiAuthor
Known Participant
October 12, 2016

Sorry, at CmdUtils::RollBackCommandSequence((IAbortableCmdSeq*)seq) in catch.