| 1046 | |
| 1047 | |
| 1048 | void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile ) |
| 1049 | { |
| 1050 | QString errorMsg; |
| 1051 | int line = -1, col = -1; |
| 1052 | if( !setContent( _data, &errorMsg, &line, &col ) ) |
| 1053 | { |
| 1054 | // parsing failed? then try to uncompress data |
| 1055 | QByteArray uncompressed = qUncompress( _data ); |
| 1056 | if( !uncompressed.isEmpty() ) |
| 1057 | { |
| 1058 | if( setContent( uncompressed, &errorMsg, &line, &col ) ) |
| 1059 | { |
| 1060 | line = col = -1; |
| 1061 | } |
| 1062 | } |
| 1063 | if( line >= 0 && col >= 0 ) |
| 1064 | { |
| 1065 | qWarning() << "at line" << line << "column" << errorMsg; |
| 1066 | if( gui ) |
| 1067 | { |
| 1068 | QMessageBox::critical( NULL, |
| 1069 | SongEditor::tr( "Error in file" ), |
| 1070 | SongEditor::tr( "The file %1 seems to contain " |
| 1071 | "errors and therefore can't be " |
| 1072 | "loaded." ). |
| 1073 | arg( _sourceFile ) ); |
| 1074 | } |
| 1075 | |
| 1076 | return; |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | QDomElement root = documentElement(); |
| 1081 | m_type = type( root.attribute( "type" ) ); |
| 1082 | m_head = root.elementsByTagName( "head" ).item( 0 ).toElement(); |
| 1083 | |
| 1084 | |
| 1085 | if( root.hasAttribute( "creatorversion" ) ) |
| 1086 | { |
| 1087 | // compareType defaults to Build,so it doesn't have to be set here |
| 1088 | ProjectVersion createdWith = root.attribute( "creatorversion" ); |
| 1089 | ProjectVersion openedWith = LMMS_VERSION; |
| 1090 | |
| 1091 | if ( createdWith != openedWith ) |
| 1092 | { |
| 1093 | // only one compareType needs to be set, and we can compare on one line because setCompareType returns ProjectVersion |
| 1094 | if( createdWith.setCompareType( ProjectVersion::Minor ) |
| 1095 | != openedWith ) |
| 1096 | { |
| 1097 | if( gui != nullptr && root.attribute( "type" ) == "song" ) |
| 1098 | { |
| 1099 | TextFloat::displayMessage( |
| 1100 | SongEditor::tr( "Version difference" ), |
| 1101 | SongEditor::tr( |
| 1102 | "This %1 was created with " |
| 1103 | "LMMS %2." |
| 1104 | ).arg( |
| 1105 | _sourceFile.endsWith( ".mpt" ) ? |
nothing calls this directly
no test coverage detected