[vtkusers] Avoiding program crashing when an algorithm does

Carlos Delgado carlos.m.delgado at gmail.com
Tue May 15 12:46:16 EDT 2012


John:

Thanks so much for your very promt reply, I really appreciate this.
I didn't understand completely your answer, since I am not proficiency
in VTK nor in Qt. Sorry for abusing your patience!
Do you mean modifiying the QApplication class file to include that
function within? Otherwise I am not sure where I should include it.

Regards,
Carlos Delgado.


2012/5/15 John Drescher <drescherjm at gmail.com>:
> On Tue, May 15, 2012 at 12:14 PM, Carlos Delgado
> <carlos.m.delgado at gmail.com> wrote:
>> Hello:
>>
>> I have developed an VTK application with a Qt GUI. I am using the
>> vtkSelectPolyData class in my program. This algorithm crashes when not
>> finding the edge, and a vtkOutputWindow is open showing an error
>> message and the program crashes.
>>
>> My question is: How can I avoid program crashing when the algorithm
>> does? I have tried a try/catch structure to handle the problem, but it
>> didn't help or I didn't implemented it properly. Could anyone give me
>> some tip on how to approach this problem?
>>
>
> Although I recommend trying to fix the algorithm bug, in Qt I have put
> a try / catch in the notify member of the application class. This will
> catch most application exceptions:
>
> bool smStudyManagerApp::notify( QObject *pObject, QEvent *pEvent )
> {
>        try {
>                return Superclass::notify(pObject,pEvent);
>        }
>        catch( smException & e) {
>                e.Print(std::cerr);
>        }
>        catch( ... )
>        {
>                std::cerr << "An unknown exception occurred" << std::endl;
>        }
>        return false;
> }
>
> John



More information about the vtkusers mailing list