Added hex version checking to the project file to warn the user if opening a file 'from the future'.
This commit is contained in:
@@ -41,6 +41,7 @@ __author__ = "Veronica Berglyd Olsen"
|
||||
__copyright__ = "Copyright 2018–2020, Veronica Berglyd Olsen"
|
||||
__license__ = "GPLv3"
|
||||
__version__ = "0.5"
|
||||
__hexversion__ = "0x000500f0"
|
||||
__date__ = "2020-05-09"
|
||||
__maintainer__ = "Veronica Berglyd Olsen"
|
||||
__email__ = "code@vkbo.net"
|
||||
|
||||
@@ -39,6 +39,8 @@ from hashlib import sha256
|
||||
from time import time
|
||||
from shutil import make_archive
|
||||
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
from nw.gui.tools import OptionState
|
||||
from nw.core.tools import projectMaintenance
|
||||
from nw.core.document import NWDoc
|
||||
@@ -285,12 +287,15 @@ class NWProject():
|
||||
nwxRoot = xRoot.tag
|
||||
|
||||
appVersion = "Unknown"
|
||||
hexVersion = "0x0"
|
||||
fileVersion = "Unknown"
|
||||
self.saveCount = 0
|
||||
self.autoCount = 0
|
||||
|
||||
if "appVersion" in xRoot.attrib:
|
||||
appVersion = xRoot.attrib["appVersion"]
|
||||
if "hexVersion" in xRoot.attrib:
|
||||
hexVersion = xRoot.attrib["hexVersion"]
|
||||
if "fileVersion" in xRoot.attrib:
|
||||
fileVersion = xRoot.attrib["fileVersion"]
|
||||
if "saveCount" in xRoot.attrib:
|
||||
@@ -308,6 +313,18 @@ class NWProject():
|
||||
)
|
||||
return False
|
||||
|
||||
if int(hexVersion, 16) > int(nw.__hexversion__, 16):
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(self.theParent, "Version Conflict", (
|
||||
"This project was saved by a newer version of %s, version %s. This is version %s. "
|
||||
"If you continue to open the project, some attributes and settings may not be "
|
||||
"preserved. Continue opening the project?"
|
||||
) % (
|
||||
nw.__package__, appVersion, nw.__version__
|
||||
))
|
||||
if msgRes != QMessageBox.Yes:
|
||||
return False
|
||||
|
||||
for xChild in xRoot:
|
||||
if xChild.tag == "project":
|
||||
logger.debug("Found project meta")
|
||||
@@ -397,6 +414,7 @@ class NWProject():
|
||||
logger.debug("Writing project meta")
|
||||
nwXML = etree.Element("novelWriterXML",attrib={
|
||||
"appVersion" : str(nw.__version__),
|
||||
"hexVersion" : str(nw.__hexversion__),
|
||||
"fileVersion" : "1.0",
|
||||
"saveCount" : str(self.saveCount),
|
||||
"autoCount" : str(self.autoCount),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="0.4.5" fileVersion="1.0" saveCount="127" autoCount="17" timeStamp="2020-05-09 16:03:23">
|
||||
<novelWriterXML appVersion="0.5" hexVersion="0x000500f0" fileVersion="1.0" saveCount="130" autoCount="17" timeStamp="2020-05-11 19:23:21">
|
||||
<project>
|
||||
<name>Sample Project</name>
|
||||
<title>Sample Project</title>
|
||||
|
||||
Reference in New Issue
Block a user