~ci-train-bot/qtmir/qtmir-ubuntu-zesty-2668

« back to all changes in this revision

Viewing changes to src/modules/Unity/Application/surfacemanager.h

Stop MirSurface deleting itself, ensure SurfaceManager alone manages MirSurface lifetimes. Add SurfaceManager test suite.

This fixes bugs where a MirSurface would call deleteLater on itself, but SurfaceManager would have no idea and keep a pointer to that MirSurface in its internal list.

Instead SurfaceManager listens for signals from both miral and the MirSurface itself to decide when to delete it.

Add a test suite to verify MirSurface lifetimes. (LP: #1655644)

Approved by: Daniel d'Andrada, Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
namespace qtmir {
32
32
 
33
33
class MirSurface;
 
34
class SessionMapInterface;
34
35
class WindowControllerInterface;
35
36
 
36
37
class SurfaceManager : public unity::shell::application::SurfaceManagerInterface
38
39
    Q_OBJECT
39
40
 
40
41
public:
41
 
    explicit SurfaceManager(QObject *parent = 0);
 
42
    explicit SurfaceManager();
 
43
    SurfaceManager(WindowControllerInterface *windowController,
 
44
                   WindowModelNotifier *windowModel,
 
45
                   SessionMapInterface *sessionMap);
42
46
    virtual ~SurfaceManager() {}
43
47
 
44
48
    void raise(unity::shell::application::MirSurfaceInterface *surface) override;
45
49
    void activate(unity::shell::application::MirSurfaceInterface *surface) override;
46
50
 
 
51
    // mainly for test usage
 
52
    MirSurface* find(const miral::WindowInfo &needle) const;
 
53
 
47
54
private Q_SLOTS:
48
55
    void onWindowAdded(const qtmir::NewWindow &windowInfo);
49
56
    void onWindowRemoved(const miral::WindowInfo &windowInfo);
58
65
    void connectToWindowModelNotifier(WindowModelNotifier *notifier);
59
66
    void rememberMirSurface(MirSurface *surface);
60
67
    void forgetMirSurface(const miral::Window &window);
61
 
    MirSurface* find(const miral::WindowInfo &needle) const;
62
68
    MirSurface* find(const miral::Window &needle) const;
63
69
 
64
70
    QVector<MirSurface*> m_allSurfaces;
65
71
 
66
72
    WindowControllerInterface *m_windowController;
 
73
    SessionMapInterface *m_sessionMap;
67
74
};
68
75
 
69
76
} // namespace qtmir