Index: mojo/public/cpp/application/lib/mojo_main_standalone.cc |
diff --git a/mojo/public/cpp/application/lib/mojo_main_standalone.cc b/mojo/public/cpp/application/lib/mojo_main_standalone.cc |
index 0ba078b25cf287bdcbac5bfaa775d36b99f85eed..6071b6b4f280aefe24b8b7ce3523f2c3341da880 100644 |
--- a/mojo/public/cpp/application/lib/mojo_main_standalone.cc |
+++ b/mojo/public/cpp/application/lib/mojo_main_standalone.cc |
@@ -10,12 +10,17 @@ |
extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( |
MojoHandle shell_handle) { |
mojo::Environment env; |
- mojo::RunLoop loop; |
- mojo::ApplicationDelegate* delegate = mojo::ApplicationDelegate::Create(); |
+ mojo::ApplicationDelegate* delegate = NULL; |
{ |
- mojo::ApplicationImpl app(delegate); |
- app.BindShell(shell_handle); |
- loop.Run(); |
+ // We have to shut down the RunLoop before destroying the |
+ // ApplicationDelegate. |
+ mojo::RunLoop loop; |
+ delegate = mojo::ApplicationDelegate::Create(); |
+ { |
+ mojo::ApplicationImpl app(delegate); |
+ app.BindShell(shell_handle); |
+ loop.Run(); |
+ } |
} |
delete delegate; |