mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-04 16:22:52 +08:00
[AFV] Fix context UNIT test crash
* crash: A crash occurred in C:\jenkins\workspace\swift_wip_fsd_and_afv_client\build\out\release\bin\testcontext.exe. * ASSERT in const QList<QAudioDeviceInfo> allQtDevices2 = QAudioDeviceInfo::availableDevices(QAudio::AudioInput) * figured out it fails in a Qt console app, runs in a widget app * see https://discordapp.com/channels/539048679160676382/623947987822837779/631939335255752704
This commit is contained in:
committed by
Mat Sutcliffe
parent
e109106102
commit
1d9cd50463
@@ -17,6 +17,10 @@
|
||||
#include "test.h"
|
||||
#include <QTest>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "comdef.h"
|
||||
#endif
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -48,6 +52,9 @@ namespace BlackCoreTest
|
||||
return;
|
||||
}
|
||||
|
||||
// CContextAudioProxy::unitTestRelaySignals() crashes in QAudioDeviceInfo::availableDevices(QAudio::AudioInput)
|
||||
// discussion https://discordapp.com/channels/539048679160676382/623947987822837779/631940817669455903
|
||||
// solved if unit test initializes a QGuiApplication
|
||||
CContextAudioProxy::unitTestRelaySignals();
|
||||
CContextNetworkProxy::unitTestRelaySignals();
|
||||
CContextOwnAircraftProxy::unitTestRelaySignals();
|
||||
@@ -79,7 +86,18 @@ namespace BlackCoreTest
|
||||
//! main
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
// QCoreApplication app(argc, argv);
|
||||
// discussion https://discordapp.com/channels/539048679160676382/623947987822837779/631940817669455903
|
||||
// QDeviceInfo crashes using QCoreApplication
|
||||
|
||||
#ifdef _WIN32
|
||||
QGuiApplication app(argc, argv);
|
||||
const HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||
Q_UNUSED(hr)
|
||||
#else
|
||||
QCoreApplication app(argc, argv); // using QGuiApplication fails on Jenkins Linux, no display
|
||||
#endif
|
||||
|
||||
BLACKTEST_INIT(BlackCoreTest::CTestContext)
|
||||
CApplication a(CApplicationInfo::UnitTest);
|
||||
a.addVatlibOptions();
|
||||
|
||||
Reference in New Issue
Block a user