Bug Related to AcDbMText That Causes AutoCAD Crash

Bug Related to AcDbMText That Causes AutoCAD Crash

3453351159
Contributor Contributor
422 Views
2 Replies
Message 1 of 3

Bug Related to AcDbMText That Causes AutoCAD Crash

3453351159
Contributor
Contributor

Following are the key points:

  • Add a command CreatText in ObjectARX.

 

 

const ACHAR* pContent = L"AA";
void CreateText()
{
	AcDbMText* pText = new AcDbMText();
	AppendDb(pText);
	auto id = pText->objectId();
	pText->close();
	pText = nullptr;
	acdbOpenAcDbEntity((AcDbEntity*&)pText, id, AcDb::kForWrite);
	pText->setContents(pContent);
	pText->close();
	pText = nullptr;
}

Acad::ErrorStatus AppendDb(AcDbEntity* pEntity, const std::wstring& sBlkRec = ACDB_MODEL_SPACE, AcDbDatabase* pDb = acdbCurDwg())
{
	Acad::ErrorStatus es = eNotImplementedYet;

	AcDbBlockTableRecordPointer pBlockTableRecord(sBlkRec.c_str(), pDb, AcDb::kForWrite);
	if ((es = pBlockTableRecord.openStatus()) != Acad::eOk)
		return es;

	return pBlockTableRecord->appendAcDbEntity(pEntity);
}

 

 

  • Execute the command.
  • Undo .
  • Attempt to close the drawing, choose not to save, then AutoCAD crashes.

This issue occurs both in AutoCAD 2018 and 2022.

0 Likes
423 Views
2 Replies
Replies (2)
Message 2 of 3

Alexander.Rivilis
Mentor
Mentor

Very strange code:

 

pText->setContents(pText);

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 3 of 3

3453351159
Contributor
Contributor

I'm sorry, I posted a error code.It has been fixed now. However, this doesn't affect the test results.

0 Likes