0

I'm currently building a C++ plugin for some software, which, when the relevant function is called, displays a nib which I built in XCode. Up until today everything has been working fine, displaying and working with the nib / Objective-C++ / C++ has caused no problems.

However out of the blue everything started crashing at the call to show the preferences dialog. I've narrowed the crashing code down to this line:

PreferencesWindowController *prefsWindowController = [[PreferencesWindowController alloc] initWithNibNamed:@"PreferencesWindow"];

PreferencesWindowController is a superclass of NSWindowController, and PreferencesWindow is a .xib file which superclasses NSWindow also.

Does anyone have any idea why this is crashing?

  • What is the code for the initializer of `PreferencesWindowController`? Is the File's Owner set correctly in the XIB to be a class of that type, connected to a window? (Also, "superclass" is the wrong term in your description...NSWindowController is the superclass of PreferencesWindowController.) – Kevin Grant Jul 23 '12 at 03:39
  • Yeah you're right sorry, didn't say that correctly! I haven't overridden the default initializer code so it should just be initializing as normal. Also, the File's Owner is set to PreferencesWindowController and the XIB class is PreferencesWindow.. However, I loaded a revision which I found in my dropbox from last week which was had no errors, but this still crashed, so I think there is some corruption in my Xcode or SDK or something.. Reinstalling Xcode as we speak. –  Jul 23 '12 at 05:05
  • Just to nitpick, I think you have the terminology wrong... If `PreferencesWindowController` is a superclass of `NSWindowController`, it means that `NSWindowController` inherits from `PreferencesWindowController`. It's probably the other way around, with `PreferencesWindowController` being a _subclass_. – Some programmer dude Jul 23 '12 at 07:18
  • Yep I got that from Kevin, honest mistake. –  Jul 23 '12 at 20:43
  • It may help to describe some of the bindings. Also note that XIB is a textual (XML) format so you can run a raw `diff` command on the working file and the broken file to see what's different. (This may offer clues, e.g. some property that isn't there anymore.) – Kevin Grant Jul 24 '12 at 02:33
  • There are no working files, that's the issue. I loaded up the revision but it crashes as well.. –  Jul 24 '12 at 03:19

1 Answers1

0

I figured out the problem. I was developing a Plug-in for some software, which apparently loaded plug-ins from two different directories on a Mac. I had the plug-in in both directories and for some reason having it being loaded in twice obviously messed around with the memory somehow. Anyway I deleted it from one of the plug-in directories and now it works fine.