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

Cut, New Window, Paste ends up copying file instead of moving it #192

Open
k9spud opened this issue Dec 20, 2023 · 1 comment
Open

Cut, New Window, Paste ends up copying file instead of moving it #192

k9spud opened this issue Dec 20, 2023 · 1 comment

Comments

@k9spud
Copy link

k9spud commented Dec 20, 2023

The following sequence should result in moving a file, but instead, it only copies the file:

  1. Open Qtfm and navigate to a folder.
  2. Select a file, right click "Cut"
  3. Select File -> New Window.
  4. In the new window, navigate to some other folder then select Edit -> Paste.

Result:
The file "Cut" in step 2 should be moved to the destination folder and no longer exist in the source folder.

However, Qtfm 6.2.1 incorrectly copies the file to the destination folder while leaving the original file in the source folder.

I have looked around in the source code and tried debugging this problem. From what I've learned, when the user selects files to "Cut" in qtfm, the program stores a list of the selected "Cut" files in "/tmp/qtfm.temp" and also puts some mimeData into the clipboard (but this mimeData does not contain "Urls").

A problem occurs when a new qtfm process is started. Right away, the new qtfm process deletes the "/tmp/qtfm.temp" file for no good reason. Without the temp file, when the user tries to paste, Qtfm no longer thinks of it as a Cut and Paste action and instead does a Copy and Paste.

Qtfm deletes the temp file due to the following code from fm/src/mainwindow.cpp:

void MainWindow::clipboardChanged()
{
    qDebug() << "clipboard changed";
    if (QApplication::clipboard()->mimeData()) {
        // if (QApplication::clipboard()->mimeData()->hasUrls()) {
            qDebug() << "clipboard has data, enable paste";
            pasteAct->setEnabled(true);
            return;
        // }
    }
    // clear tmp and disable paste if no mime
    modelList->clearCutItems();
    pasteAct->setEnabled(false);
}

Commenting out the if (... hasUrls()) { block (as shown above) seems to fix the problem for me. I do not know if this causes other problems though.

@onelittlehope
Copy link

Not relevant to this bug report and am just pointing out that guessable file names under world read/writable directories like /tmp can be a security issue.

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

No branches or pull requests

2 participants