Skip to content

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

@k9spud

Description

@k9spud

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions