Code review comment for lp:~dandrader/qtmir/coordinateTranslator

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 14/04/2016 07:34, Gerry Boland wrote:
> + if (CoordinateTranslator::instance()) {
> + CoordinateTranslator::instance()->registerMirSurface(this, surface.get());
> + }
> Why would there not be an instance returned? Having to check this every time is a pain. Singleton pattern requires instance() returns a valid object.

CoordinateTranslator has no control over the creation of its instance.

It's created by MirServer here:

"""
     override_the_coordinate_translator([]
         {
             return std::make_shared<qtmir::CoordinateTranslator>();
         });
"""

CoordinateTranslator::instance() simply returns its single existing
instance, if any.

How do you conciliate the Singleton pattern you expect with the way
things get created in MirServer?

« Back to merge proposal