Skip to content

Commit

Permalink
fix: [clipboard]dde-file-manager block for a few seconds when using t…
Browse files Browse the repository at this point in the history
…he shortcut ctrl+c

Commit less code, loop to create fileinfo for all url before writing to clipboard. change to take only 3 files to create fileinfo and then get icon

Log: dde-file-manager block for a few seconds when using the shortcut ctrl+c
Bug: https://pms.uniontech.com/bug-view-211657.html
  • Loading branch information
liyigang1 authored and deepin-bot[bot] committed Jul 27, 2023
1 parent 1491572 commit ed1719f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/dfm-base/utils/clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,17 @@ void ClipBoard::setUrlsToClipboard(const QList<QUrl> &list, ClipBoard::Clipboard
ba.append(qurl.toString());

const QString &path = qurl.toLocalFile();

const FileInfoPointer &info = InfoFactory::create<FileInfo>(qurl, Global::CreateFileInfoType::kCreateFileInfoAuto, &error);

if (!info) {
qWarning() << QString("create file info error, case : %1").arg(error);
continue;
if (!path.isEmpty()) {
text += path + '\n';
}

if (maxIconsNum-- > 0) {
const FileInfoPointer &info = InfoFactory::create<FileInfo>(qurl, Global::CreateFileInfoType::kCreateFileInfoAuto, &error);

if (!info) {
qWarning() << QString("create file info error, case : %1").arg(error);
continue;
}
QStringList iconList;
if (info->isAttributes(OptInfoType::kIsSymLink)) {
iconList << "emblem-symbolic-link";
Expand Down Expand Up @@ -153,10 +156,6 @@ void ClipBoard::setUrlsToClipboard(const QList<QUrl> &list, ClipBoard::Clipboard
}
stream << iconList << icon;
}

if (!path.isEmpty()) {
text += path + '\n';
}
}

mimeData->setText(text.endsWith('\n') ? text.left(text.length() - 1) : text);
Expand Down

0 comments on commit ed1719f

Please sign in to comment.