diff options
author | Jesus Fernandez <jesus.fernandez@qt.io> | 2018-02-12 16:19:21 +0100 |
---|---|---|
committer | Jesus Fernandez <Jesus.Fernandez@qt.io> | 2018-02-15 10:50:49 +0000 |
commit | 2a66261776e83139f84d586826a6bd82abc1d2db (patch) | |
tree | a4dfc4de722030c781719cf68a9bb90ac9a6f096 /src | |
parent | 3ede2fe3a426675691c32e6ee07913fc3c27d0fd (diff) |
Return event id instead of deleted event
Under some situations, the QWebGLFunctionCall is destroyed before
getting the event id. Increasing the lifetime of the event makes no
sense so instead of that, the id can be returned and passed to the query
function.
Task-number: QTBUG-66031
Change-Id: Iba755b8154fba3fadf81a1a73c87d16f0e31c4f3
Reviewed-by: Michael Winkelmann <michael.winkelmann@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/webgl/qwebglcontext.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/plugins/platforms/webgl/qwebglcontext.cpp b/src/plugins/platforms/webgl/qwebglcontext.cpp index be62649..fb5ff03 100644 --- a/src/plugins/platforms/webgl/qwebglcontext.cpp +++ b/src/plugins/platforms/webgl/qwebglcontext.cpp @@ -382,39 +382,44 @@ static void postEventImpl(QWebGLFunctionCall *event) } template<const GLFunction *Function, class... Ts> -static QWebGLFunctionCall *createEventAndPostImpl(bool wait, Ts&&... arguments) +static int createEventAndPostImpl(bool wait, Ts&&... arguments) { auto event = createEventImpl<Function>(wait); + auto id = -1; if (event) { + id = event->id(); addHelper(event, arguments...); postEventImpl(event); } - return event; + return id; } template<const GLFunction *Function> -static QWebGLFunctionCall *createEventAndPostImpl(bool wait) +static int createEventAndPostImpl(bool wait) { auto event = createEventImpl<Function>(wait); - if (event) + auto id = -1; + if (event) { + id = event->id(); postEventImpl(event); - return event; + } + return id; } template<const GLFunction *Function, class... Ts> -inline QWebGLFunctionCall *postEventImpl(bool wait, Ts&&... arguments) +inline int postEventImpl(bool wait, Ts&&... arguments) { return createEventAndPostImpl<Function>(wait, arguments...); } template<const GLFunction *Function> -inline QWebGLFunctionCall *postEvent(bool wait) +inline int postEvent(bool wait) { return createEventAndPostImpl<Function>(wait); } template<const GLFunction *Function, class...Ts> -inline QWebGLFunctionCall *postEvent(Ts&&... arguments) +inline int postEvent(Ts&&... arguments) { return postEventImpl<Function>(false, arguments...); } @@ -423,8 +428,8 @@ template<const GLFunction *Function, class ReturnType, class...Ts> static ReturnType postEventAndQuery(ReturnType defaultValue, Ts&&... arguments) { - const auto event = postEventImpl<Function>(true, arguments...); - return event ? queryValue(event->id(), defaultValue) : defaultValue; + auto id = postEventImpl<Function>(true, arguments...); + return id != -1 ? queryValue(id, defaultValue) : defaultValue; } namespace QWebGL { |