Commit 52ee93a9 authored by Agata Cacko's avatar Agata Cacko
Browse files

Fix loading wrong file format (progress bar + recent docs)

Before this patch, when you forced Krita to load file in
unknown format, it showed uncancelled progress bar and
showed the file in Recent Documents.
It happened when you dragged and dropped file to the
welcome screen or import animation frames or use Open->File
or Open -> Recent Files.
Progress bars were visible only when some image was opened.
This commit cancels progress bars and make sure unloadable
files are not added to Recent Documents.


Test Plan:
1. Create an unloadable file. Can be "touch a".
2. Load it using one of the ways mentioned above
3. After loading, there is an error message. Click ok.
4. If you used Import Animation Frames, look at the bottom
of Krita window.
- before: progress bar still "loading"
- now: no progress bar visible
5. If you used other option, create a new file or open
something else, and you'll see the same effect.
6. Look at Recent Documents.
- before: unloadable file added to list
- now: no unloadable file added to list
(beside the ones that were aleady there after testing)

Reviewers: #krita, rempt

Reviewed By: #krita, rempt

Tags: #krita

Differential Revision:
parent 27947095
......@@ -1185,11 +1185,12 @@ bool KisDocument::openUrl(const QUrl &_url, OpenFlags flags)
else {
if (!(flags & DontAddToRecent)) {
if (ret) {
if ((flags & DontAddToRecent)) {
// Detect readonly local-files; remote files are assumed to be writable
QFileInfo fi(url.toLocalFile());
......@@ -1271,8 +1272,9 @@ bool KisDocument::openFile()
dbgUI << localFilePath() << "type:" << typeName;
KisMainWindow *window = KisPart::instance()->currentMainwindow();
KoUpdaterPtr updater;
if (window && window->viewManager()) {
KoUpdaterPtr updater = window->viewManager()->createUnthreadedUpdater(i18n("Opening document"));
updater = window->viewManager()->createUnthreadedUpdater(i18n("Opening document"));
......@@ -1281,6 +1283,9 @@ bool KisDocument::openFile()
status = d->importExportManager->importDocument(localFilePath(), typeName);
if (status != KisImportExportFilter::OK) {
if (window && window->viewManager()) {
QString msg = KisImportExportFilter::conversionStatusString(status);
if (!msg.isEmpty()) {
DlgLoadMessages dlg(i18nc("@title:window", "Krita"),
......@@ -1668,8 +1673,9 @@ void KisDocument::setLocalFilePath( const QString &localFilePath )
bool KisDocument::openUrlInternal(const QUrl &url)
if ( !url.isValid() )
if ( !url.isValid() ) {
return false;
if (d->m_bAutoDetectedMime) {
d->mimeType = QByteArray();
......@@ -1678,8 +1684,9 @@ bool KisDocument::openUrlInternal(const QUrl &url)
QByteArray mimetype = d->mimeType;
if ( !closeUrl() )
if ( !closeUrl() ) {
return false;
d->mimeType = mimetype;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment