Thread: [Pyobjc-dev] Two difficulties with document-based app
Brought to you by:
ronaldoussoren
From: David E. <epp...@ic...> - 2002-12-11 18:17:58
|
In order to try to learn how to program in Cocoa and pyobjc, I am attempting to build a simple document-based application, using the 0.7 pyobjc package. Mostly everything's working well, but I am having trouble tracking down two bugs: (1) The usual Cocoa objective-C document-based template, when it starts up, creates a new document window. It also does the same when selected in the dock and it doesn't already have a window. My app does the dock-selection new window thing (without any code on my part, simply by adding a doc type to the target) but does not create a new window on startup. (2) If I open and then close a document window, I get a string of scary looking log messages like: Before DECREF in normal Release with dead python repeated several times. If it were just a matter of some log messages, that would be ok, but then sometimes my program craps out with a bus error. Do either of these look familiar to anyone? I'm guessing the second one has to do with my lack of understanding of when I need to do explicit retain/release and when pyobjc will do it for me, but the new doc window creation process is all done by the nib, it doesn't involve any of my python code creating new objc objects... -- David Eppstein UC Irvine Dept. of Information & Computer Science epp...@ic... http://www.ics.uci.edu/~eppstein/ |
From: <bb...@ma...> - 2002-12-11 20:13:25
|
I haven't looked at the other specific problems, but will soon.... however, you should really use the version in CVS. We are on the verge of shipping 0.8 and it is leaps and bounds better than 0.7. See the ChangeLog for an idea of how many things changed. In particular, the examples have been considerably refined. We are going to cut 0.8 before doing a Cocoa-Python Multiple Document template, but that template will be one of the first things I do once 0.8 ships. There are, as you have noted, some issues that we need to work through -- some may be fixed in 0.8. b.bum On Wednesday, December 11, 2002, at 01:17 PM, David Eppstein wrote: > In order to try to learn how to program in Cocoa and pyobjc, I am > attempting to build a simple document-based application, using the 0.7 > pyobjc package. Mostly everything's working well, but I am having > trouble tracking down two bugs: |
From: David E. <epp...@ic...> - 2002-12-11 21:20:41
|
On 12/11/02 3:13 PM -0500 bb...@ma... wrote: > I haven't looked at the other specific problems, but will soon.... > however, you should really use the version in CVS. We are on the verge > of shipping 0.8 and it is leaps and bounds better than 0.7. Ok, I guess. I was holding off because I had the impression the 0.8 release was imminent and it seemed like a better idea to wait until a relatively stable release than to try to hit a moving and sometimes buggy target. When is the 0.8 release expected? > We are going to cut 0.8 before doing a Cocoa-Python Multiple Document > template, but that template will be one of the first things I do once 0.8 > ships. I'd be happy to share my code but I'm not sure how useful you'd find it. What I remember doing to make a document-based app was: - Create class MyDocument (NSDocument) with methods modeled on the ObjC template (all I'm currently implementing are init and windowNibName, more to come later). - Move the window and associated objects from MainMenu.nib to MyDocument.nib (the same nib whose name was returned from MyDocument.windowNibName) - Set the "File's Owner" class in MyDocument.nib to MyDocument so I could set some outlets on it. - Create a document type in the target having MyDocument as its document class Anyway, I want to say thank you, because writing this all out has helped me track down one of the two bugs that were the subject of my previous message. It turns out that the "Before DECREF in normal" / "Release with dead python" messages are caused by the outlets on File's Owner. If I don't set those outlets, the messages stop happening and my bus errors go away. Is this a bug in pyobjc or in my understanding of how to use it? I can easily work around this by moving all the functionality from MyDocument to another object created within the nib, but it would be helpful to understand whether outlets to File's Owners are ok. -- David Eppstein UC Irvine Dept. of Information & Computer Science epp...@ic... http://www.ics.uci.edu/~eppstein/ |
From: Ronald O. <ous...@ci...> - 2002-12-12 06:45:47
|
On Wednesday, Dec 11, 2002, at 22:20 Europe/Amsterdam, David Eppstein wrote: > Anyway, I want to say thank you, because writing this all out has > helped me track down one of the two bugs that were the subject of my > previous message. It turns out that the "Before DECREF in normal" / > "Release with dead python" messages are caused by the outlets on > File's Owner. The messages are leftovers from some debug code. The soon-to-be-released 0.8 version no longer prints these messages. > If I don't set those outlets, the messages stop happening and my bus > errors go away. Is this a bug in pyobjc or in my understanding of how > to use it? It is probably a bug in pyobjc. Could you run your code with the CVS version of pyobjc, the bug is probably fixed by now. Ronald |
From: David E. <epp...@ic...> - 2002-12-12 05:00:14
|
On 12/11/02 1:20 PM -0800 David Eppstein <epp...@ic...> wrote: > It turns out that the "Before DECREF in normal" / "Release with dead > python" messages are caused by the outlets on File's Owner. If I don't > set those outlets, the messages stop happening and my bus errors go away. > Is this a bug in pyobjc or in my understanding of how to use it? I can > easily work around this by moving all the functionality from MyDocument > to another object created within the nib, but it would be helpful to > understand whether outlets to File's Owners are ok. I spoke too early. This seems to be difficult to work around. The NSDocument class has an outlet, "window". If I fail to connect this outlet from the nib's "File's Owner" object to the nib's window, new document windows come up unselected, and you have to click on them to activate them (obviously undesired behavior). But if I connect this outlet, then closing a document window causes the log messages and bus error death. For that matter, to implement file i/o, I am going to need outlets connecting the document object to the objects where the data lives... I decided this was a serious enough bug for me to immediately go ahead with Bill Bum's suggestion that I try the cvs version instead of the 0.7 package. Unfortunately, while the log messages are gone, the bus error is still there... Do you guys need a more formal bug report? Should I try to work up a simpler test case or has my description been clear enough for you to reproduce it? -- David Eppstein UC Irvine Dept. of Information & Computer Science epp...@ic... http://www.ics.uci.edu/~eppstein/ |
From: Ronald O. <ous...@ci...> - 2002-12-13 10:23:15
|
On Thursday, Dec 12, 2002, at 06:00 Europe/Amsterdam, David Eppstein wrote: > On 12/11/02 1:20 PM -0800 David Eppstein <epp...@ic...> wrote: >> It turns out that the "Before DECREF in normal" / "Release with dead >> python" messages are caused by the outlets on File's Owner. If I >> don't >> set those outlets, the messages stop happening and my bus errors go >> away. >> Is this a bug in pyobjc or in my understanding of how to use it? I >> can >> easily work around this by moving all the functionality from >> MyDocument >> to another object created within the nib, but it would be helpful to >> understand whether outlets to File's Owners are ok. > > I spoke too early. This seems to be difficult to work around. > > The NSDocument class has an outlet, "window". If I fail to connect > this outlet from the nib's "File's Owner" object to the nib's window, > new document windows come up unselected, and you have to click on them > to activate them (obviously undesired behavior). But if I connect > this outlet, then closing a document window causes the log messages > and bus error death. For that matter, to implement file i/o, I am > going to need outlets connecting the document object to the objects > where the data lives... > > I decided this was a serious enough bug for me to immediately go ahead > with Bill Bum's suggestion that I try the cvs version instead of the > 0.7 package. Unfortunately, while the log messages are gone, the bus > error is still there... > That's too bad. I've yet really tried to reproduce your problem, but from your description your trying to do something like the Todo example. That example does not crash. Could you try to build a simpler test case? Ronald |
From: David E. <epp...@ic...> - 2002-12-13 16:57:40
Attachments:
crashy.tar.gz
|
On 12/13/02 11:22 AM +0100 Ronald Oussoren <ous...@ci...> wrote: > That's too bad. I've yet really tried to reproduce your problem, but from > your description your trying to do something like the Todo example. That > example does not crash. Could you try to build a simpler test case? Ok, a test case is attached to this email. Usage: - Build and run from within projectbuilder - Make a new window with Cmd-N. You should see a log message about a new document. - Close the window with Cmd-W. After a few seconds, on my computer, the program crashes with a bus error. I tried some further simplifications beyond what I'm sending, and the program stopped crashing, but I don't know whether that's because everything here is necessary to trigger it or whether the simplifications moved memory allocations around enough to mask the bug. -- David Eppstein UC Irvine Dept. of Information & Computer Science epp...@ic... http://www.ics.uci.edu/~eppstein/ |
From: Ronald O. <ous...@ci...> - 2002-12-15 19:51:17
|
I've just checked in a patch that removes the crash. I'm pretty sure this fixes the problem, but it might not be the right way to fix this. Ronald On Friday, Dec 13, 2002, at 17:57 Europe/Amsterdam, David Eppstein wrote: > On 12/13/02 11:22 AM +0100 Ronald Oussoren <ous...@ci...> wrote: >> That's too bad. I've yet really tried to reproduce your problem, but >> from >> your description your trying to do something like the Todo example. >> That >> example does not crash. Could you try to build a simpler test case? > > Ok, a test case is attached to this email. Usage: > - Build and run from within projectbuilder > - Make a new window with Cmd-N. You should see a log message about a > new document. > - Close the window with Cmd-W. After a few seconds, on my computer, > the program crashes with a bus error. > > I tried some further simplifications beyond what I'm sending, and the > program stopped crashing, but I don't know whether that's because > everything here is necessary to trigger it or whether the > simplifications moved memory allocations around enough to mask the > bug. > > -- > David Eppstein UC Irvine Dept. of Information & Computer Science > epp...@ic... http://www.ics.uci.edu/~eppstein/ > <crashy.tar.gz> |
From: David E. <epp...@ic...> - 2002-12-15 20:36:38
|
On 12/15/02 8:50 PM +0100 Ronald Oussoren <ous...@ci...> wrote: > I've just checked in a patch that removes the crash. I'm pretty sure this > fixes the problem, but it might not be the right way to fix this. Thanks, I'm not seeing the crashes any more after installing this patch. -- David Eppstein UC Irvine Dept. of Information & Computer Science epp...@ic... http://www.ics.uci.edu/~eppstein/ |
From: Isaac L. <is...@st...> - 2002-12-16 02:07:36
|
Hey all, After a nice trip over tho the local Barnes and Noble, I was kinda confused by the Cocoa books available. Bill mentioned these ones to me a while back, but I couldn't find them: On Monday, December 2, 2002, at 10:46 AM, Bill Bumgarner wrote: > I would highly recommend that you grab a copy of Aaron Hillegas' Cocoa > book [and Garfinkel's/Mahoney's book] and learn Cocoa/ObjC via those > books -- they are both excellent. Does anyone on the list know exactly where I can find these books, or what their exact titles are? Or- does anyone recommend the Oreilley Cocoa book? Thanks! .ike Isaac Levy + Office of Structured Systems http://structuredsystems.net |
From: Jiva D. <ji...@de...> - 2002-12-16 04:33:02
|
I'll second the Hillegas book... just go to Amazon and do a search by author Hillegas. On Sunday, December 15, 2002, at 07:07 PM, Isaac Levy wrote: > Hey all, > > After a nice trip over tho the local Barnes and Noble, I was kinda > confused by the Cocoa books available. > > Bill mentioned these ones to me a while back, but I couldn't find them: > > On Monday, December 2, 2002, at 10:46 AM, Bill Bumgarner wrote: >> I would highly recommend that you grab a copy of Aaron Hillegas' >> Cocoa book [and Garfinkel's/Mahoney's book] and learn Cocoa/ObjC via >> those books -- they are both excellent. > > Does anyone on the list know exactly where I can find these books, or > what their exact titles are? > > Or- does anyone recommend the Oreilley Cocoa book? > > Thanks! > .ike > > > > Isaac Levy > + Office of Structured Systems > http://structuredsystems.net > > > > ------------------------------------------------------- > This sf.net email is sponsored by: > With Great Power, Comes Great Responsibility Learn to use your power > at OSDN's High Performance Computing Channel > http://hpc.devchannel.org/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > |