ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Throwing exception in Autocad dialog kill Acad session

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
majklha
488 Views, 3 Replies

Throwing exception in Autocad dialog kill Acad session

I have a ARX application with dialog. If I throw and subsequently catch exception in ARX code, program will return to AutoCAD. It is expected behavior.

But, If I throw exception in dialog code (for example in OnBnClickedButton function) , Autocad fell. 

 

I tested it on easy application generated by ARX Wizard. 

 

Example 1 (works properly) - called from command:

void Pokus()
{
try
{
throw std::exception("Pokus");
}
catch (std::exception& except)
{
acutPrintf(L"\nExcept: %s", except.what());

}
}

 

example 2 (kill Acad):

void Pokus()
{
try
{
CPokDialog dlg;
dlg.DoModal();
}

catch (std::exception& except)
{
acutPrintf(L"\nExcept: %s", except.what());

}
}



void CPokDialog::OnBnClickedButton1()
{
throw std::exception("throw");
}

 

 

Tags (2)
3 REPLIES 3
Message 2 of 4
Alexander.Rivilis
in reply to: majklha

What behavior did you expect? This is a very bad practice to leave an unhandled exception.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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

Message 3 of 4
majklha
in reply to: Alexander.Rivilis

It is maybe bad understanding. 

I am not leaving unhandled exception. The problem, I have, is that I handle exception (I have there catch block) and after it I return to ACAD (eg. acedRetNil()). And normal behavior is that Acad continue normally, user function was interrupted. It is first example.

But if i am in dialog - second example, the Autocad fell, although exception was handled....

 

Showing code was only part, of course. 

 

Thanks,

M.

Message 4 of 4
Alexander.Rivilis
in reply to: majklha

If you not catch exception within CPokDialog::OnBnClickedButton1 method - this exception will be passed to AutoCAD message loop and will be unhandled as far as AutoCAD do not know that you will try to catch it after dialog will be closed. So you have to catch this exception within CPokDialog::OnBnClickedButton1

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report