From 2291decf1d2a2a6cb88f600c3371bcecda0e51c7 Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Fri, 19 Feb 2016 11:06:04 +0000 Subject: use logging categories --- libqmenumodel/src/unitymenumodel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 63d5e5b..67fe95d 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -22,6 +22,7 @@ #include "unitymenumodelevents.h" #include "unitymenuaction.h" #include "unitymenuactionevents.h" +#include "logging.h" #include #include @@ -33,6 +34,8 @@ extern "C" { #include "gtk/gtksimpleactionobserver.h" } +Q_LOGGING_CATEGORY(unitymenumodel, "qmenumodel.unitymenumodel", QtWarningMsg) + G_DEFINE_QUARK (UNITY_MENU_MODEL, unity_menu_model) G_DEFINE_QUARK (UNITY_SUBMENU_MODEL, unity_submenu_model) G_DEFINE_QUARK (UNITY_MENU_ITEM_EXTENDED_ATTRIBUTES, unity_menu_item_extended_attributes) @@ -654,7 +657,7 @@ bool UnityMenuModel::loadExtendedAttributes(int position, const QVariantMap &sch GVariant *value = gtk_menu_tracker_item_get_attribute_value (item, name.toUtf8(), NULL); if (value == NULL) { - qWarning("loadExtendedAttributes: menu item does not contain '%s'", it.key().toUtf8().constData()); + qCDebug(unitymenumodel, "loadExtendedAttributes: menu item does not contain '%s'", it.key().toUtf8().constData()); continue; } @@ -662,7 +665,7 @@ bool UnityMenuModel::loadExtendedAttributes(int position, const QVariantMap &sch if (qvalue.isValid()) extendedAttrs->insert(qtify_name (name.toUtf8()), qvalue); else - qWarning("loadExtendedAttributes: key '%s' is of type '%s' (expected '%s')", + qCWarning(unitymenumodel, "loadExtendedAttributes: key '%s' is of type '%s' (expected '%s')", name.toUtf8().constData(), g_variant_get_type_string(value), type.constData()); g_variant_unref (value); -- cgit v1.2.3 From 2bf63470a4d25af32eb6c39b9c5da2e64a9cdf8f Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Tue, 23 Feb 2016 14:29:04 +0000 Subject: added missing file --- libqmenumodel/src/logging.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 libqmenumodel/src/logging.h (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/logging.h b/libqmenumodel/src/logging.h new file mode 100644 index 0000000..bd7e708 --- /dev/null +++ b/libqmenumodel/src/logging.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License version 3, as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef QMENUMODEL_LOGGING_H +#define QMENUMODEL_LOGGING_H + +#include +Q_DECLARE_LOGGING_CATEGORY(unitymenumodel) + +#endif // QMENUMODEL_LOGGING_H -- cgit v1.2.3 From 4ad605553fa905edb3a78578fa01dba6c2819176 Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Tue, 23 Feb 2016 14:35:57 +0000 Subject: only log critical --- libqmenumodel/src/unitymenumodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 67fe95d..70412a4 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -34,7 +34,7 @@ extern "C" { #include "gtk/gtksimpleactionobserver.h" } -Q_LOGGING_CATEGORY(unitymenumodel, "qmenumodel.unitymenumodel", QtWarningMsg) +Q_LOGGING_CATEGORY(unitymenumodel, "qmenumodel.unitymenumodel", QtCriticalMsg) G_DEFINE_QUARK (UNITY_MENU_MODEL, unity_menu_model) G_DEFINE_QUARK (UNITY_SUBMENU_MODEL, unity_submenu_model) @@ -657,7 +657,7 @@ bool UnityMenuModel::loadExtendedAttributes(int position, const QVariantMap &sch GVariant *value = gtk_menu_tracker_item_get_attribute_value (item, name.toUtf8(), NULL); if (value == NULL) { - qCDebug(unitymenumodel, "loadExtendedAttributes: menu item does not contain '%s'", it.key().toUtf8().constData()); + qCWarning(unitymenumodel, "loadExtendedAttributes: menu item does not contain '%s'", it.key().toUtf8().constData()); continue; } -- cgit v1.2.3 From c6bba62bdac1f3cdb20e9bd7a763a2ec03beeb44 Mon Sep 17 00:00:00 2001 From: Florian Boucault Date: Tue, 19 Jul 2016 22:41:52 +0200 Subject: Crossbuilding fixes. --- libqmenumodel/QMenuModel/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/QMenuModel/CMakeLists.txt b/libqmenumodel/QMenuModel/CMakeLists.txt index 78e062b..eb4d463 100644 --- a/libqmenumodel/QMenuModel/CMakeLists.txt +++ b/libqmenumodel/QMenuModel/CMakeLists.txt @@ -24,11 +24,7 @@ qt5_use_modules(qmenumodel-qml Qml Quick) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qmldir" "${CMAKE_CURRENT_BINARY_DIR}/qmldir") -execute_process( - COMMAND qmake -query QT_INSTALL_QML - OUTPUT_VARIABLE QT_IMPORTS_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE -) +set(QT_IMPORTS_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/qml") set(QMLPLUGIN_INSTALL_PREFIX "${QT_IMPORTS_DIR}/QMenuModel") install(TARGETS qmenumodel-qml DESTINATION ${QMLPLUGIN_INSTALL_PREFIX}) install(FILES qmldir DESTINATION ${QMLPLUGIN_INSTALL_PREFIX}) -- cgit v1.2.3 From 449ac3d20ef7aa4d63f258eeb2a160a5f55cfa9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 14 Oct 2016 17:26:49 +0200 Subject: Converter: add support to LongLong and ULongLong --- libqmenumodel/src/converter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 69e6629..021fc82 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -156,12 +156,18 @@ GVariant* Converter::toGVariant(const QVariant &value) case QVariant::Int: result = g_variant_new_int32(value.toInt()); break; + case QVariant::LongLong: + result = g_variant_new_int64(value.toLongLong()); + break; case QVariant::String: result = g_variant_new_string(value.toString().toUtf8().data()); break; case QVariant::UInt: result = g_variant_new_uint32(value.toUInt()); break; + case QVariant::ULongLong: + result = g_variant_new_uint64(value.toULongLong()); + break; case QVariant::Map: { GVariantBuilder *b; -- cgit v1.2.3 From 1e9cf635d3074b82759b0edab44ba4549af5085e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 14 Oct 2016 17:29:10 +0200 Subject: UnityMenuModel add support for activating and changing state with a variant string parameter --- libqmenumodel/src/unitymenumodel.cpp | 34 ++++++++++++++++++++++++++++++++++ libqmenumodel/src/unitymenumodel.h | 2 ++ 2 files changed, 36 insertions(+) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 70412a4..6e9a5f7 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -715,6 +715,40 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) } } +static QVariant parseVariantString(const QString& string) +{ + QVariant qvariant; + GVariant *gvariant; + GError *error = NULL; + + if (string.isEmpty()) { + return qvariant; + } + + gvariant = g_variant_parse (NULL, string.toStdString().c_str(), NULL, NULL, &error); + + if (error) { + qWarning() << "Impossible to parse" << string << "as variant string:"<< error->message; + g_error_free (error); + return qvariant; + } + + qvariant = Converter::toQVariant(gvariant); + g_variant_unref (gvariant); + + return qvariant; +} + +void UnityMenuModel::activateByVariantString(int index, const QString& parameter) +{ + activate(index, parseVariantString(parameter)); +} + +void UnityMenuModel::changeStateByVariantString(int index, const QString& parameter) +{ + changeState(index, parseVariantString(parameter)); +} + void UnityMenuModel::changeState(int index, const QVariant& parameter) { GSequenceIter *it; diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h index 8816d22..826d5b2 100644 --- a/libqmenumodel/src/unitymenumodel.h +++ b/libqmenumodel/src/unitymenumodel.h @@ -63,7 +63,9 @@ public: Q_INVOKABLE QVariant get(int row, const QByteArray &role); Q_INVOKABLE void activate(int index, const QVariant& parameter = QVariant()); + Q_INVOKABLE void activateByVariantString(int index, const QString& parameter = QString()); Q_INVOKABLE void changeState(int index, const QVariant& parameter); + Q_INVOKABLE void changeStateByVariantString(int index, const QString& parameter = QString()); void registerAction(UnityMenuAction* action); void unregisterAction(UnityMenuAction* action); -- cgit v1.2.3 From 462b8422fd363d6ef3b6882459926a87ca389fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 14 Oct 2016 17:40:18 +0200 Subject: UnityMenuModel: avoid copying the string to a new std one --- libqmenumodel/src/unitymenumodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 6e9a5f7..a407ac1 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -725,7 +725,7 @@ static QVariant parseVariantString(const QString& string) return qvariant; } - gvariant = g_variant_parse (NULL, string.toStdString().c_str(), NULL, NULL, &error); + gvariant = g_variant_parse (NULL, string.toUtf8().data(), NULL, NULL, &error); if (error) { qWarning() << "Impossible to parse" << string << "as variant string:"<< error->message; -- cgit v1.2.3 From 33b75336e5148b7dcf6113dcfe59d58ee38f9481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 15 Oct 2016 02:04:05 +0200 Subject: UnityMenuModel: avoid initializing an empty QVariant if not needed --- libqmenumodel/src/unitymenumodel.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index a407ac1..4c238d8 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -717,12 +717,11 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) static QVariant parseVariantString(const QString& string) { - QVariant qvariant; GVariant *gvariant; GError *error = NULL; if (string.isEmpty()) { - return qvariant; + return QVariant(); } gvariant = g_variant_parse (NULL, string.toUtf8().data(), NULL, NULL, &error); @@ -730,10 +729,10 @@ static QVariant parseVariantString(const QString& string) if (error) { qWarning() << "Impossible to parse" << string << "as variant string:"<< error->message; g_error_free (error); - return qvariant; + return QVariant(); } - qvariant = Converter::toQVariant(gvariant); + const QVariant& qvariant = Converter::toQVariant(gvariant); g_variant_unref (gvariant); return qvariant; -- cgit v1.2.3 From 1adf4a6c1c9a978d1853612bf994f622599ea29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 11:44:04 +0200 Subject: Converter: move parseVariantString here from UnityMenuModel --- libqmenumodel/src/converter.cpp | 24 ++++++++++++++++++++++++ libqmenumodel/src/converter.h | 2 ++ libqmenumodel/src/unitymenumodel.cpp | 27 ++------------------------- 3 files changed, 28 insertions(+), 25 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 021fc82..527ae85 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -24,6 +24,7 @@ extern "C" { #include "converter.h" #include +#include #include /*! \internal */ @@ -137,6 +138,29 @@ static GVariant* toGVariant(const QString &typeName, const QVariant &value) return NULL; } +QVariant Converter::toQVariantFromVariantString(const QString &variantString) +{ + GVariant *gvariant; + GError *error = NULL; + + if (variantString.isEmpty()) { + return QVariant(); + } + + gvariant = g_variant_parse (NULL, variantString.toUtf8().data(), NULL, NULL, &error); + + if (error) { + qWarning() << "Impossible to parse" << variantString << "as variant string:"<< error->message; + g_error_free (error); + return QVariant(); + } + + const QVariant& qvariant = Converter::toQVariant(gvariant); + g_variant_unref (gvariant); + + return qvariant; +} + GVariant* Converter::toGVariant(const QVariant &value) { GVariant *result = NULL; diff --git a/libqmenumodel/src/converter.h b/libqmenumodel/src/converter.h index f47c09e..27cdcae 100644 --- a/libqmenumodel/src/converter.h +++ b/libqmenumodel/src/converter.h @@ -21,12 +21,14 @@ #define CONVERTER_H typedef struct _GVariant GVariant; +class QString; class QVariant; class Converter { public: static QVariant toQVariant(GVariant *value); + static QVariant toQVariantFromVariantString(const QString &variantString); static GVariant* toGVariant(const QVariant &value); // This converts a QVariant to a GVariant using a provided gvariant schema as diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 4c238d8..5e8c8e3 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -715,37 +715,14 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) } } -static QVariant parseVariantString(const QString& string) -{ - GVariant *gvariant; - GError *error = NULL; - - if (string.isEmpty()) { - return QVariant(); - } - - gvariant = g_variant_parse (NULL, string.toUtf8().data(), NULL, NULL, &error); - - if (error) { - qWarning() << "Impossible to parse" << string << "as variant string:"<< error->message; - g_error_free (error); - return QVariant(); - } - - const QVariant& qvariant = Converter::toQVariant(gvariant); - g_variant_unref (gvariant); - - return qvariant; -} - void UnityMenuModel::activateByVariantString(int index, const QString& parameter) { - activate(index, parseVariantString(parameter)); + activate(index, Converter::toQVariantFromVariantString(parameter)); } void UnityMenuModel::changeStateByVariantString(int index, const QString& parameter) { - changeState(index, parseVariantString(parameter)); + changeState(index, Converter::toQVariantFromVariantString(parameter)); } void UnityMenuModel::changeState(int index, const QVariant& parameter) -- cgit v1.2.3 From 06687a7f140678f26d9394b4f0b5a4a41aaab63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 11:55:14 +0200 Subject: QStateAction: add ability to activate or change state by variant string --- libqmenumodel/src/qstateaction.cpp | 20 ++++++++++++++++++++ libqmenumodel/src/qstateaction.h | 2 ++ libqmenumodel/src/unitymenumodel.h | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/qstateaction.cpp b/libqmenumodel/src/qstateaction.cpp index 983064a..fcffa44 100644 --- a/libqmenumodel/src/qstateaction.cpp +++ b/libqmenumodel/src/qstateaction.cpp @@ -19,6 +19,7 @@ #include "qstateaction.h" +#include "converter.h" #include "qdbusactiongroup.h" /*! @@ -98,6 +99,15 @@ void QStateAction::updateState(const QVariant &state) m_group->updateActionState(m_name, v); } +/*! + Request for the state of action to be changed to \a paramenter. + This call merely requests a change. The action may refuse to change its state or may change its state to something other than \a paramenter. +*/ +void QStateAction::updateStateByVariantString(const QString &state) +{ + updateState(Converter::toQVariantFromVariantString(state)); +} + /*! Activates the action passing \a parameter. \a parameter must be the correct type of parameter for the action @@ -107,6 +117,16 @@ void QStateAction::activate(const QVariant ¶meter) m_group->activateAction(m_name, parameter); } +/*! + Activates the action passing \a parameter using GLib Variant String format. + \a parameter must be the correct type of parameter for the action +*/ +void QStateAction::activateByVariantString(const QString ¶meter) +{ + activate(Converter::toQVariantFromVariantString(parameter)); +} + + /*! \internal */ QString QStateAction::name() const { diff --git a/libqmenumodel/src/qstateaction.h b/libqmenumodel/src/qstateaction.h index 0fc68c2..4d05a7a 100644 --- a/libqmenumodel/src/qstateaction.h +++ b/libqmenumodel/src/qstateaction.h @@ -36,7 +36,9 @@ public: bool isValid() const; Q_INVOKABLE void activate(const QVariant ¶meter = QVariant()); + Q_INVOKABLE void activateByVariantString(const QString ¶meter = QString()); Q_INVOKABLE void updateState(const QVariant ¶meter); + Q_INVOKABLE void updateStateByVariantString(const QString ¶meter); Q_SIGNALS: void stateChanged(QVariant state); diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h index 826d5b2..ed3bcd7 100644 --- a/libqmenumodel/src/unitymenumodel.h +++ b/libqmenumodel/src/unitymenumodel.h @@ -65,7 +65,7 @@ public: Q_INVOKABLE void activate(int index, const QVariant& parameter = QVariant()); Q_INVOKABLE void activateByVariantString(int index, const QString& parameter = QString()); Q_INVOKABLE void changeState(int index, const QVariant& parameter); - Q_INVOKABLE void changeStateByVariantString(int index, const QString& parameter = QString()); + Q_INVOKABLE void changeStateByVariantString(int index, const QString& parameter); void registerAction(UnityMenuAction* action); void unregisterAction(UnityMenuAction* action); -- cgit v1.2.3 From e87701e0f2d5f3b7dd291c7b8c62e407b5abf4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 12:53:27 +0200 Subject: Converter: add bytestring support --- libqmenumodel/src/converter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 527ae85..91cafab 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -58,6 +58,11 @@ QVariant Converter::toQVariant(GVariant *value) gsize size = 0; const gchar *v = g_variant_get_string(value, &size); result.setValue(QString::fromUtf8(v, size)); + } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING)) { + gsize size = 0; + gchar *bs = g_variant_dup_bytestring(value, &size); + result.setValue(QByteArray::fromRawData(bs, size)); + g_free(bs); } else if (g_variant_type_equal(type, G_VARIANT_TYPE_VARIANT)) { GVariant *var = g_variant_get_variant(value); result = toQVariant(var); @@ -111,7 +116,6 @@ QVariant Converter::toQVariant(GVariant *value) * G_VARIANT_TYPE_DICT_ENTRY * G_VARIANT_TYPE_DICTIONARY * G_VARIANT_TYPE_STRING_ARRAY - * G_VARIANT_TYPE_BYTESTRING * G_VARIANT_TYPE_OBJECT_PATH_ARRAY * G_VARIANT_TYPE_BYTESTRING_ARRAY */ -- cgit v1.2.3 From c42bc210a32f06b2850fbe010be9356d477330b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 15:39:20 +0200 Subject: Converter: add support for ByteArrayList --- libqmenumodel/src/converter.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 91cafab..9fd65ed 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -63,6 +63,15 @@ QVariant Converter::toQVariant(GVariant *value) gchar *bs = g_variant_dup_bytestring(value, &size); result.setValue(QByteArray::fromRawData(bs, size)); g_free(bs); + } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING_ARRAY)) { + gsize size = 0; + const gchar **bsa = g_variant_get_bytestring_array(value, &size); + QByteArrayList list; + for (gsize i = 0; i < size; ++i) { + list << bsa[i]; + } + result.setValue(list); + g_free(bsa); } else if (g_variant_type_equal(type, G_VARIANT_TYPE_VARIANT)) { GVariant *var = g_variant_get_variant(value); result = toQVariant(var); @@ -117,7 +126,6 @@ QVariant Converter::toQVariant(GVariant *value) * G_VARIANT_TYPE_DICTIONARY * G_VARIANT_TYPE_STRING_ARRAY * G_VARIANT_TYPE_OBJECT_PATH_ARRAY - * G_VARIANT_TYPE_BYTESTRING_ARRAY */ return result; @@ -211,6 +219,18 @@ GVariant* Converter::toGVariant(const QVariant &value) g_variant_builder_unref(b); break; } + case QMetaType::QByteArrayList: + { + const QByteArrayList &list = qvariant_cast(value); + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_BYTESTRING_ARRAY); + + for (const QByteArray &ba : list) { + g_variant_builder_add_value(b, g_variant_new_bytestring(ba)); + } + result = g_variant_builder_end(b); + g_variant_builder_unref(b); + break; + } case QVariant::List: { QVariantList lst = value.toList(); -- cgit v1.2.3 From 36681ba81d33e3c1e66bef49450f4e7008154b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 15:50:17 +0200 Subject: Converter: use QMetaType to check integer subtypes --- libqmenumodel/src/converter.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 9fd65ed..9f89662 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -131,25 +131,6 @@ QVariant Converter::toQVariant(GVariant *value) return result; } -static GVariant* toGVariant(const QString &typeName, const QVariant &value) -{ - if (typeName == "uchar") { - return g_variant_new_byte(value.value()); - } else if (typeName == "short") { - return g_variant_new_int16(value.value()); - } else if (typeName == "ushort") { - return g_variant_new_uint16(value.value()); - } else if (typeName == "long") { - return g_variant_new_int64(value.value()); - } else if (typeName == "ulong") { - return g_variant_new_uint64(value.value()); - } else { - qWarning() << "QVariant type not supported:" << typeName; - } - - return NULL; -} - QVariant Converter::toQVariantFromVariantString(const QString &variantString) { GVariant *gvariant; @@ -204,6 +185,21 @@ GVariant* Converter::toGVariant(const QVariant &value) case QVariant::ULongLong: result = g_variant_new_uint64(value.toULongLong()); break; + case QMetaType::UChar: + result = g_variant_new_byte(value.value()); + break; + case QMetaType::Short: + result = g_variant_new_int16(value.value()); + break; + case QMetaType::UShort: + result = g_variant_new_uint16(value.value()); + break; + case QMetaType::Long: + result = g_variant_new_int64(value.value()); + break; + case QMetaType::ULong: + result = g_variant_new_uint64(value.value()); + break; case QVariant::Map: { GVariantBuilder *b; @@ -243,7 +239,7 @@ GVariant* Converter::toGVariant(const QVariant &value) break; } default: - result = ::toGVariant(value.typeName(), value); + qWarning() << "QVariant type not supported:" << value.type(); } return result; -- cgit v1.2.3 From 3bd198ee6bdaec2fefff032098b2442b0160c961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 16:48:00 +0200 Subject: Converter: use some c++11 facilities for lists --- libqmenumodel/src/converter.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 9f89662..3131d4f 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -229,13 +229,13 @@ GVariant* Converter::toGVariant(const QVariant &value) } case QVariant::List: { - QVariantList lst = value.toList(); - GVariant **vars = g_new(GVariant*, lst.size()); - for (int i=0; i < lst.size(); i++) { - vars[i] = toGVariant(lst[i]); + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_TUPLE); + + for (const QVariant &v : value.toList()) { + g_variant_builder_add_value(b, toGVariant(v)); } - result = g_variant_new_tuple(vars, lst.size()); - g_free(vars); + result = g_variant_builder_end(b); + g_variant_builder_unref(b); break; } default: @@ -307,14 +307,14 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch const GVariantType* entry_type; GVariant* data; entry_type = g_variant_type_element(schema_type); - gchar* entryTypeString = g_variant_type_dup_string(entry_type); + const gchar* entryTypeString = g_variant_type_peek_string(entry_type); - QVariantList lst = value.toList(); + const QVariantList &lst = value.toList(); GVariant **vars = g_new(GVariant*, lst.size()); bool ok = true; - for (int i=0; i < lst.size(); i++) { - data = Converter::toGVariantWithSchema(lst[i], entryTypeString); + for (int i=0, iMax=lst.size(); i < iMax; i++) { + data = Converter::toGVariantWithSchema(lst.at(i), entryTypeString); if (data) { vars[i] = data; @@ -328,7 +328,6 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch if (ok) { result = g_variant_new_array(entry_type, vars, lst.size()); } - g_free(entryTypeString); g_free(vars); } } else if (g_variant_type_is_tuple(schema_type)) { @@ -341,11 +340,11 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch const GVariantType* entry_type = g_variant_type_first(schema_type); bool ok = true; - for (int i=0; i < lst.size(); i++) { + for (int i=0,iMax=lst.size(); i < iMax; i++) { gchar* entryTypeString = g_variant_type_dup_string(entry_type); - data = Converter::toGVariantWithSchema(lst[i], entryTypeString); + data = Converter::toGVariantWithSchema(lst.at(i), entryTypeString); if (data) { vars[i] = data; -- cgit v1.2.3 From 3def677b32e7cf1916de2cdf6be01a7a0cc43d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 17:27:13 +0200 Subject: Converter: use builders and c++ facilities for schema conversions --- libqmenumodel/src/converter.cpp | 60 +++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 38 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 3131d4f..aef34d0 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -303,69 +303,53 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch } } else if (g_variant_type_is_array(schema_type)) { if (value.canConvert(QVariant::List)) { + const GVariantType* entryType = g_variant_type_element(schema_type); + const gchar* entryTypeString = g_variant_type_peek_string(entryType); - const GVariantType* entry_type; - GVariant* data; - entry_type = g_variant_type_element(schema_type); - const gchar* entryTypeString = g_variant_type_peek_string(entry_type); - - const QVariantList &lst = value.toList(); - GVariant **vars = g_new(GVariant*, lst.size()); - + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_ARRAY); bool ok = true; - for (int i=0, iMax=lst.size(); i < iMax; i++) { - data = Converter::toGVariantWithSchema(lst.at(i), entryTypeString); + + for (const QVariant &v : value.toList()) { + GVariant *data = toGVariantWithSchema(v, entryTypeString); if (data) { - vars[i] = data; - } - else { + g_variant_builder_add_value(b, data); + } else { ok = false; qWarning() << "Failed to convert list to array with schema:" << schema; break; } } if (ok) { - result = g_variant_new_array(entry_type, vars, lst.size()); + result = g_variant_builder_end(b); } - g_free(vars); + g_variant_builder_unref(b); } } else if (g_variant_type_is_tuple(schema_type)) { if (value.canConvert(QVariant::List)) { - GVariant* data; - - QVariantList lst = value.toList(); - GVariant **vars = g_new(GVariant*, lst.size()); - - const GVariantType* entry_type = g_variant_type_first(schema_type); + const GVariantType* entryType = g_variant_type_first(schema_type); + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_TUPLE); bool ok = true; - for (int i=0,iMax=lst.size(); i < iMax; i++) { - - gchar* entryTypeString = g_variant_type_dup_string(entry_type); - data = Converter::toGVariantWithSchema(lst.at(i), entryTypeString); + for (const QVariant &v : value.toList()) { + gchar* entryTypeString = g_variant_type_dup_string(entryType); + GVariant *data = toGVariantWithSchema(v, entryTypeString); + g_free(entryTypeString); if (data) { - vars[i] = data; - } - else { + g_variant_builder_add_value(b, data); + entryType = g_variant_type_next(entryType); + } else { ok = false; - qWarning() << "Failed to convert list to tuple with schema:" << schema; - g_free(entryTypeString); - break; - } - g_free(entryTypeString); - - entry_type = g_variant_type_next(entry_type); - if (!entry_type) { + qWarning() << "Failed to convert list to array with schema:" << schema; break; } } if (ok) { - result = g_variant_new_tuple(vars, lst.size()); + result = g_variant_builder_end(b); } - g_free(vars); + g_variant_builder_unref(b); } } -- cgit v1.2.3 From 901e9dcbf13b658545d5bc1e2d96ccac2ed61111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 17:34:52 +0200 Subject: converter: stop looking if w'eve no entryType --- libqmenumodel/src/converter.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index aef34d0..1b63272 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -340,6 +340,8 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch if (data) { g_variant_builder_add_value(b, data); entryType = g_variant_type_next(entryType); + if (!entryType) + break; } else { ok = false; qWarning() << "Failed to convert list to array with schema:" << schema; -- cgit v1.2.3 From 3d2c260f804273e5a65f27a379f4ad74407ee921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 22 Oct 2016 19:00:49 +0200 Subject: remove deprecated g_type_init() calls --- libqmenumodel/src/qdbusobject.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/qdbusobject.cpp b/libqmenumodel/src/qdbusobject.cpp index be9fb93..fab2df7 100644 --- a/libqmenumodel/src/qdbusobject.cpp +++ b/libqmenumodel/src/qdbusobject.cpp @@ -81,7 +81,6 @@ QDBusObject::QDBusObject(QObject* listener) m_busType(DBusEnums::None), m_status(DBusEnums::Disconnected) { - g_type_init(); qRegisterMetaType("DBusEnums::ConnectionStatus"); } -- cgit v1.2.3 From 6d2076c889b4d914672e2bbfd1c218252b9ed1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 16:50:59 +0200 Subject: Converter: add support to String Arrays --- libqmenumodel/src/converter.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 1b63272..e2a31c0 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Canonical Ltd. + * Copyright 2012-2016 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -15,6 +15,7 @@ * * Authors: * Renato Araujo Oliveira Filho + * Marco Trevisan */ extern "C" { @@ -58,6 +59,14 @@ QVariant Converter::toQVariant(GVariant *value) gsize size = 0; const gchar *v = g_variant_get_string(value, &size); result.setValue(QString::fromUtf8(v, size)); + } else if (g_variant_type_equal(type, G_VARIANT_TYPE_STRING_ARRAY)) { + gsize size = 0; + const gchar **sa = g_variant_get_strv(value, &size); + QStringList list; + for (gsize i = 0; i < size; ++i) { + list << QString::fromUtf8(sa[i]); + } + result.setValue(list); } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING)) { gsize size = 0; gchar *bs = g_variant_dup_bytestring(value, &size); @@ -124,7 +133,6 @@ QVariant Converter::toQVariant(GVariant *value) * G_VARIANT_TYPE_UNIT * G_VARIANT_TYPE_DICT_ENTRY * G_VARIANT_TYPE_DICTIONARY - * G_VARIANT_TYPE_STRING_ARRAY * G_VARIANT_TYPE_OBJECT_PATH_ARRAY */ @@ -238,6 +246,17 @@ GVariant* Converter::toGVariant(const QVariant &value) g_variant_builder_unref(b); break; } + case QVariant::StringList: + { + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_STRING_ARRAY); + + for (const QString &s : value.toStringList()) { + g_variant_builder_add(b, "s", s.toUtf8().data()); + } + result = g_variant_builder_end(b); + g_variant_builder_unref(b); + break; + } default: qWarning() << "QVariant type not supported:" << value.type(); } -- cgit v1.2.3 From 307efb494989e3be1086731dc591c886d5f57583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 19:57:38 +0200 Subject: UnityMenuModel: use conversion with gschema in unity actions --- libqmenumodel/src/unitymenumodel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 5e8c8e3..695d053 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -692,6 +692,8 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) { GSequenceIter *it; GtkMenuTrackerItem *item; + GVariant *value; + const GVariantType *parameter_type; it = g_sequence_get_iter_at_pos (priv->items, index); if (g_sequence_iter_is_end (it)) { @@ -707,7 +709,9 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) gchar *action; action = gtk_menu_tracker_item_get_action_name (item); - g_action_group_activate_action (G_ACTION_GROUP (priv->muxer), action, Converter::toGVariant(parameter)); + parameter_type = g_action_group_get_action_parameter_type (G_ACTION_GROUP (priv->muxer), action); + value = Converter::toGVariantWithSchema(parameter, g_variant_type_peek_string (parameter_type)); + g_action_group_activate_action (G_ACTION_GROUP (priv->muxer), action, value); g_free (action); } else { -- cgit v1.2.3 From 0d1bfd69b848b2c86b48a3de198bc7dad9c96441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 20:01:23 +0200 Subject: UnityMenuModel: avoid copy on assignment --- libqmenumodel/src/unitymenumodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 695d053..aac1d92 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -661,7 +661,7 @@ bool UnityMenuModel::loadExtendedAttributes(int position, const QVariantMap &sch continue; } - QVariant qvalue = attributeToQVariant(value, type); + const QVariant &qvalue = attributeToQVariant(value, type); if (qvalue.isValid()) extendedAttrs->insert(qtify_name (name.toUtf8()), qvalue); else -- cgit v1.2.3 From 64ac22dc0d80ab3d44fe0fa08cbc517a5bc6b1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Tue, 25 Oct 2016 20:23:06 +0200 Subject: converter: use qUtf8Printable function --- libqmenumodel/src/converter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index e2a31c0..a7c3adf 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -148,7 +148,7 @@ QVariant Converter::toQVariantFromVariantString(const QString &variantString) return QVariant(); } - gvariant = g_variant_parse (NULL, variantString.toUtf8().data(), NULL, NULL, &error); + gvariant = g_variant_parse (NULL, qUtf8Printable(variantString), NULL, NULL, &error); if (error) { qWarning() << "Impossible to parse" << variantString << "as variant string:"<< error->message; @@ -185,7 +185,7 @@ GVariant* Converter::toGVariant(const QVariant &value) result = g_variant_new_int64(value.toLongLong()); break; case QVariant::String: - result = g_variant_new_string(value.toString().toUtf8().data()); + result = g_variant_new_string(qUtf8Printable(value.toString())); break; case QVariant::UInt: result = g_variant_new_uint32(value.toUInt()); @@ -217,7 +217,7 @@ GVariant* Converter::toGVariant(const QVariant &value) QMapIterator i(value.toMap()); while (i.hasNext()) { i.next(); - g_variant_builder_add(b, "{sv}", i.key().toUtf8().data(), toGVariant(i.value())); + g_variant_builder_add(b, "{sv}", qUtf8Printable(i.key()), toGVariant(i.value())); } result = g_variant_builder_end(b); g_variant_builder_unref(b); @@ -251,7 +251,7 @@ GVariant* Converter::toGVariant(const QVariant &value) GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_STRING_ARRAY); for (const QString &s : value.toStringList()) { - g_variant_builder_add(b, "s", s.toUtf8().data()); + g_variant_builder_add(b, "s", qUtf8Printable(s)); } result = g_variant_builder_end(b); g_variant_builder_unref(b); @@ -312,7 +312,7 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch } } else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_STRING)) { if (value.canConvert()) { - result = g_variant_new_string(value.toString().toUtf8().data()); + result = g_variant_new_string(qUtf8Printable(value.toString())); } } else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_VARIANT)) { result = Converter::toGVariant(value); -- cgit v1.2.3 From edfe13a5191e0df28575a7847e8ce94ac29a3e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 20:29:53 +0200 Subject: converter: free the strv container --- libqmenumodel/src/converter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index a7c3adf..483e646 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -67,6 +67,7 @@ QVariant Converter::toQVariant(GVariant *value) list << QString::fromUtf8(sa[i]); } result.setValue(list); + g_free(sa); } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING)) { gsize size = 0; gchar *bs = g_variant_dup_bytestring(value, &size); -- cgit v1.2.3 From fc52f8461996abd0b4f66d59360e870581f19d97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 20:38:43 +0200 Subject: converter: free schema type on destruction --- libqmenumodel/src/converter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index 483e646..cbf8076 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -272,8 +272,7 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch } GVariant* result = NULL; - const GVariantType* schema_type; - schema_type = g_variant_type_new(schema); + GVariantType* schema_type = g_variant_type_new(schema); if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_BOOLEAN)) { if (value.canConvert()) { @@ -379,6 +378,9 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch if (!result) { result = Converter::toGVariant(value); } + + g_free(schema_type); + return result; } -- cgit v1.2.3 From d56d0baefd53a8c7f3a9cd10fcaaeef1826e7d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 20:56:40 +0200 Subject: converter: return a variant when the schema is a variant --- libqmenumodel/src/converter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index cbf8076..ff70803 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -315,7 +315,7 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch result = g_variant_new_string(qUtf8Printable(value.toString())); } } else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_VARIANT)) { - result = Converter::toGVariant(value); + result = g_variant_new_variant(Converter::toGVariant(value)); } else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_VARDICT)) { if (value.canConvert(QVariant::Map)) { result = Converter::toGVariant(value.toMap()); -- cgit v1.2.3 From 210cae9ff99fc5bbb206b904c8c7bfa2736f503f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 26 Oct 2016 14:29:33 +0200 Subject: converter: properly set the QByteArray using ctor, or it will be created twice --- libqmenumodel/src/converter.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'libqmenumodel') diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp index ff70803..459e77f 100644 --- a/libqmenumodel/src/converter.cpp +++ b/libqmenumodel/src/converter.cpp @@ -69,10 +69,7 @@ QVariant Converter::toQVariant(GVariant *value) result.setValue(list); g_free(sa); } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING)) { - gsize size = 0; - gchar *bs = g_variant_dup_bytestring(value, &size); - result.setValue(QByteArray::fromRawData(bs, size)); - g_free(bs); + result.setValue(QByteArray(g_variant_get_bytestring(value))); } else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTESTRING_ARRAY)) { gsize size = 0; const gchar **bsa = g_variant_get_bytestring_array(value, &size); -- cgit v1.2.3