View previous topic :: View next topic |
Author |
Message |
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Tue Dec 18, 2007 3:48 pm Post subject: drag drop crashing |
|
|
I copied the drag/drop setup from the filedrop.d example, but for some reason my app crashes when I do that. The filedrop example doesnt crash for me.
The last bit of the stack trace from windbg shows the following:
Code: |
0 unknown function
1 Control.DropTarget.ensureDataObj
2 Control.DropTarget.DragEnter
3 unknown function
...
|
So it's crashing before it even gets to any of my code.
The crash doesn't always happen though. Sometimes I can successfully do one or two drops before crashing. It is definitely the call to "dataObj.isSameDataObject" that's causing the problem.
I added some writefln's to ensureDataObj to check:
Code: |
void ensureDataObj(dfl.internal.wincom.IDataObject pDataObject)
{
writefln("this = 0x%x ; dataObj = 0x%x ; pDataObject = 0x%x",
cast(void*)this, cast(void*)dataObj, cast(void*)pDataObject);
if(!dataObj) {
writefln(" ! data obj");
}
writefln(" passed ! data obj check");
if(!dataObj || !dataObj.isSameDataObject(pDataObject)) {
writefln(" ! isSameDataObject");
}
writefln(" passed ! isSameDataObject check");
if(!dataObj || !dataObj.isSameDataObject(pDataObject))
{
writefln(" make dataobj");
dataObj = new ComToDdataObject(pDataObject);
}
}
|
Here's the output I get from doing a couple of drags in and out over the window:
Code: |
this = 0x1FA36A0 ; dataObj = 0x0000 ; pDataObject = 0x1888B8
! data obj
passed ! data obj check
! isSameDataObject
passed ! isSameDataObject check
make dataobj
this = 0x1FA36A0 ; dataObj = 0x1FCFA90 ; pDataObject = 0x18B028
passed ! data obj check
! isSameDataObject
passed ! isSameDataObject check
make dataobj
this = 0x1FA36A0 ; dataObj = 0x1FC7660 ; pDataObject = 0x18B098
passed ! data obj check
! isSameDataObject
passed ! isSameDataObject check
make dataobj
this = 0x1FA36A0 ; dataObj = 0x1FC2BA0 ; pDataObject = 0x18B028
passed ! data obj check
Error: Access Violation
|
Note that this happens even if all I do is set allowDrag on my control. I'm not even setting any onDragThisOrThats callbacks.
Any ideas? I think the only way dataObj.isSameDataObject could generate an access violation is if the dataObj is bogus for some reason. But how could that be happening? |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Wed Dec 19, 2007 3:18 am Post subject: Re: drag drop crashing |
|
|
The drag/drop examples use Code: | Application.autoCollect = false; | to prevent DFL from calling garbage collection cycles periodically.
I have a suspicion that interfaces don't actually refer to objects directly and so don't hold a reference for the GC, but I haven't confirmed it. Reading through some D internals suggested that interfaces only use an offset to the object.
It's probably best not to rely on autoCollect though. A better way would probably be to hold a reference to the drop data object in your class. |
|
Back to top |
|
|
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Wed Dec 19, 2007 3:32 am Post subject: Re: drag drop crashing |
|
|
Chris Miller wrote: | The drag/drop examples use Code: | Application.autoCollect = false; | to prevent DFL from calling garbage collection cycles periodically.
I have a suspicion that interfaces don't actually refer to objects directly and so don't hold a reference for the GC, but I haven't confirmed it. Reading through some D internals suggested that interfaces only use an offset to the object.
It's probably best not to rely on autoCollect though. A better way would probably be to hold a reference to the drop data object in your class. |
Sweet! Holding onto a reference to ev.data did the trick.
Thanks. |
|
Back to top |
|
|
|