[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-i18n-doc
Subject: [krita] /: BUG:371523 Do not crash on opening Gimp 2.9 files
From: Boudewijn Rempt <boud () valdyas ! org>
Date: 2016-10-23 14:25:22
Message-ID: E1byJiE-0003x6-VR () code ! kde ! org
[Download RAW message or body]
Git commit adf8f6ee59820f5147a60af82bc3ff7e2f873153 by Boudewijn Rempt.
Committed on 23/10/2016 at 14:25.
Pushed by rempt into branch 'master'.
BUG:371523 Do not crash on opening Gimp 2.9 files
Krita cannot load Gimp 2.9 files (and never will be, probably,
because xcf-tools isn't maintained anymore and the file format
is un(der)documented). But we shouldn't crash and burn trying
to load them anyway.
This adds two new strings for translation, I'm afraid :-(
CCMAIL:kde-i18n-doc@kde.org
M +5 -0 libs/ui/KisImportExportFilter.cpp
M +1 -0 libs/ui/KisImportExportFilter.h
M +9 -11 plugins/impex/xcf/3rdparty/xcftools/xcf-general.c
M +6 -0 plugins/impex/xcf/kis_xcf_import.cpp
http://commits.kde.org/krita/adf8f6ee59820f5147a60af82bc3ff7e2f873153
diff --git a/libs/ui/KisImportExportFilter.cpp b/libs/ui/KisImportExportFilter.cpp
index 5fd237a..c3dbcbd 100644
--- a/libs/ui/KisImportExportFilter.cpp
+++ b/libs/ui/KisImportExportFilter.cpp
@@ -153,11 +153,16 @@ QString \
KisImportExportFilter::conversionStatusString(ConversionStatus status)
msg = i18n("Unknown file type"); break;
+ case UnsupportedVersion:
+
+ msg = i18n("Unsupported file version"); break;
+
case UserCancelled:
// intentionally we do not prompt the error message here
break;
+
default: msg = i18n("Unknown error"); break;
}
return msg;
diff --git a/libs/ui/KisImportExportFilter.h b/libs/ui/KisImportExportFilter.h
index c5bc6e6..3ffdb39 100644
--- a/libs/ui/KisImportExportFilter.h
+++ b/libs/ui/KisImportExportFilter.h
@@ -93,6 +93,7 @@ public:
DownloadFailed,
FilterCreationError,
ProgressCancelled,
+ UnsupportedVersion,
JustInCaseSomeBrokenCompilerUsesLessThanAByte = 255
};
diff --git a/plugins/impex/xcf/3rdparty/xcftools/xcf-general.c \
b/plugins/impex/xcf/3rdparty/xcftools/xcf-general.c index b23c260..3716917 100644
--- a/plugins/impex/xcf/3rdparty/xcftools/xcf-general.c
+++ b/plugins/impex/xcf/3rdparty/xcftools/xcf-general.c
@@ -2,7 +2,7 @@
*
* This file was written by Henning Makholm <henning@makholm.net>
* It is hereby in the public domain.
- *
+ *
* In jurisdictions that do not recognise grants of copyright to the
* public domain: I, the author and (presumably, in those jurisdictions)
* copyright holder, hereby permit anyone to distribute and use this code,
@@ -92,7 +92,7 @@ xcfString(uint32_t ptr,uint32_t *after)
uint32_t length ;
unsigned i ;
ICONV_CONST char *utf8master ;
-
+
xcfCheckspace(ptr,4,"(string length)");
length = xcfL(ptr) ;
ptr += 4 ;
@@ -197,7 +197,7 @@ getBasicXcfInfo(void)
uint32_t ptr, data, layerfile ;
PropType type ;
int i, j ;
-
+
xcfCheckspace(0,14+7*4,"(very short)");
if( strcmp((char*)xcf_file,"gimp xcf file") == 0 )
XCF.version = 0 ;
@@ -207,15 +207,13 @@ getBasicXcfInfo(void)
else
FatalBadXCF(_("Not an XCF file at all (magic not recognized)"));
- if( XCF.version < 0 || XCF.version > 3 ) {
- fprintf(stderr,
- _("Warning: XCF version %d not supported (trying anyway...)\n"),
- XCF.version);
+ if (XCF.version < 0 || XCF.version > 3) {
+ return;
}
-
+
XCF.compression = COMPRESS_NONE ;
XCF.colormapptr = 0 ;
-
+
ptr = 14 ;
XCF.width = xcfL(ptr); ptr += 4 ;
XCF.height = xcfL(ptr); ptr += 4 ;
@@ -283,9 +281,9 @@ getBasicXcfInfo(void)
L->pathLength = (ptr - data - 2) / 4 ;
if ( L->pathLength != 0 ) {
-
+
L->path = xcfmalloc( L->pathLength * sizeof(unsigned) ) ;
-
+
for ( j = 0; j!=L->pathLength; j++ )
*(L->path + j) = (unsigned)xcfL(data + 4 * j);
}
diff --git a/plugins/impex/xcf/kis_xcf_import.cpp \
b/plugins/impex/xcf/kis_xcf_import.cpp index d926632..939003b 100644
--- a/plugins/impex/xcf/kis_xcf_import.cpp
+++ b/plugins/impex/xcf/kis_xcf_import.cpp
@@ -196,6 +196,12 @@ KisImportExportFilter::ConversionStatus \
KisXCFImport::loadFromDevice(QIODevice*
// Decode the data
getBasicXcfInfo() ;
+
+ if (XCF.version < 0 || XCF.version > 3) {
+ doc->setErrorMessage(i18n("This XCF file is too new; Krita cannot support \
XCF files written by GIMP 2.9 or newer.")); + return \
KisImportExportFilter::UnsupportedVersion; + }
+
initColormap();
dbgFile << XCF.version << "width = " << XCF.width << "height = " << XCF.height \
<< "layers = " << XCF.numLayers;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic