~unity-team/unity-scopes-api/trunk

« back to all changes in this revision

Viewing changes to src/scopes/internal/smartscopes/HttpClientQt.cpp

  • Committer: Tarmac
  • Author(s): Marcus Tomlinson
  • Date: 2014-01-22 12:19:43 UTC
  • mfrom: (125.3.13 lp-1267917)
  • Revision ID: tarmac-20140122121943-hxd60wyixyuv7i9e
Ensure that manager_ and reply_ objects are created and destroyed from within the same Qt thread. Fixes: https://bugs.launchpad.net/bugs/1267917.

Approved by PS Jenkins bot, Michal Hruby.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
 
105
105
        get_qt_thread_->start();
106
106
        loop.exec();
107
 
        get_qt_thread_->wait();
108
 
 
109
 
        QNetworkReply* reply = get_qt_thread_->getReply();
110
 
 
111
 
        if (!reply)
112
 
        {
113
 
            // no reply
114
 
            unity::ResourceException e("No reply from " + request_url + ":" + std::to_string(port));
115
 
            promise_->set_exception(e.self());
116
 
        }
117
 
        else if (!reply->isFinished())
118
 
        {
119
 
            // incomplete reply
120
 
            unity::ResourceException e("Incomplete reply from " + request_url + ":" + std::to_string(port));
121
 
            promise_->set_exception(e.self());
122
 
        }
123
 
        else if (reply->error() != QNetworkReply::NoError)
124
 
        {
125
 
            // communication error
126
 
            unity::ResourceException e(reply->errorString().toStdString());
 
107
 
 
108
        std::string reply;
 
109
        bool success = get_qt_thread_->get_reply(reply);
 
110
 
 
111
        if (!success)
 
112
        {
 
113
            unity::ResourceException e(reply);
127
114
            promise_->set_exception(e.self());
128
115
        }
129
116
        else
130
117
        {
131
 
            QString reply_string(reply->readAll());
132
 
            promise_->set_value(reply_string.toStdString());
 
118
            promise_->set_value(reply);
133
119
        }
134
120
    });
135
121