plugins/screenshot: Cache screenshot attributes
When a QPromise reports results, it's not necessary that the QFutureWatcher is going to report it immediately. That can happen at some point in the future, which is okay according to the QFuture api contract. Due to that, we cannot assume that the stored Output and EffectWindow objects pointers are valid when the QFutureWatcher::finished is emitted.
This commit is contained in:
parent
50fae55821
commit
69f344a439
1 changed files with 6 additions and 6 deletions
|
@ -176,7 +176,7 @@ public:
|
|||
QVariantMap attributes() const override;
|
||||
|
||||
private:
|
||||
Output *m_screen;
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
class ScreenShotSourceArea2 : public ScreenShotSource2
|
||||
|
@ -197,7 +197,7 @@ public:
|
|||
QVariantMap attributes() const override;
|
||||
|
||||
private:
|
||||
EffectWindow *m_window;
|
||||
QUuid m_internalId;
|
||||
};
|
||||
|
||||
class ScreenShotSinkPipe2 : public QObject
|
||||
|
@ -248,14 +248,14 @@ ScreenShotSourceScreen2::ScreenShotSourceScreen2(ScreenShotEffect *effect,
|
|||
Output *screen,
|
||||
ScreenShotFlags flags)
|
||||
: ScreenShotSource2(effect->scheduleScreenShot(screen, flags))
|
||||
, m_screen(screen)
|
||||
, m_name(screen->name())
|
||||
{
|
||||
}
|
||||
|
||||
QVariantMap ScreenShotSourceScreen2::attributes() const
|
||||
{
|
||||
return QVariantMap{
|
||||
{QStringLiteral("screen"), m_screen->name()},
|
||||
{QStringLiteral("screen"), m_name},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -270,14 +270,14 @@ ScreenShotSourceWindow2::ScreenShotSourceWindow2(ScreenShotEffect *effect,
|
|||
EffectWindow *window,
|
||||
ScreenShotFlags flags)
|
||||
: ScreenShotSource2(effect->scheduleScreenShot(window, flags))
|
||||
, m_window(window)
|
||||
, m_internalId(window->internalId())
|
||||
{
|
||||
}
|
||||
|
||||
QVariantMap ScreenShotSourceWindow2::attributes() const
|
||||
{
|
||||
return QVariantMap{
|
||||
{QStringLiteral("windowId"), m_window->internalId().toString()},
|
||||
{QStringLiteral("windowId"), m_internalId.toString()},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue