summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2018-03-20 13:12:10 (GMT)
committerTobias Markmann <tm@ayena.de>2018-03-20 14:48:04 (GMT)
commitf2c2c7d035029fb9615b42c18ccea83e8e705b10 (patch)
tree2f56fb77de0f366528395f21732d418f016f63b5 /Swift/Controllers/Highlighting
parent44581c5285d13c0ec715b35ddc79177e5ebeef39 (diff)
parent5ba3f18ad8efa040d49f36d83ec2e7891a9add9f (diff)
downloadswift-f2c2c7d035029fb9615b42c18ccea83e8e705b10.zip
swift-f2c2c7d035029fb9615b42c18ccea83e8e705b10.tar.bz2
Merge branch 'swift-4.x'swift-5.0alpha2
* swift-4.x: (44 commits) Test-Information: Builds on macOS 10.13.3 with clang trunk. Change-Id: If50381f103b0ad18d038b920d3d43537642141cb
Diffstat (limited to 'Swift/Controllers/Highlighting')
-rw-r--r--Swift/Controllers/Highlighting/HighlightAction.cpp2
-rw-r--r--Swift/Controllers/Highlighting/HighlightAction.h56
2 files changed, 52 insertions, 6 deletions
diff --git a/Swift/Controllers/Highlighting/HighlightAction.cpp b/Swift/Controllers/Highlighting/HighlightAction.cpp
index e9f14df..60ace42 100644
--- a/Swift/Controllers/Highlighting/HighlightAction.cpp
+++ b/Swift/Controllers/Highlighting/HighlightAction.cpp
@@ -12,6 +12,8 @@
#include <Swift/Controllers/Highlighting/HighlightAction.h>
+BOOST_CLASS_VERSION(Swift::HighlightAction, 1)
+
namespace Swift {
diff --git a/Swift/Controllers/Highlighting/HighlightAction.h b/Swift/Controllers/Highlighting/HighlightAction.h
index da92901..d11f3ec 100644
--- a/Swift/Controllers/Highlighting/HighlightAction.h
+++ b/Swift/Controllers/Highlighting/HighlightAction.h
@@ -12,11 +12,14 @@
#pragma once
+#include <map>
+#include <memory>
#include <string>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/optional.hpp>
+#include <boost/serialization/map.hpp>
#include <boost/serialization/optional.hpp>
namespace Swift {
@@ -57,12 +60,53 @@ namespace Swift {
bool operator ==(const HighlightAction& a, const HighlightAction& b);
bool operator !=(const HighlightAction& a, const HighlightAction& b);
+
template<class Archive>
- void HighlightAction::serialize(Archive& ar, const unsigned int /*version*/) {
- ar & frontColor_;
- ar & backColor_;
- ar & soundFilePath_;
- ar & systemNotificaitonEnabled_;
+ void HighlightAction::serialize(Archive& ar, const unsigned int version) {
+ auto inputStream = dynamic_cast<boost::archive::text_iarchive*>(&ar);
+ auto outputStream = dynamic_cast<boost::archive::text_oarchive*>(&ar);
+
+ if (version == 0) {
+ if (inputStream) {
+ const boost::archive::library_version_type BoostArchiveSkipVersion(15);
+ auto archiveLibraryVersion = boost::archive::BOOST_ARCHIVE_VERSION();
+ //Due to https://svn.boost.org/trac10/ticket/13050 the boost::optional fields may fail to load and crash the client. Therefore we skip loading the values from previous versions.
+ if (archiveLibraryVersion == BoostArchiveSkipVersion && archiveLibraryVersion > inputStream->get_library_version()) {
+ return;
+ }
+ }
+ ar & frontColor_;
+ ar & backColor_;
+ ar & soundFilePath_;
+ ar & systemNotificaitonEnabled_;
+ }
+ else if (version == 1) {
+ //Using a map instead of optional values that may cause a problems when serialised with boost::archive 15 version
+ std::map<std::string, std::string> properties;
+ if (outputStream) {
+ if (frontColor_.is_initialized()) {
+ properties["frontColor"] = frontColor_.get();
+ }
+ if (backColor_.is_initialized()) {
+ properties["backColor"] = backColor_.get();
+ }
+ if (soundFilePath_.is_initialized()) {
+ properties["soundFilePath"] = soundFilePath_.get();
+ }
+ }
+ ar & properties;
+ ar & systemNotificaitonEnabled_;
+ if (inputStream) {
+ if (properties.find("frontColor") != properties.end()) {
+ frontColor_ = properties["frontColor"];
+ }
+ if (properties.find("backColor") != properties.end()) {
+ backColor_ = properties["backColor"];
+ }
+ if (properties.find("soundFilePath") != properties.end()) {
+ soundFilePath_ = properties["soundFilePath"];
+ }
+ }
+ }
}
-
}