The session config file $HOME/.config/katemetainfos stores the mode of the last open files. However, it may contain invalid or non-existent modes, for example, when applying an highlighting mode of a custom XML file that will be renamed or deleted. Therefore, a verification is added, only existing modes will be applied.
- The KTextEditor::DocumentPrivate::updateFileType() function now returns a boolean, which is false if the mode name entered in the parameter doesn't exist or is invalid.
- Modes with empty names are considered invalid, since KateModeManager::fileType(const QString &name) returns an empty KateFileType object if the name of the parameter doesn't exist. It's understood that the name of a mode shouldn't be empty, since it acts as a unique identifier.
- When reading the session config file (KTextEditor::DocumentPrivate::readSessionConfig()), it's checked if the stored mode is valid. If the mode is invalid, it will not be applied and the default mode will be used, depending on the file extension or MIME-type.