diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-01-13 15:58:29 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-01-18 19:06:32 +0100 |
commit | 14fe15e3fc2b4c3013806047d202b3ca6beed259 (patch) | |
tree | c2f81105090b0a274ebecfd12fa1e5057477577f /platform/qt/src | |
parent | 49da57393a5c5ddff1a7f60620c38858643b1220 (diff) | |
download | qtlocation-mapboxgl-14fe15e3fc2b4c3013806047d202b3ca6beed259.tar.gz |
[Qt] Avoid QApplication duplication via test main()
Diffstat (limited to 'platform/qt/src')
-rw-r--r-- | platform/qt/src/run_loop.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/platform/qt/src/run_loop.cpp b/platform/qt/src/run_loop.cpp index 1c199be9de..c44f284852 100644 --- a/platform/qt/src/run_loop.cpp +++ b/platform/qt/src/run_loop.cpp @@ -31,22 +31,6 @@ RunLoop* RunLoop::Get() { } RunLoop::RunLoop(Type type) : impl(std::make_unique<Impl>()) { - // XXX: We should probably throw an runtime exception - // here instead of creating a QCoreApplication which is - // way too intrusive. This is a hack mostly for the unit - // tests to work, as you always need a QCoreApplication - // prior to run a Qt app. - if (!QCoreApplication::instance()) { - static const char* argv[] = { "mbgl" }; - static int argc = 1; - - // We need to keep this around because it would otherwise crash - // on Qt4 due to a bug on QNetworkConfigurationManager when recreating - // a QCoreApplication: https://bugreports.qt.io/browse/QTBUG-36897 - static auto* app = new QCoreApplication(argc, const_cast<char**>(argv)); - Q_UNUSED(app); - } - switch (type) { case Type::New: impl->loop = std::make_unique<QEventLoop>(); @@ -80,6 +64,7 @@ void RunLoop::push(std::shared_ptr<WorkTask> task) { } void RunLoop::run() { + assert(QCoreApplication::instance()); MBGL_VERIFY_THREAD(tid); if (impl->type == Type::Default) { @@ -90,6 +75,7 @@ void RunLoop::run() { } void RunLoop::stop() { + assert(QCoreApplication::instance()); invoke([&] { if (impl->type == Type::Default) { QCoreApplication::instance()->exit(); @@ -100,6 +86,7 @@ void RunLoop::stop() { } void RunLoop::runOnce() { + assert(QCoreApplication::instance()); MBGL_VERIFY_THREAD(tid); if (impl->type == Type::Default) { |