fixed crasher
authorKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Feb 2013 17:33:19 +0000 (09:33 -0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Feb 2013 17:33:19 +0000 (09:33 -0800)
lib/abstractpropertytype.cpp
lib/abstractpropertytype.h
lib/debugout.h
lib/vehicleproperty.cpp
plugins/dbus/abstractdbusinterface.cpp
plugins/dbus/varianttype.cpp
plugins/dbus/vehicleinfo.h

index d964d67..42e2a20 100644 (file)
@@ -12,9 +12,9 @@ ListPropertyType::ListPropertyType()
 
 }
 
-ListPropertyType::ListPropertyType(int)
+ListPropertyType::ListPropertyType(AbstractPropertyType *property)
 {
-
+       append(property);
 }
 
 ListPropertyType::ListPropertyType(ListPropertyType &other)
@@ -74,15 +74,17 @@ void ListPropertyType::fromString(std::string)
 GVariant *ListPropertyType::toVariant()
 {
        GVariantBuilder params;
-       g_variant_builder_init(&params,G_VARIANT_TYPE_ARRAY);
+       g_variant_builder_init(&params, G_VARIANT_TYPE_ARRAY);
 
        for(auto itr = mList.begin(); itr != mList.end(); itr++)
        {
-               AbstractPropertyType* t;
+               AbstractPropertyType* t = *itr;
                g_variant_builder_add_value(&params, t->toVariant());
        }
 
-       return g_variant_builder_end(&params);
+       GVariant* var =  g_variant_builder_end(&params);
+       g_assert(var);
+       return var;
 }
 
 
index 67c63a9..9ed7cf5 100644 (file)
@@ -367,7 +367,7 @@ class ListPropertyType: public AbstractPropertyType
 public:
 
        ListPropertyType();
-       ListPropertyType(int unused);
+       ListPropertyType(AbstractPropertyType *property);
        ListPropertyType(ListPropertyType & other);
        ~ListPropertyType();
 
index 8a0af60..6fbc690 100644 (file)
@@ -101,6 +101,7 @@ private:
        std::string bufferTime(double time)
        {
                ostringstream f;
+               f.precision(15);
                f<<time;
 
                while(f.str().length() < 15)
index 279b505..ae1d864 100644 (file)
@@ -182,7 +182,7 @@ VehicleProperty::VehicleProperty()
        REGISTERPROPERTY(Altitude,0);
        REGISTERPROPERTY(Direction,0);
        REGISTERPROPERTY(VehicleType,Vehicle::Unknown);
-       REGISTERPROPERTY(DoorsPerRow,0);
+       registerPropertyPriv(DoorsPerRow,[]() { BasicPropertyType<uint16_t> d(0); return new DoorsPerRowType(&d); });
        REGISTERPROPERTY(TransmissionGearType,Transmission::Unknown);
        REGISTERPROPERTYWITHTYPE(FrontWheelRadius, WheelRadiusType, 0);
        REGISTERPROPERTYWITHTYPE(RearWheelRadius, WheelRadiusType, 0);
index 88a02b1..789af5a 100644 (file)
@@ -134,14 +134,13 @@ void AbstractDBusInterface::updateValue(AbstractProperty *property)
 
        g_dbus_connection_emit_signal(mConnection, NULL, mObjectPath.c_str(), mInterfaceName.c_str(), string(property->name() + "Changed").c_str(), tuple_variant, &error);
 
-       //g_variant_unref(params[0]);
-       //g_variant_unref(params[1]);
        g_free(params);
        g_variant_unref(val);
 
        if(error)
        {
-               throw -1;
+               DebugOut(0)<<error->message<<endl;
+               //throw -1;
        }
 }
 
index b128f1c..acde5e3 100644 (file)
@@ -1,5 +1,6 @@
 #include "varianttype.h"
 #include "abstractroutingengine.h"
+#include "debugout.h"
 
 VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, std::string propertyName,  Access access, AbstractDBusInterface *interface)
        :AbstractProperty(propertyName, signature, access, interface),routingEngine(re)
@@ -21,7 +22,6 @@ GVariant *VariantType::toGVariant()
 {
        if(!value())
        {
-
                AbstractPropertyType* v = VehicleProperty::getPropertyTypeForPropertyNameValue(mPropertyName);
 
                setValue(v);
@@ -29,7 +29,9 @@ GVariant *VariantType::toGVariant()
                delete v;
        }
 
-       return value()->toVariant();
+       auto v = value();
+
+       return v->toVariant();
 }
 
 void VariantType::fromGVariant(GVariant *val)
@@ -42,6 +44,11 @@ void VariantType::fromGVariant(GVariant *val)
        request.value = v;
        request.completed = [](AsyncPropertyReply* reply)
        {
+               /// TODO: throw dbus exception
+               if(!reply->success)
+               {
+                       DebugOut(0)<<"Success fail";
+               }
                delete reply;
        };
 
index 87bb8a7..a5e3314 100644 (file)
@@ -66,7 +66,7 @@ public:
        DoorsProperty(AbstractRoutingEngine* re, GDBusConnection* connection)
                :DBusSink("org.automotive.doors","/org/automotive/vehicleinfo/doors", re, connection, map<string, string>())
        {
-               wantPropertyVariant(VehicleProperty::DoorsPerRow, "DoorsPerRow", "a(i)", AbstractProperty::Read);
+               wantPropertyVariant(VehicleProperty::DoorsPerRow, "DoorsPerRow", "ai", AbstractProperty::Read);
 
                supportedChanged(re->supported());
        }