fix some crashers
This commit is contained in:
parent
370df7d047
commit
3c3cb76bf8
@ -73,6 +73,7 @@ QVariant ActionTypes::data(const QModelIndex &index, int role) const
|
||||
|
||||
void ActionTypes::addActionType(ActionType *actionType)
|
||||
{
|
||||
actionType->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_actionTypes.count(), m_actionTypes.count());
|
||||
//qDebug() << "ActionTypes: loaded actionType" << actionType->name();
|
||||
m_actionTypes.append(actionType);
|
||||
|
||||
@ -74,6 +74,10 @@ ParamTypes *EventType::paramTypes() const
|
||||
|
||||
void EventType::setParamTypes(ParamTypes *paramTypes)
|
||||
{
|
||||
if (m_paramTypes && m_paramTypes->parent() == this) {
|
||||
m_paramTypes->deleteLater();
|
||||
}
|
||||
paramTypes->setParent(this);
|
||||
m_paramTypes = paramTypes;
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ private:
|
||||
QString m_name;
|
||||
QString m_displayName;
|
||||
int m_index;
|
||||
ParamTypes *m_paramTypes;
|
||||
ParamTypes *m_paramTypes = nullptr;
|
||||
};
|
||||
|
||||
#endif // EVENTTYPE_H
|
||||
|
||||
@ -71,6 +71,7 @@ QVariant EventTypes::data(const QModelIndex &index, int role) const
|
||||
|
||||
void EventTypes::addEventType(EventType *eventType)
|
||||
{
|
||||
eventType->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_eventTypes.count(), m_eventTypes.count());
|
||||
//qDebug() << "EventTypes: loaded eventType" << eventType->name();
|
||||
m_eventTypes.append(eventType);
|
||||
|
||||
@ -15,7 +15,7 @@ Interfaces::Interfaces(QObject *parent) : QAbstractListModel(parent)
|
||||
ParamType* pt = nullptr;
|
||||
ParamTypes *pts = nullptr;
|
||||
|
||||
iface = new Interface("battery", "Battery powered devices");
|
||||
iface = new Interface("battery", "Battery powered devices", this);
|
||||
et = new EventType();
|
||||
pts = new ParamTypes(et);
|
||||
et->setParamTypes(pts);
|
||||
@ -43,7 +43,7 @@ Interfaces::Interfaces(QObject *parent) : QAbstractListModel(parent)
|
||||
m_list.append(iface);
|
||||
|
||||
|
||||
iface = new Interface("notification", "Notification services");
|
||||
iface = new Interface("notification", "Notification services", this);
|
||||
at = new ActionType();
|
||||
pts = new ParamTypes(at);
|
||||
at->setParamTypes(pts);
|
||||
|
||||
@ -100,6 +100,7 @@ QVariant ParamTypes::data(const QModelIndex &index, int role) const
|
||||
|
||||
void ParamTypes::addParamType(ParamType *paramType)
|
||||
{
|
||||
paramType->setParent(this);
|
||||
beginInsertRows(QModelIndex(), m_paramTypes.count(), m_paramTypes.count());
|
||||
//qDebug() << "ParamTypes: loaded paramType" << paramType->name();
|
||||
m_paramTypes.append(paramType);
|
||||
|
||||
@ -44,7 +44,6 @@ QUuid State::stateTypeId() const
|
||||
|
||||
QVariant State::value() const
|
||||
{
|
||||
qDebug() << "returning value:" << m_value;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
@ -309,6 +309,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
||||
int commandId = dataMap.value("id").toInt();
|
||||
JsonRpcReply *reply = m_replies.take(commandId);
|
||||
if (reply) {
|
||||
reply->deleteLater();
|
||||
// qDebug() << QString("JsonRpc: got response for %1.%2: %3").arg(reply->nameSpace(), reply->method(), QString::fromUtf8(jsonDoc.toJson(QJsonDocument::Indented))) << reply->callback() << reply->callback();
|
||||
|
||||
if (dataMap.value("status").toString() == "unauthorized") {
|
||||
@ -322,7 +323,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
||||
emit authenticationRequiredChanged();
|
||||
}
|
||||
|
||||
if (reply->caller() != nullptr && !reply->callback().isEmpty()) {
|
||||
if (!reply->caller().isNull() && !reply->callback().isEmpty()) {
|
||||
QMetaObject::invokeMethod(reply->caller(), reply->callback().toLatin1().data(), Q_ARG(QVariantMap, dataMap));
|
||||
}
|
||||
|
||||
@ -346,8 +347,7 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
||||
}
|
||||
}
|
||||
|
||||
JsonRpcReply::JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params, QObject *caller, const QString &callback):
|
||||
QObject(caller),
|
||||
JsonRpcReply::JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params, QPointer<QObject> caller, const QString &callback):
|
||||
m_commandId(commandId),
|
||||
m_nameSpace(nameSpace),
|
||||
m_method(method),
|
||||
@ -357,6 +357,10 @@ JsonRpcReply::JsonRpcReply(int commandId, QString nameSpace, QString method, QVa
|
||||
{
|
||||
}
|
||||
|
||||
JsonRpcReply::~JsonRpcReply()
|
||||
{
|
||||
}
|
||||
|
||||
int JsonRpcReply::commandId() const
|
||||
{
|
||||
return m_commandId;
|
||||
@ -388,7 +392,7 @@ QVariantMap JsonRpcReply::requestMap()
|
||||
return request;
|
||||
}
|
||||
|
||||
QObject* JsonRpcReply::caller() const
|
||||
QPointer<QObject> JsonRpcReply::caller() const
|
||||
{
|
||||
return m_caller;
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
#include <QPointer>
|
||||
|
||||
#include "nymeaconnection.h"
|
||||
#include "jsonhandler.h"
|
||||
@ -115,7 +116,8 @@ class JsonRpcReply : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params = QVariantMap(), QObject *caller = 0, const QString &callback = QString());
|
||||
explicit JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params = QVariantMap(), QPointer<QObject> caller = QPointer<QObject>(), const QString &callback = QString());
|
||||
~JsonRpcReply();
|
||||
|
||||
int commandId() const;
|
||||
QString nameSpace() const;
|
||||
@ -123,7 +125,7 @@ public:
|
||||
QVariantMap params() const;
|
||||
QVariantMap requestMap();
|
||||
|
||||
QObject *caller() const;
|
||||
QPointer<QObject> caller() const;
|
||||
QString callback() const;
|
||||
|
||||
private:
|
||||
@ -132,7 +134,7 @@ private:
|
||||
QString m_method;
|
||||
QVariantMap m_params;
|
||||
|
||||
QObject *m_caller;
|
||||
QPointer<QObject> m_caller;
|
||||
QString m_callback;
|
||||
};
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ Item {
|
||||
|
||||
signal addRuleClicked(var value)
|
||||
|
||||
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
||||
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
||||
|
||||
LogsModel {
|
||||
id: logs
|
||||
|
||||
@ -15,106 +15,64 @@ CustomViewBase {
|
||||
}
|
||||
|
||||
property var playbackState: device.states.getState(deviceClass.stateTypes.findByName("playbackStatus").id)
|
||||
property var playbackStateValue: playbackState.value
|
||||
onPlaybackStateValueChanged: populateControls()
|
||||
Component.onCompleted: populateControls()
|
||||
|
||||
function populateControls() {
|
||||
print("generating controls")
|
||||
controlsModel.clear();
|
||||
controlsModel.append({image: "../images/media-skip-backward.svg", action: "skipBack"})
|
||||
controlsModel.append({image: "../images/media-seek-backward.svg", action: "rewind"})
|
||||
controlsModel.append({image: "../images/media-playback-stop.svg", action: "stop"})
|
||||
if (playbackState.value === "PAUSED" || playbackState.value === "STOPPED") {
|
||||
controlsModel.append({image: "../images/media-playback-start.svg", action: "play"})
|
||||
}
|
||||
if (playbackState.value === "PLAYING") {
|
||||
controlsModel.append({image: "../images/media-playback-pause.svg", action: "pause"})
|
||||
}
|
||||
|
||||
controlsModel.append({image: "../images/media-seek-forward.svg", action: "fastForward"})
|
||||
controlsModel.append({image: "../images/media-skip-forward.svg", action: "skipNext"})
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: column
|
||||
anchors { left: parent.left; right: parent.right }
|
||||
|
||||
RowLayout {
|
||||
Row {
|
||||
id: controlsRow
|
||||
Layout.fillWidth: true
|
||||
|
||||
Item { Layout.fillWidth: true; height: 1 }
|
||||
property int iconSize: Math.max(app.iconSize * 2, column.width / (controlsModel.count + 0))
|
||||
|
||||
property int iconSize: Math.min(root.width / 6, app.iconSize * 2)
|
||||
// Item {
|
||||
// width: Math.max(app.iconSize * 2, column.width / (controlsModel.count + 2))
|
||||
// height: 1
|
||||
// }
|
||||
|
||||
AbstractButton {
|
||||
Layout.fillWidth: true
|
||||
height: Math.min(app.iconSize * 2)
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: "../images/media-skip-backward.svg"
|
||||
|
||||
Repeater {
|
||||
model: ListModel {
|
||||
id: controlsModel
|
||||
}
|
||||
onClicked: {
|
||||
executeAction("skipBack")
|
||||
}
|
||||
}
|
||||
AbstractButton {
|
||||
Layout.fillWidth: true
|
||||
height: Math.min(app.iconSize * 2)
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: "../images/media-seek-backward.svg"
|
||||
}
|
||||
onClicked: {
|
||||
executeAction("rewind")
|
||||
}
|
||||
}
|
||||
AbstractButton {
|
||||
Layout.fillWidth: true
|
||||
height: Math.min(app.iconSize * 2)
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: "../images/media-playback-stop.svg"
|
||||
}
|
||||
onClicked: {
|
||||
executeAction("stop")
|
||||
}
|
||||
}
|
||||
AbstractButton {
|
||||
Layout.fillWidth: true
|
||||
height: Math.min(app.iconSize * 2)
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: "../images/media-playback-start.svg"
|
||||
}
|
||||
visible: playbackState.value == "PAUSED" || playbackState.value == "STOPPED"
|
||||
onClicked: {
|
||||
executeAction("play")
|
||||
}
|
||||
}
|
||||
AbstractButton {
|
||||
Layout.fillWidth: true
|
||||
height: Math.min(app.iconSize * 2)
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: "../images/media-playback-pause.svg"
|
||||
}
|
||||
visible: playbackState.value == "PLAYING"
|
||||
onClicked: {
|
||||
executeAction("pause")
|
||||
delegate: AbstractButton {
|
||||
|
||||
height: app.iconSize * 2
|
||||
width: controlsRow.iconSize
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: model.image
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
onClicked: {
|
||||
executeAction(model.action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AbstractButton {
|
||||
Layout.fillWidth: true
|
||||
height: Math.min(app.iconSize * 2)
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: "../images/media-seek-forward.svg"
|
||||
}
|
||||
onClicked: {
|
||||
executeAction("fastForward")
|
||||
}
|
||||
}
|
||||
AbstractButton {
|
||||
Layout.fillWidth: true
|
||||
height: Math.min(app.iconSize * 2)
|
||||
ColorIcon {
|
||||
height: parent.height
|
||||
width: height
|
||||
name: "../images/media-skip-forward.svg"
|
||||
}
|
||||
onClicked: {
|
||||
executeAction("skipNext")
|
||||
}
|
||||
}
|
||||
Item { Layout.fillWidth: true; height: 1 }
|
||||
// Item { Layout.fillWidth: true; height: 1 }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user