Reported in CLANG test build here: https://build.swift-project.org/job/macos_test_job/4/warnings10Result/
This commit is contained in:
Klaus Basan
2018-05-16 21:28:33 +02:00
parent 58bdbac7b6
commit 35d78b641a
4 changed files with 93 additions and 56 deletions

View File

@@ -648,9 +648,13 @@ namespace BlackCore
multiPart->moveToThread(m_accessManager->thread());
}
return httpRequestImpl(request, logId, callback, NoRedirects, [ this, multiPart ](QNetworkAccessManager & qam, const QNetworkRequest & request)
QPointer<CApplication> myself(this);
return httpRequestImpl(request, logId, callback, NoRedirects, [ = ](QNetworkAccessManager & qam, const QNetworkRequest & request)
{
QNetworkReply *nr = qam.post(request, multiPart);
QNetworkReply *nr = nullptr;
if (!myself) { return nr; }
if (!multiPart) { return nr; }
nr = qam.post(request, multiPart);
multiPart->setParent(nr);
return nr;
});

View File

@@ -51,29 +51,37 @@ namespace BlackCore
CContext(mode, runtime)
{
if (mode == CCoreFacadeConfig::NotUsed) { return; }
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, [this](const CStatusMessage & message)
QPointer<IContextApplication> myself(this);
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, [ = ](const CStatusMessage & message)
{
if (!myself) { return; }
this->logMessage(message, {});
});
connect(CLogHandler::instance(), &CLogHandler::subscriptionAdded, this, [this](const CLogPattern & pattern)
connect(CLogHandler::instance(), &CLogHandler::subscriptionAdded, this, [ = ](const CLogPattern & pattern)
{
if (!myself) { return; }
this->addLogSubscription({}, pattern);
});
connect(CLogHandler::instance(), &CLogHandler::subscriptionRemoved, this, [this](const CLogPattern & pattern)
connect(CLogHandler::instance(), &CLogHandler::subscriptionRemoved, this, [ = ](const CLogPattern & pattern)
{
if (!myself) { return; }
this->removeLogSubscription({}, pattern);
});
connect(this, &IContextApplication::logSubscriptionAdded, this, [this](const CIdentifier & subscriber, const CLogPattern & pattern)
connect(this, &IContextApplication::logSubscriptionAdded, this, [ = ](const CIdentifier & subscriber, const CLogPattern & pattern)
{
this->m_logSubscriptions[subscriber].push_back(pattern);
if (!myself) { return; }
m_logSubscriptions[subscriber].push_back(pattern);
});
connect(this, &IContextApplication::logSubscriptionRemoved, this, [this](const CIdentifier & subscriber, const CLogPattern & pattern)
connect(this, &IContextApplication::logSubscriptionRemoved, this, [ = ](const CIdentifier & subscriber, const CLogPattern & pattern)
{
this->m_logSubscriptions[subscriber].removeAll(pattern);
if (!myself) { return; }
m_logSubscriptions[subscriber].removeAll(pattern);
});
connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, [this](const CValueCachePacket & settings)
connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, [ = ](const CValueCachePacket & settings)
{
if (!myself) { return; }
this->changeSettings(settings, {});
});
@@ -83,14 +91,15 @@ namespace BlackCore
CSettingsCache::instance()->changeValuesFromRemote(settings, origin);
});
bool s = connect(CInputManager::instance(), &CInputManager::hotkeyActionRegistered, [this](const QStringList & actions)
bool s = connect(CInputManager::instance(), &CInputManager::hotkeyActionRegistered, [ = ](const QStringList & actions)
{
if (!myself) { return; }
this->registerHotkeyActions(actions, {});
});
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect hotkey action failed");
Q_UNUSED(s);
s = connect(this, &IContextApplication::hotkeyActionsRegistered, [this](const QStringList & actions, const CIdentifier & origin)
s = connect(this, &IContextApplication::hotkeyActionsRegistered, [ = ](const QStringList & actions, const CIdentifier & origin)
{
if (origin.hasApplicationProcessId()) { return; }
CInputManager::instance()->registerRemoteActions(actions);
@@ -98,15 +107,17 @@ namespace BlackCore
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect hotkey actions failed");
Q_UNUSED(s);
s = connect(CInputManager::instance(), &CInputManager::remoteActionFromLocal, [this](const QString & action, bool argument)
s = connect(CInputManager::instance(), &CInputManager::remoteActionFromLocal, [ = ](const QString & action, bool argument)
{
if (!myself) { return; }
this->callHotkeyAction(action, argument, {});
});
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect remote action failed");
Q_UNUSED(s);
s = connect(this, &IContextApplication::remoteHotkeyAction, [this](const QString & action, bool argument, const CIdentifier & origin)
s = connect(this, &IContextApplication::remoteHotkeyAction, [ = ](const QString & action, bool argument, const CIdentifier & origin)
{
if (!myself) { return; }
if (origin.isFromLocalMachine()) { return; }
CInputManager::instance()->callFunctionsBy(action, argument);
CLogMessage(this, CLogCategory::contextSlot()).debug() << "Calling function" << action << "from origin" << origin.getMachineName();

View File

@@ -445,7 +445,8 @@ namespace BlackGui
QMenu *sm = menu.addMenu(CIcons::appSettings16(), "Settings");
sm->setIcon(CIcons::appSettings16());
QAction *a = sm->addAction(CIcons::disk16(), "Settings directory");
bool c = connect(a, &QAction::triggered, this, [a, this]()
QPointer<CGuiApplication> myself(this);
bool c = connect(a, &QAction::triggered, this, [ = ]()
{
const QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore()));
if (QDir(path).exists())
@@ -456,25 +457,27 @@ namespace BlackGui
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
a = sm->addAction("Reset settings");
c = connect(a, &QAction::triggered, this, [this]()
c = connect(a, &QAction::triggered, this, [ = ]
{
if (myself.isNull()) { return; }
CSettingsCache::instance()->clearAllValues();
this->displayTextInConsole("Cleared all settings!");
myself->displayTextInConsole("Cleared all settings!");
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
a = sm->addAction("List settings files");
c = connect(a, &QAction::triggered, this, [this]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
if (myself.isNull()) { return; }
const QStringList files(CSettingsCache::instance()->enumerateStore());
this->displayTextInConsole(files.join("\n"));
myself->displayTextInConsole(files.join("\n"));
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
sm = menu.addMenu("Cache");
sm->setIcon(CIcons::appSettings16());
a = sm->addAction(CIcons::disk16(), "Cache directory");
c = connect(a, &QAction::triggered, this, [this]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
const QString path(QDir::toNativeSeparators(CDataCache::persistentStore()));
if (QDir(path).exists())
@@ -485,23 +488,25 @@ namespace BlackGui
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
a = sm->addAction("Reset cache");
c = connect(a, &QAction::triggered, this, [this]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
if (myself.isNull()) { return; }
const QStringList files = CApplication::clearCaches();
this->displayTextInConsole("Cleared caches! " + QString::number(files.size()) + " files");
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
a = sm->addAction("List cache files");
c = connect(a, &QAction::triggered, this, [this]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
if (myself.isNull()) { return; }
const QStringList files(CDataCache::instance()->enumerateStore());
this->displayTextInConsole(files.join("\n"));
myself->displayTextInConsole(files.join("\n"));
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
a = menu.addAction(CIcons::disk16(), "Log directory");
c = connect(a, &QAction::triggered, this, [this]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
const QString path(QDir::toNativeSeparators(CDirectoryUtils::logDirectory()));
if (QDir(path).exists())
@@ -519,18 +524,21 @@ namespace BlackGui
void CGuiApplication::addMenuForStyleSheets(QMenu &menu)
{
QPointer<CGuiApplication> myself(this);
QMenu *sm = menu.addMenu("Style sheet");
QAction *aReload = sm->addAction(CIcons::refresh16(), "Reload");
bool c = connect(aReload, &QAction::triggered, this, [aReload, this]()
bool c = connect(aReload, &QAction::triggered, this, [ = ]()
{
this->reloadStyleSheets();
if (myself.isNull()) { return; }
myself->reloadStyleSheets();
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
QAction *aOpen = sm->addAction(CIcons::text16(), "Open qss file");
c = connect(aOpen, &QAction::triggered, this, [aOpen, this]()
c = connect(aOpen, &QAction::triggered, this, [ = ]()
{
this->openStandardWidgetStyleSheet();
if (myself.isNull()) { return; }
myself->openStandardWidgetStyleSheet();
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
Q_UNUSED(c);
@@ -553,11 +561,13 @@ namespace BlackGui
menu.addSeparator();
a = menu.addAction("E&xit");
a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));
c = connect(a, &QAction::triggered, this, [a, this]()
QPointer<CGuiApplication> myself(this);
c = connect(a, &QAction::triggered, this, [ = ]()
{
// a close event might already trigger a shutdown
this->mainApplicationWidget()->close();
this->gracefulShutdown();
if (!myself) { return; }
myself->mainApplicationWidget()->close();
myself->gracefulShutdown();
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
Q_UNUSED(c);
@@ -565,38 +575,43 @@ namespace BlackGui
void CGuiApplication::addMenuInternals(QMenu &menu)
{
QPointer<CGuiApplication> myself(this);
QMenu *sm = menu.addMenu("Templates");
QAction *a = sm->addAction("JSON bootstrap");
bool c = connect(a, &QAction::triggered, this, [a, this]()
bool c = connect(a, &QAction::triggered, this, [ = ]()
{
if (!myself) { return; }
const CGlobalSetup s = this->getGlobalSetup();
this->displayTextInConsole(s.toJsonString());
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
a = sm->addAction("JSON update info (for info only)");
c = connect(a, &QAction::triggered, this, [a, this]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
if (!myself) { return; }
const CUpdateInfo info = this->getUpdateInfo();
this->displayTextInConsole(info.toJsonString());
myself->displayTextInConsole(info.toJsonString());
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
if (this->hasWebDataServices())
{
a = menu.addAction("Services log.(console)");
c = connect(a, &QAction::triggered, this, [a, this]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
this->displayTextInConsole(this->getWebDataServices()->getReadersLog());
if (!myself) { return; }
myself->displayTextInConsole(this->getWebDataServices()->getReadersLog());
CLogMessage(this).info("Displayed services log.");
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
}
a = menu.addAction("Metadata (slow)");
c = connect(a, &QAction::triggered, this, [a, this]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
this->displayTextInConsole(getAllUserMetatypesTypes());
if (!myself) { return; }
myself->displayTextInConsole(getAllUserMetatypesTypes());
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
Q_UNUSED(c);
@@ -604,44 +619,44 @@ namespace BlackGui
void CGuiApplication::addMenuWindow(QMenu &menu)
{
QWidget *w = mainApplicationWidget();
QPointer<QWidget> w = mainApplicationWidget();
if (!w) { return; }
const QSize iconSize = CIcons::empty16().size();
QPixmap icon = w->style()->standardIcon(QStyle::SP_TitleBarMaxButton).pixmap(iconSize);
QAction *a = menu.addAction(icon.scaled(iconSize), "Fullscreen");
bool c = connect(a, &QAction::triggered, this, [a, w]()
bool c = connect(a, &QAction::triggered, this, [ = ]()
{
if (!w) { return; }
w->showFullScreen();
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
icon = w->style()->standardIcon(QStyle::SP_TitleBarMinButton).pixmap(iconSize);
a = menu.addAction(icon.scaled(iconSize), "Minimize");
c = connect(a, &QAction::triggered, this, [a, w]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
if (!w) { return; }
w->showMinimized();
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
icon = w->style()->standardIcon(QStyle::SP_TitleBarNormalButton).pixmap(iconSize);
a = menu.addAction(icon.scaled(iconSize), "Normal");
c = connect(a, &QAction::triggered, this, [a, w]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
if (!w) { return; }
w->showNormal();
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
a = menu.addAction("Toggle stay on top");
c = connect(a, &QAction::triggered, this, [a, w]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
if (CGuiUtility::toggleStayOnTop(w))
{
CLogMessage(w).info("Window on top");
}
else
{
CLogMessage(w).info("Window not always on top");
}
if (!w) { return; }
const bool onTop = CGuiUtility::toggleStayOnTop(w);
CLogMessage(w.data()).info(onTop ?
QStringLiteral("Window on top") :
QStringLiteral("Window not always on top"));
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
Q_UNUSED(c);
@@ -649,18 +664,22 @@ namespace BlackGui
void CGuiApplication::addMenuHelp(QMenu &menu)
{
QWidget *w = mainApplicationWidget();
QPointer<QWidget> w = mainApplicationWidget();
if (!w) { return; }
QAction *a = menu.addAction(w->style()->standardIcon(QStyle::SP_TitleBarContextHelpButton), "Online help");
bool c = connect(a, &QAction::triggered, this, [this]()
QPointer<CGuiApplication> myself(this);
bool c = connect(a, &QAction::triggered, this, [ = ]()
{
this->showHelp();
if (!myself) { return; }
myself->showHelp();
});
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
a = menu.addAction(QApplication::windowIcon(), "About swift");
c = connect(a, &QAction::triggered, this, [w]()
c = connect(a, &QAction::triggered, this, [ = ]()
{
if (!w) { return; }
CAboutDialog dialog(w);
dialog.exec();
});

View File

@@ -11,6 +11,7 @@
#include "simulatorxplane.h"
#include <QLatin1String>
#include <QPointer>
class QDBusConnection;
@@ -28,8 +29,10 @@ namespace BlackSimPlugin
void CXSwiftBusServiceProxy::getOwnAircraftSituationData(XPlaneData *o_xplaneData)
{
std::function<void(QDBusPendingCallWatcher *)> callback = [this, o_xplaneData](QDBusPendingCallWatcher * watcher)
QPointer<CXSwiftBusServiceProxy> myself(this);
std::function<void(QDBusPendingCallWatcher *)> callback = [ = ](QDBusPendingCallWatcher * watcher)
{
if (!myself) { return; }
QDBusPendingReply<double, double, double, double, double, double, double, double> reply = *watcher;
if (!reply.isError())
{