Fix crash when no QApplication is available.
This happens when QtCreator launches qmlplugindump. Testcase: qmlplugindump -nonrelocatable org.kde.analitza 1.1 or qmlplugindump -nonrelocatable org.kde.okular 2.0 REVIEW: 128767
This commit is contained in:
parent
910e6a4ef7
commit
a940089a8f
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "qmenu.h"
|
#include "qmenu.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
@ -27,15 +28,18 @@
|
|||||||
#include "plasmacomponentsplugin.h"
|
#include "plasmacomponentsplugin.h"
|
||||||
QMenuProxy::QMenuProxy(QObject *parent)
|
QMenuProxy::QMenuProxy(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
|
m_menu(Q_NULLPTR),
|
||||||
m_status(DialogStatus::Closed),
|
m_status(DialogStatus::Closed),
|
||||||
m_placement(Plasma::Types::LeftPosedTopAlignedPopup)
|
m_placement(Plasma::Types::LeftPosedTopAlignedPopup)
|
||||||
{
|
{
|
||||||
m_menu = new QMenu(0);
|
if (qobject_cast<QApplication *>(QCoreApplication::instance())) {
|
||||||
connect(m_menu, &QMenu::triggered, this, &QMenuProxy::itemTriggered);
|
m_menu = new QMenu(0);
|
||||||
connect(m_menu, &QMenu::aboutToHide, [ = ]() {
|
connect(m_menu, &QMenu::triggered, this, &QMenuProxy::itemTriggered);
|
||||||
m_status = DialogStatus::Closed;
|
connect(m_menu, &QMenu::aboutToHide, [ = ]() {
|
||||||
emit statusChanged();
|
m_status = DialogStatus::Closed;
|
||||||
});
|
emit statusChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenuProxy::~QMenuProxy()
|
QMenuProxy::~QMenuProxy()
|
||||||
@ -105,6 +109,9 @@ void QMenuProxy::setVisualParent(QObject *parent)
|
|||||||
|
|
||||||
QWindow *QMenuProxy::transientParent()
|
QWindow *QMenuProxy::transientParent()
|
||||||
{
|
{
|
||||||
|
if (!m_menu) {
|
||||||
|
return Q_NULLPTR;
|
||||||
|
}
|
||||||
return m_menu->windowHandle()->transientParent();
|
return m_menu->windowHandle()->transientParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user