I have pondered over this patch for quite a while now and I am still undecided. It does no harm, but it also works around a problem that should not be there. When you don't need NSApplicationMain() you should juts not call it.

Here is your main function:

int main(int argc, const char ** argv) {
  AppController * controller = [AppController new];
  [[NSApplication sharedApplication] setDelegate:controller];
  return NSApplicationMain(argc, argv);
}

I don't see why you need to call NSApplicationMain here. This is my standard main function for tools:

int main (int argc, const char *argv[])
{
  CREATE_AUTORELEASE_POOL(pool);
  id app;

  app = [NSApplication sharedApplication];
  [app setDelegate: [AppController new]];
  [app run];
  RELEASE(pool);
  return 0;
}

This surely can be improved on as well. What we need is another macro for the pool release to get this correct for all our different supported compiler setups.

Fred

On 23.05.2012 13:19, Ivan Vučica wrote:
Hi,

for QuartzCore I'll be implementing small command-line tools that in fact
open an AppKit window with NSOpenGLView as the content view.

This sort of thing is not officially supported in Cocoa (a bundle is
required, or hacks with CPSEnableForegroundOperation() are required).
However, it works just fine with GNUstep.

Except for one small error that I just noticed and don't remember seeing
before.

"Bad application class '(null)' specified"

Looks like in gui's Source/Functions.m, NSApplicationMain() is explicitly
demanding that the bundle and its info dictionary exist, and that
NSPrincipalClass is specified, instead of either defaulting to
NSApplication, or simply checking whether the class is already initialized.

Since NSApp is a global variable, this should work fine:

Index: Source/Functions.m
===================================================================
--- Source/Functions.m    (revision 35156)
+++ Source/Functions.m    (working copy)
@@ -70,7 +70,7 @@
    className = [infoDict objectForKey: @"NSPrincipalClass"];
    appClass = NSClassFromString(className);

-  if (appClass == 0)
+  if (appClass == 0&&  NSApp == nil)
      {
        NSLog(@"Bad application class '%@' specified", className);
        appClass = [NSApplication class];

Thoughts?



_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep


_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to