Index: mojo/public/cpp/application/lib/mojo_main_chromium.cc |
diff --git a/mojo/public/cpp/application/lib/mojo_main_chromium.cc b/mojo/public/cpp/application/lib/mojo_main_chromium.cc |
index 269b7a2f036ab77636ee22986420280671c62be4..d8c5e3f643493ecc9f6e0591d0746e2c7c9f855e 100644 |
--- a/mojo/public/cpp/application/lib/mojo_main_chromium.cc |
+++ b/mojo/public/cpp/application/lib/mojo_main_chromium.cc |
@@ -14,12 +14,16 @@ extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( |
#if !defined(COMPONENT_BUILD) |
base::AtExitManager at_exit; |
#endif |
- base::MessageLoop loop; |
- scoped_ptr<mojo::ApplicationDelegate> delegate( |
- mojo::ApplicationDelegate::Create()); |
- mojo::ApplicationImpl app(delegate.get()); |
- app.BindShell(shell_handle); |
- loop.Run(); |
+ scoped_ptr<mojo::ApplicationDelegate> delegate; |
+ { |
+ // We have to shut down the MessageLoop before destroying the |
+ // ApplicationDelegate. |
+ base::MessageLoop loop; |
+ delegate.reset(mojo::ApplicationDelegate::Create()); |
+ mojo::ApplicationImpl app(delegate.get()); |
+ app.BindShell(shell_handle); |
+ loop.Run(); |
+ } |
return MOJO_RESULT_OK; |
} |