Mir

Code review comment for lp:~kdub/mir/fix-1158564

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

53 + std::shared_ptr<struct alloc_device_t> alloc_device;
54 std::shared_ptr<mga::AndroidBuffer> android_buffer;
55 std::shared_ptr<mga::AndroidBuffer> second_android_buffer;

Yikes. If you're having that issue, what I would suggest doing would be either:

a) Add a comment saying that this needs to be the order and hope it stays up-to-date
b) Wrap it all up into a new class, e.g:

class DrawTestAndroidBuffers
{
    public:

        // We require std::shared_ptr<struct alloc_device_t as a construction parameter to signify that the relevant mga::AndroidBuffers require it to be around during their lifetime.
        DrawTestAndroidBuffers (std::shared_ptr<struct alloc_device_t const&) { ... }

 std::shared_ptr<mga::AndroidBuffer> android_buffer;
 std::shared_ptr<mga::AndroidBuffer> second_android_buffer;
};

class DrawTestAndroidDevice
{
    public:

        std::shared_ptr<struct alloc_device_t> alloc_device;
        DrawTestAndroidBuffers android_buffers;
};

What that does is ensure that in order to initialize the android_buffers, you have to have an alloc_device first. The dependency is certainly implicit, but at least any future maintainer will think twice before changing it, and it makes it more difficult to accidentally change the order.

« Back to merge proposal