From d377d1f3a921488525f6e75c850632f559707747 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 21 Oct 2019 15:14:53 +0200 Subject: Enforce QTextDocument::MarkdownFeature compatibility at compile time We use md4c for parsing markdown. It provides flags to control the feature set that will be supported when parsing particular documents. QTextMarkdownImporter::Feature is a fine-grained set of flags that exactly match the md4c feature flags that we support in Qt so far. QTextMarkdownImporter is a private exported class (new in 5.14). We don't expect the corresponding flags in md4c to change in incompatible ways in the future: the md4c authors have as much respect for avoiding compatibility issues as we do, and likely will only add features, not remove them. We now enforce QTextMarkdownImporter::Features compatibility with QTextDocument::MarkdownFeatures by setting them directly. We check QTextMarkdownImporter::Features compatibility with md4c's #define'd feature flags using static asserts, so that any hypothetical incompatibility would be detected at compile time. The enum conversion from QTextDocument::MarkdownFeatures to QTextMarkdownImporter::Features is moved to a new QTextMarkdownImporter constructor; thus the conversions from QTextDocument::MarkdownFeatures to QTextMarkdownImporter::Features, and then to unsigned (in QTextMarkdownImporter::import()) are adjacent in the same private class implementation. If incompatibility ever occurred, we would need to replace one or both of those with another suitable conversion function. Change-Id: I0bf8a21eb7559df1d38406b948ef657f9060c67b Reviewed-by: Vitaly Fanaskov --- src/gui/text/qtextdocument.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gui/text/qtextdocument.h') diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index 2fadc40cd2..7d46238257 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -152,7 +152,6 @@ public: #endif #if QT_CONFIG(textmarkdownwriter) || QT_CONFIG(textmarkdownreader) - // Must be in sync with QTextMarkdownImporter::Features, should be in sync with #define MD_FLAG_* in md4c enum MarkdownFeature { MarkdownNoHTML = 0x0020 | 0x0040, MarkdownDialectCommonMark = 0, -- cgit v1.2.3