diff options
author | sky <sky@chromium.org> | 2015-05-28 16:22:53 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-28 23:23:22 +0000 |
commit | 7b851a20f13e24921fd62e80a8b31f28f4a1ad36 (patch) | |
tree | 23b5c9d86c13e7329236c34e618b07a75daf76e1 /mojo/application | |
parent | 6c4a368e5df834d2995f295bd2c77cd95688d09d (diff) | |
download | chromium_src-7b851a20f13e24921fd62e80a8b31f28f4a1ad36.zip chromium_src-7b851a20f13e24921fd62e80a8b31f28f4a1ad36.tar.gz chromium_src-7b851a20f13e24921fd62e80a8b31f28f4a1ad36.tar.bz2 |
Makes ApplicationRunner delete the delegate before the app
To do otherwise means the delegate outlives the app, which is error
prone (I was hitting an asan error running apptests). Before this
patch the destruction order was:
1. app
2. messageloop
3. delegate
Between 2 and 3 we may pump events posted by the delegate, which is
problematic since the app has been deleted.
Now it's:
. delegate
. app
. messageloop
BUG=none
TEST=none
R=ben@chromium.org
Review URL: https://codereview.chromium.org/1160643003
Cr-Commit-Position: refs/heads/master@{#331877}
Diffstat (limited to 'mojo/application')
-rw-r--r-- | mojo/application/public/cpp/lib/application_runner.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mojo/application/public/cpp/lib/application_runner.cc b/mojo/application/public/cpp/lib/application_runner.cc index cc32b9f..8ed7482 100644 --- a/mojo/application/public/cpp/lib/application_runner.cc +++ b/mojo/application/public/cpp/lib/application_runner.cc @@ -67,8 +67,11 @@ MojoResult ApplicationRunner::Run(MojoHandle application_request_handle) { MakeRequest<Application>(MakeScopedHandle( MessagePipeHandle(application_request_handle)))); loop->Run(); + // It's very common for the delegate to cache the app and terminate on + // errors. If we don't delete the delegate before the app we run the risk + // of the delegate having a stale reference to the app and trying to use it. + delegate_.reset(); } - delegate_.reset(); return MOJO_RESULT_OK; } |