Bug 416921 - python copy paste selection - Paste issue (not paste action)
Summary: python copy paste selection - Paste issue (not paste action)
Status: RESOLVED INTENTIONAL
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: 4.2.8
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-29 18:11 UTC by keyth_qcfx2
Modified: 2020-07-31 15:51 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
copy paste code (641 bytes, text/plain)
2020-01-29 18:13 UTC, keyth_qcfx2
Details

Note You need to log in before you can comment on or make changes to this bug.
Description keyth_qcfx2 2020-01-29 18:11:54 UTC
SUMMARY
Copy paste a user selection with python code gives faulty results.
I am not talking about actions in this case, actions work well.

STEPS TO REPRODUCE
1. Make a Manual Selection on any image
2. Copy Selection with python code (not actions)
3. Paste Selection with python code (not actions)

OBSERVED RESULT
the pasted image is cuted in a weird way and the pasted result is only a percentage of the image in the clipboard.
Even after that, if a paste action command is given it will come out right.

EXPECTED RESULT
I expect for the paste command to paste "everything" inside the clipboard.

SOFTWARE/OS VERSIONS
Windows: 10

ADDITIONAL INFORMATION:
I made a video showing it happening, an example code and a working file.

video : https://www.youtube.com/watch?v=N86upR2WMhE&feature=emb_logo
Comment 1 keyth_qcfx2 2020-01-29 18:13:31 UTC
Created attachment 125525 [details]
copy paste code

just some code that copies the selection and then pastes it.
Comment 2 keyth_qcfx2 2020-01-29 18:20:09 UTC
file : https://ufile.io/uu1g1myk
this file is just a random image with a active selection on it running the code will give the same exact result as in the video.
Comment 3 wolthera 2020-02-17 14:42:19 UTC
I am not getting errors with this in Krita Version: 4.3.0-prealpha (git 33e8716), Qt version compiled: 5.13.2, loaded: 5.13.2. Process ID: 25526
Comment 4 wolthera 2020-02-17 14:45:15 UTC
it only starts doing something funny here when I do it twice.
Comment 5 keyth_qcfx2 2020-02-20 23:37:59 UTC
only on the 2nd try? with me it does it right away every time, on the recording I opened krita with 2 grid lines a selection and a random image and nothing else.

You think is a problem in the code I made (like in the sequence order or is it lacking some other command then) or is it really in the paste command then?

I tryed to look up as much info as I could on the topic but I can't say for certain, but my feeling is that it's on the command itself somewhere. I compared the C++ file and the Python one, and the python one looked to lack some cases inside (but I dont read C++ to know better).
Comment 6 Scott Petrovic 2020-07-31 15:51:35 UTC
This was written a little while ago, but I looked at it briefly.

The way the paste() works right now, it requires a selection. When you do the deselect action in your code snippet, you are making it so the paste operation doesn't work. 

See this code. https://api.kde.org/appscomplete-api/krita-apidocs/libs/libkis/html/Selection_8cpp_source.html#l00177

If there is no selection, the paste isn't going to work. The way it works otherwise is that it will truncate some of your copied content depending on what you put fot he x and y position.

My recommendation is probably just not to use the paste(). It is probably better to just use the paste action. You can move it around as needed, then merge down to a below layer if it needs to be on another layer.

If there are coding questions like this, we also have a new krita-artists website that you can post questions to (https://krita-artists.org/). There is a good community of developers on there to help with scripting questions like this too. I am going to close this for now. If there is something else that comes up we can make a new ticket.