Menu

#432 Improve exception safety with smart pointers

Maybe
open
nobody
None
5
2013-10-11
2012-05-11
No

Discussion

  • D. Michael McIntyre

    • milestone: --> Maybe
     
  • Ted Felix

    Ted Felix - 2013-10-11

    I don't think exception safety is a serious issue with rg. Rg doesn't use exceptions for error handling as much as it uses return codes.

    That said, smart pointer classes are still useful for resource management (garbage collection).

    Qt's primary resource management mechanism involves QObject's ctor. Classes that derive from QObject can use QObject's ctor to pass a parent object. When the parent object is destroyed, it destroys all of its child objects. It appears that most of rg uses this approach.

    For classes that don't derive from QObject, Qt offers several smart pointer classes. QSharedPointer is worth investigating as it should be similar to C++11's std::shared_ptr. I've found shared_ptr's garbage collection to be very helpful.

     

    Last edit: Ted Felix 2013-10-11

Log in to post a comment.