summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-10-21 15:14:53 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-10-24 20:58:44 +0200
commitd377d1f3a921488525f6e75c850632f559707747 (patch)
treee351fc46db44119a6499f1c4543084b1c83c27dd /src/gui/text/qtextdocument.h
parent5edf34848a51c7678031aeb9576b8f3b7b5fceab (diff)
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 <vitaly.fanaskov@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocument.h')
-rw-r--r--src/gui/text/qtextdocument.h1
1 files changed, 0 insertions, 1 deletions
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,