]> sigrok.org Git - pulseview.git/commitdiff
SignalBase: Work around QColor serialization bug on OSX
authorSoeren Apel <redacted>
Sat, 27 Oct 2018 15:06:07 +0000 (17:06 +0200)
committerUwe Hermann <redacted>
Sat, 27 Oct 2018 19:17:52 +0000 (21:17 +0200)
pv/data/signalbase.cpp

index 9f35725f8df1cc540e032680cb70d31b4fe6b5ad..670de49874326006f83b441074cc1d783c4767ae 100644 (file)
@@ -450,7 +450,7 @@ void SignalBase::save_settings(QSettings &settings) const
 {
        settings.setValue("name", name());
        settings.setValue("enabled", enabled());
-       settings.setValue("color", color());
+       settings.setValue("color", color().rgba());
        settings.setValue("conversion_type", (int)conversion_type_);
 
        settings.setValue("conv_options", (int)(conversion_options_.size()));
@@ -470,8 +470,15 @@ void SignalBase::restore_settings(QSettings &settings)
        if (settings.contains("enabled"))
                set_enabled(settings.value("enabled").toBool());
 
-       if (settings.contains("color"))
-               set_color(settings.value("color").value<QColor>());
+       if (settings.contains("color")) {
+               QVariant value = settings.value("color");
+
+               // Workaround for Qt QColor serialization bug on OSX
+               if (((QMetaType::Type)(value.type()) == QMetaType::QColor) && value.isValid())
+                       set_color(value.value<QColor>());
+               else
+                       set_color(QColor::fromRgba(value.value<uint32_t>()));
+       }
 
        if (settings.contains("conversion_type"))
                set_conversion_type((ConversionType)settings.value("conversion_type").toInt());