[graphics/krita/krita/6.0] libs/ui/dialogs: [android] Properly check pre-existing frames
Carsten Hartenfels <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 8dc36b1b569434d69ff0faf64d643671dc059caa by Carsten Hartenfels.
Committed on 27/07/2026 at 17:19.
Pushed by hartenfels into branch 'krita/6.0'.
[android] Properly check pre-existing frames
When exporting animation frames, because trying to juggle the content
URI with QFileInfo doesn't work and just returns garbage, which means it
will never notice that there are existing files. Now the path mangling
is done manually instead.
M +29 -5 libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
https://invent.kde.org/graphics/krita/-/commit/8dc36b1b569434d69ff0faf64d643671dc059caa
diff --git a/libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp b/libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
index e123719c715..3c7fe51b79c 100644
--- a/libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
+++ b/libs/ui/dialogs/KisAsyncAnimationFramesSaveDialog.cpp
@@ -74,16 +74,40 @@ KisAsyncAnimationFramesSaveDialog::~KisAsyncAnimationFramesSaveDialog()
KisAsyncAnimationRenderDialogBase::Result KisAsyncAnimationFramesSaveDialog::regenerateRange(KisViewManager *viewManager)
{
- QFileInfo fileInfo(savedFilesMaskWildcard());
- QDir dir(fileInfo.absolutePath());
+ QString dirPath;
+ QString fileWildcard;
+#ifdef Q_OS_ANDROID
+ // QFileInfo can't manage to manipulate content URIs on Android, most
+ // functions either just hand you the entire input or an empty string, so
+ // we have to do the name mangling by hand.
+ {
+ QString wildcardPath = savedFilesMaskWildcard();
+ int lastSlashIndex = wildcardPath.lastIndexOf(QChar('/'));
+ KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(lastSlashIndex != -1, RenderFailed);
+ dirPath = wildcardPath.mid(0, lastSlashIndex);
+ fileWildcard = wildcardPath.mid(lastSlashIndex + 1);
+ }
+#else
+ {
+ QFileInfo fileInfo(savedFilesMaskWildcard());
+ dirPath = fileInfo.absolutePath();
+ fileWildcard = fileInfo.fileName();
+ }
+#endif
+ QDir dir(dirPath);
+ // On Android, directory existence checks are unreliable and creating
+ // directories is not allowed. We'll just have to take what we're given and
+ // hope that works out for us.
+#ifndef Q_OS_ANDROID
if (!dir.exists()) {
- dir.mkpath(fileInfo.absolutePath());
+ dir.mkpath(dirPath);
}
KIS_SAFE_ASSERT_RECOVER_NOOP(dir.exists());
+#endif
// Check for overwrite. (Batch mode always overwrites.)
- QStringList preexistingFileNames = dir.entryList({ fileInfo.fileName() });
+ QStringList preexistingFileNames = dir.entryList({ fileWildcard });
if (!preexistingFileNames.isEmpty() && !batchMode()) {
QStringList truncatedList = preexistingFileNames;
@@ -105,7 +129,7 @@ KisAsyncAnimationRenderDialogBase::Result KisAsyncAnimationFramesSaveDialog::reg
"deleted, continue?\n\n"
"Directory: %1\n"
"Files: %2",
- fileInfo.absolutePath(), exampleFiles),
+ dirPath, exampleFiles),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);