Blackberry10 | netstatus_interface_get_type:type为NULL

时间:2014-03-15 15:29:06

标签: c++ networking blackberry-10 http-get qtnetwork

我的HTTP请求有问题

request.hpp

#ifndef PROGRAMMEREQUEST_HPP_
#define PROGRAMMEREQUEST_HPP_

#include <QObject>

class RequestHTTP : public QObject
{
    Q_OBJECT

public:
    RequestHTTP();
    virtual ~RequestHTTP() {}
    void sendRequest(QUrl url, QObject *target, const QString signature);

private:
    QString callbackMethodName;
    QObject *callbackObject;

private slots:
    void onRequestFinished();

};

#endif

request.cpp

#include "request.hpp"

#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>

#include <QBuffer>
#include <QIODevice>

#include <QMetaMethod>

RequestHTTP::RequestHTTP() : callbackObject(NULL) { }

void RequestHTTP::sendRequest(QUrl url, QObject *target, const QString signature)
{
    this->callbackObject = target;
    this->callbackMethodName = signature;

    QNetworkRequest request = QNetworkRequest();
    request.setUrl(url);

    QNetworkAccessManager *pNetworkAccessManager = new QNetworkAccessManager(this);
    QNetworkReply* reply = pNetworkAccessManager->get(request);

    bool result = connect(reply, SIGNAL(finished()), this, SLOT(onRequestFinished()));

    Q_UNUSED(result);
    Q_ASSERT(result);
}

void RequestHTTP::onRequestFinished()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());

    if (reply && reply->error() == QNetworkReply::NoError)
    {
        QBuffer device;
        device.setData(reply->readAll());
        device.open(QIODevice::ReadOnly);

        QByteArray normalizedSignature = QMetaObject::normalizedSignature(callbackMethodName);

        int methodIndex = callbackObject->metaObject()->indexOfMethod(normalizedSignature);

        QMetaMethod method = callbackObject->metaObject()->method(methodIndex);
        method.invoke(callbackObject,
                       Qt::DirectConnection, Q_ARG(QBuffer *, &device));
    }
    else
    {
        // Problem with the reply.
        // ...
    }

    reply->deleteLater();
}

当我表演时

QUrl url("http://www.example-xml-ws.org");
RequestHTTP http;
http.sendRequest(url, this, "processData(QBuffer*)");

我在bool result = connect(reply, SIGNAL(finished()), this, SLOT(onRequestFinished()));

之后的日志中看到错误
  

Mar 15 17:20:55.032 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_type:type is NULL

     

3月15日17:20:55.032 org.example.testDev_xamplefmeb1c2e99.37572818默认8900错误netstatus_interface_get_ip_status:ip_ok为NULL

     

Mar 15 17:20:55.032 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_num_ip_addresses:num_ip_addresses为NULL

     

Mar 15 17:20:55.033 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_type:type is NULL

     

3月15日17:20:55.033 org.example.testDev_xamplefmeb1c2e99.37572818默认8900错误netstatus_interface_get_ip_status:ip_ok为NULL

     

Mar 15 17:20:55.033 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_num_ip_addresses:num_ip_addresses为NULL

     

Mar 15 17:20:55.034 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_type:type is NULL

     

3月15日17:20:55.034 org.example.testDev_xamplefmeb1c2e99.37572818默认8900错误netstatus_interface_get_ip_status:ip_ok为NULL

     

Mar 15 17:20:55.034 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_num_ip_addresses:num_ip_addresses为NULL

     

Mar 15 17:20:55.034 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_type:type is NULL

     

3月15日17:20:55.034 org.example.testDev_xamplefmeb1c2e99.37572818默认8900错误netstatus_interface_get_ip_status:ip_ok为NULL

     

Mar 15 17:20:55.034 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_num_ip_addresses:num_ip_addresses为NULL

     

Mar 15 17:20:55.036 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_type:type is NULL

     

3月15日17:20:55.036 org.example.testDev_xamplefmeb1c2e99.37572818默认8900错误netstatus_interface_get_ip_status:ip_ok为NULL

     

Mar 15 17:20:55.036 org.example.testDev_xamplefmeb1c2e99.37572818 default 8900 ERROR netstatus_interface_get_num_ip_addresses:num_ip_addresses为NULL

结果请求成功发送,但问题是为什么我看到这个输出?

0 个答案:

没有答案