1111#include " settings.h"
1212
1313#include " include/cef_application_mac.h"
14+ #include " include/cef_version.h"
1415#include " include/base/cef_logging.h"
1516#include " include/wrapper/cef_helpers.h"
1617#import " include/wrapper/cef_library_loader.h"
@@ -76,6 +77,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:
7677 (NSApplication *)sender {
7778 return NSTerminateNow;
7879 }
80+ // applicationShouldHandleReopen TODO?
7981@end
8082
8183int main (int argc, char **argv) {
@@ -88,6 +90,9 @@ int main(int argc, char **argv) {
8890
8991 @autoreleasepool {
9092
93+ [SharedApplication sharedApplication ];
94+ CHECK ([NSApp isKindOfClass: [SharedApplication class ]]);
95+
9196 // Passing ENV variables to PHP using the --cgi-environment
9297 // command line arg passed to app.
9398 if (argv) {
@@ -112,6 +117,8 @@ int main(int argc, char **argv) {
112117 // Log what process type is launching
113118 if (!cmdline->HasSwitch (" type" )) {
114119 // If there is no --type flag then this is main process
120+ LOG (INFO) << " PHP Desktop version: " << PHPDESKTOP_VERSION;
121+ LOG (INFO) << " Chrome version: " << CEF_VERSION;
115122 LOG (INFO) << " Launching Browser process (main process)\n " ;
116123 } else {
117124 const std::string& process_type = cmdline->GetSwitchValue (" type" );
@@ -238,19 +245,20 @@ int remote_debugging_port(
238245 // App implements application-level callbacks for the browser process.
239246 CefRefPtr<App> app (new App);
240247
241- [SharedApplication sharedApplication ];
242-
243248 // Log messages created by LOG() macro will be written to debug.log
244249 // file only after CEF was initialized. Before CEF is initialized
245250 // all logs are only printed to console.
246251 LOG (INFO) << " Initialize CEF" ;
252+ LOG (INFO) << " Note that logging to terminal doesn't work from this point on, "
253+ << " unless you add --enable-logging=stderr switch to settings.json" ;
247254 if (!CefInitialize (main_args, cef_settings, app.get (), nullptr )) {
248255 LOG (ERROR) << " Failed to initialize CEF" ;
249- return 1 ;
256+ return CefGetExitCode (); ;
250257 }
251258
252259 // Create the application delegate.
253- NSObject * delegate = [[SharedAppDelegate alloc ] init ];
260+ SharedAppDelegate* delegate = [[SharedAppDelegate alloc ] init ];
261+ NSApp .delegate = delegate;
254262 [delegate performSelectorOnMainThread: @selector (createApplication: )
255263 withObject: nil
256264 waitUntilDone: NO ];
@@ -264,6 +272,12 @@ int remote_debugging_port(
264272 LOG (INFO) << " Shutdown CEF" ;
265273 CefShutdown ();
266274
275+ // Release the delegate.
276+ #if !__has_feature(objc_arc)
277+ [delegate release ];
278+ #endif // !__has_feature(objc_arc)
279+ delegate = nil ;
280+
267281 } // end @autoreleasepool
268282
269283 return 0 ;
0 commit comments