diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-03-21 12:45:29 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-03-21 12:45:29 +0900 |
commit | 9af8b122516867c47dfdc7293b19eecd6f4f4eab (patch) | |
tree | 8a52296ab58bac7d9bb812e9ce1fc3d030cb9569 /examples/qmc-example.cpp | |
parent | 567d75fd47b185e6906f34b7c4aef0952b5c2f50 (diff) | |
download | libquotient-9af8b122516867c47dfdc7293b19eecd6f4f4eab.tar.gz libquotient-9af8b122516867c47dfdc7293b19eecd6f4f4eab.zip |
Fixed to work with older MinGW
At least MinGW 4.8 (bundled with Qt 5.2.1 for Windows) crashes with internal error on lambdas-in-lambdas.
Diffstat (limited to 'examples/qmc-example.cpp')
-rw-r--r-- | examples/qmc-example.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index 36446255..7b45a785 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -4,12 +4,29 @@ #include "connection.h" #include "room.h" -int main(int argc, char* argv[]) +using namespace QMatrixClient; +using std::cout; +using std::endl; + +void onNewRoom(Room* r) { - using namespace QMatrixClient; - using std::cout; - using std::endl; + cout << "New room: " << r->id().toStdString() << endl; + QObject::connect(r, &Room::namesChanged, [=] { + cout << "Room " << r->id().toStdString() << ", name(s) changed:" << endl; + cout << " Name: " << r->name().toStdString() << endl; + cout << " Canonical alias: " << r->canonicalAlias().toStdString() << endl; + }); + QObject::connect(r, &Room::aboutToAddNewMessages, [=] (Events evs) { + cout << "New events in room " << r->id().toStdString() << ":" << endl; + for (auto e: evs) + { + cout << e->originalJson().toStdString() << endl; + } + }); +} +int main(int argc, char* argv[]) +{ QCoreApplication app(argc, argv); if (argc < 2) return -1; @@ -24,20 +41,6 @@ int main(int argc, char* argv[]) cout << "Sync done" << endl; conn->sync(30000); }); - QObject::connect(conn, &Connection::newRoom, [=] (Room* r) { - cout << "New room: " << r->id().toStdString() << endl; - QObject::connect(r, &Room::namesChanged, [=] { - cout << "Room " << r->id().toStdString() << ", name(s) changed:" << endl; - cout << " Name: " << r->name().toStdString() << endl; - cout << " Canonical alias: " << r->canonicalAlias().toStdString() << endl; - }); - QObject::connect(r, &Room::aboutToAddNewMessages, [=] (Events evs) { - cout << "New events in room " << r->id().toStdString() << ":" << endl; - for (auto e: evs) - { - cout << e->originalJson().toStdString() << endl; - } - }); - }); + QObject::connect(conn, &Connection::newRoom, onNewRoom); return app.exec(); } |