Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in DragDropFormats.pas = aMedium.Stm:=Stream = problems #44

Open
MicrotronX opened this issue Oct 27, 2020 · 17 comments
Open

Change in DragDropFormats.pas = aMedium.Stm:=Stream = problems #44

MicrotronX opened this issue Oct 27, 2020 · 17 comments
Labels

Comments

@MicrotronX
Copy link

Hi,

before i was able to perform a DragDrop Operation fromtDropEmptySource (connected to VirtualDataformatAdapter) to tDropComboTarget (new form on same app), after changing lines 1297 and 1303 from iStream(aMedium.stm):=Stream to aMedium.Stm:=Stream it does not work any more.

Changing those lines back ... and everything is working again.

@MicrotronX MicrotronX changed the title Change in DragDropFormats.pas = problems Change in DragDropFormats.pas = aMedium.Stm:=Stream = problems Oct 27, 2020
@landrix
Copy link
Owner

landrix commented Oct 27, 2020

do you have a sample application please?

i changed it, because it produces a memory leak

#41

@MicrotronX
Copy link
Author

I use this in my big project so no small demo but changing it back solved problems on my side, don't know why but now it works

@landrix
Copy link
Owner

landrix commented Oct 27, 2020

i can't reproduce it without any informations about the code in the involved eventhandler. the best way is, you can provide a little demo.

@MicrotronX
Copy link
Author

MicrotronX commented Oct 27, 2020

Here's some code:

onMouseDown of my cxGridView:
`myFileDropSource.Files.Clear; // = tEmptyDropSource where a tvirtualdataformatadapter is connected
TVirtualFileStreamDataFormat(myVirtualDataformatAdapter.DataFormat).FileNames.Clear;
TVirtualFileStreamDataFormat(myVirtualDataformatAdapter.DataFormat).FileNames.add(vdatei); // add some virtual filenames
// manage also a internal list with these filenames, which will be created at myEmptyDropSourceGetData..

// Start the drag operation.
myEmptyDropSource.Execute();`

On the other side, at the form2 i have a tDropComboTarget where the onDrop event is never gets called after your change.

@landrix
Copy link
Owner

landrix commented Oct 31, 2020

can you check the new sources again please

@landrix landrix added the bug label Oct 31, 2020
@MicrotronX
Copy link
Author

With your latest changes drag&drop within same app from two different forms is working again. So it seems that this bug is solved.

@MicrotronX
Copy link
Author

MicrotronX commented Nov 2, 2020

Stop. Not solved. Crazy. Within same app it works without problems. If i start the same app twice and try to Drag&Drop from one to the other, sometimes it works, sometimes it does not.

@landrix landrix closed this as completed Nov 2, 2020
@landrix landrix reopened this Nov 2, 2020
@MicrotronX
Copy link
Author

And it seems that the last started app can Drag&Drop TO the first started app but the first started can't Drag&drop files TO the last started app.

@landrix
Copy link
Owner

landrix commented Nov 2, 2020

ok, i will switch back to the origin code

@MicrotronX
Copy link
Author

And both apps can drag&drop within the same app from different forms without any problems inkluding our own clipboardformat and dataformat. from one app to the other the own clipboard- and dataformat is not available

@landrix
Copy link
Owner

landrix commented Nov 2, 2020

and the origin code works as expected in both cases?

@MicrotronX
Copy link
Author

Will try to do the same, two started exe files and drag&drop between them between different forms within the applications. I had not tested this before your update. After your change it started working within same app and different forms ... as i can remember i had no problems from different apps but will try it again.

@MicrotronX
Copy link
Author

MicrotronX commented Nov 2, 2020

If i drag and drop to second app, than the debugger (second started app) shows that the on getStream of virtualdataadapter is called and it returns the stream without problems but this stream is never received on app where drop is made:

procedure TmxDateianlagen.VirtualDataAdapter_OnGetStream(Sender: TFileContentsStreamOnDemandClipboardFormat; Index: integer; out AStream: IStream);
var
    Stream:tStream;
    vMemStream: TMemoryStream;
    vFileStream: tFileStream;
vmindex:longint;
begin
    // This event handler is called by TFileContentsStreamOnDemandClipboardFormat
    // when the drop target requests data from the drop source (that's us).
    try
        try
            AStream := nil; vMemStream:=tdateianlagen.FastSave2Memorystream(vmindex); // get the stream of file
Stream:=vMemStream;
            if Stream.Position=0 then begin
                Stream.position:=Stream.size;
            end;

            // ...and return the stream back to the target as an IStream. Note that the
            // target is responsible for deleting the stream (via reference counting).
            AStream := TFixedStreamAdapter.Create(Stream, soOwned);
        finally
            setlength(vlist,0);
        end;
    except
        on e:Exception do begin
            bottompanel.caption:=bottompanel.caption+',Ex:'+e.message;
            if assigned(Stream) then Stream.Free;
            raise;
        end;
    end;
end;

@MicrotronX
Copy link
Author

Can i send you a private demo, i have extracted a some functions into a demo but don't want that to be online. It is a demo with two cx-grids. You can drop a file from explorer into both + drag&drop links between them (internal clipboardformat, dataformat). If you start this app again and try to drag&drop from first app grid to second app grid it does not work.

@landrix
Copy link
Owner

landrix commented Nov 2, 2020

you find my email on my github profile

@landrix
Copy link
Owner

landrix commented Nov 3, 2020

thank you, i need to modify your demo, i must remove the components, that i don't have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@landrix @MicrotronX and others