Blackberry: Fix crash when opening file dialog without parent.
If parent is null, we now use qqnxintegration->primaryScreen() This simplifies ctors of QQnxTheme and QQnxFileDialogHelper which now receive a QQnxIntegration pointer instead of receiving a font database and a bps event filter. Change-Id: I3b1ed4d99f738b980a4f19a98618341a14e0c222 Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
This commit is contained in:
parent
aa3a75ce14
commit
1eabbc0908
@ -43,6 +43,7 @@
|
||||
|
||||
#include "qqnxbpseventfilter.h"
|
||||
#include "qqnxscreen.h"
|
||||
#include "qqnxintegration.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QEventLoop>
|
||||
@ -58,9 +59,9 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QQnxFileDialogHelper::QQnxFileDialogHelper(QQnxBpsEventFilter *eventFilter)
|
||||
QQnxFileDialogHelper::QQnxFileDialogHelper(const QQnxIntegration *integration)
|
||||
: QPlatformFileDialogHelper(),
|
||||
m_eventFilter(eventFilter),
|
||||
m_integration(integration),
|
||||
m_dialog(0),
|
||||
m_acceptMode(QFileDialogOptions::AcceptOpen),
|
||||
m_selectedFilter(),
|
||||
@ -144,8 +145,9 @@ bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modali
|
||||
Q_UNUSED(flags);
|
||||
qFileDialogHelperDebug() << Q_FUNC_INFO;
|
||||
|
||||
QQnxBpsEventFilter *eventFilter = m_integration->bpsEventFilter();
|
||||
// We *really* need the bps event filter ;)
|
||||
if (!m_eventFilter)
|
||||
if (!eventFilter)
|
||||
return false;
|
||||
|
||||
// Native dialogs can only handle application modal use cases so far
|
||||
@ -208,12 +210,15 @@ bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modali
|
||||
m_acceptMode = opts->acceptMode();
|
||||
|
||||
// Set the libscreen window group and common properties
|
||||
QQnxScreen *nativeScreen = static_cast<QQnxScreen *>(parent->screen()->handle());
|
||||
|
||||
QQnxScreen *nativeScreen = parent ? static_cast<QQnxScreen *>(parent->screen()->handle()) :
|
||||
m_integration->primaryDisplay();
|
||||
Q_ASSERT(nativeScreen);
|
||||
dialog_set_group_id(m_dialog, nativeScreen->windowGroupName());
|
||||
dialog_set_title_text(m_dialog, opts->windowTitle().toLocal8Bit().constData());
|
||||
|
||||
// Register ourselves for dialog domain events from bps
|
||||
m_eventFilter->registerForDialogEvents(this);
|
||||
eventFilter->registerForDialogEvents(this);
|
||||
|
||||
// Show the dialog
|
||||
dialog_show(m_dialog);
|
||||
|
@ -48,13 +48,13 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QQnxBpsEventFilter;
|
||||
class QQnxIntegration;
|
||||
|
||||
class QQnxFileDialogHelper : public QPlatformFileDialogHelper
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQnxFileDialogHelper(QQnxBpsEventFilter *eventFilter);
|
||||
explicit QQnxFileDialogHelper(const QQnxIntegration *);
|
||||
~QQnxFileDialogHelper();
|
||||
|
||||
bool handleEvent(bps_event_t *event);
|
||||
@ -81,7 +81,7 @@ Q_SIGNALS:
|
||||
private:
|
||||
void setNameFilter(const QString &filter);
|
||||
|
||||
QQnxBpsEventFilter *m_eventFilter;
|
||||
const QQnxIntegration *m_integration;
|
||||
dialog_instance_t m_dialog;
|
||||
QFileDialogOptions::AcceptMode m_acceptMode;
|
||||
QString m_selectedFilter;
|
||||
|
@ -406,7 +406,7 @@ QPlatformTheme *QQnxIntegration::createPlatformTheme(const QString &name) const
|
||||
{
|
||||
qIntegrationDebug() << Q_FUNC_INFO << "name =" << name;
|
||||
if (name == QQnxTheme::name())
|
||||
return new QQnxTheme(m_fontDatabase, m_bpsEventFilter);
|
||||
return new QQnxTheme(this);
|
||||
return QPlatformIntegration::createPlatformTheme(name);
|
||||
}
|
||||
#endif
|
||||
|
@ -128,10 +128,10 @@ public:
|
||||
|
||||
void createDisplay(screen_display_t display, bool isPrimary);
|
||||
void removeDisplay(QQnxScreen *screen);
|
||||
QQnxScreen *primaryDisplay() const;
|
||||
private:
|
||||
void createDisplays();
|
||||
void destroyDisplays();
|
||||
QQnxScreen *primaryDisplay() const;
|
||||
|
||||
static void addWindow(screen_window_t qnxWindow, QWindow *window);
|
||||
static void removeWindow(screen_window_t qnxWindow);
|
||||
|
@ -43,13 +43,11 @@
|
||||
|
||||
#include "qqnxfiledialoghelper.h"
|
||||
#include "qqnxsystemsettings.h"
|
||||
#include "qqnxintegration.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QQnxTheme::QQnxTheme(QPlatformFontDatabase *fontDatabase,
|
||||
QQnxBpsEventFilter *eventFilter)
|
||||
: m_fontDatabase(fontDatabase),
|
||||
m_eventFilter(eventFilter)
|
||||
QQnxTheme::QQnxTheme(const QQnxIntegration *integration) : m_integration(integration)
|
||||
{
|
||||
}
|
||||
|
||||
@ -77,7 +75,7 @@ QPlatformDialogHelper *QQnxTheme::createPlatformDialogHelper(DialogType type) co
|
||||
{
|
||||
switch (type) {
|
||||
case QPlatformTheme::FileDialog:
|
||||
return new QQnxFileDialogHelper(m_eventFilter);
|
||||
return new QQnxFileDialogHelper(m_integration);
|
||||
#ifndef QT_NO_COLORDIALOG
|
||||
case QPlatformTheme::ColorDialog:
|
||||
#endif
|
||||
@ -91,8 +89,10 @@ QPlatformDialogHelper *QQnxTheme::createPlatformDialogHelper(DialogType type) co
|
||||
|
||||
const QFont *QQnxTheme::font(Font type) const
|
||||
{
|
||||
if (m_fonts.isEmpty() && m_fontDatabase)
|
||||
m_fonts = qt_qnx_createRoleFonts(m_fontDatabase);
|
||||
QPlatformFontDatabase *fontDatabase = m_integration->fontDatabase();
|
||||
|
||||
if (fontDatabase && m_fonts.isEmpty())
|
||||
m_fonts = qt_qnx_createRoleFonts(fontDatabase);
|
||||
return m_fonts.value(type, 0);
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,12 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QQnxBpsEventFilter;
|
||||
|
||||
class QPlatformFontDatabase;
|
||||
class QQnxIntegration;
|
||||
|
||||
class QQnxTheme : public QPlatformTheme
|
||||
{
|
||||
public:
|
||||
QQnxTheme(QPlatformFontDatabase *fontDatabase, QQnxBpsEventFilter *eventFilter);
|
||||
explicit QQnxTheme(const QQnxIntegration *);
|
||||
~QQnxTheme();
|
||||
|
||||
static QString name() { return QStringLiteral("blackberry"); }
|
||||
@ -69,9 +67,8 @@ public:
|
||||
const QFont *font(Font type = SystemFont) const;
|
||||
|
||||
private:
|
||||
QPlatformFontDatabase *m_fontDatabase;
|
||||
QQnxBpsEventFilter *m_eventFilter;
|
||||
mutable QHash<QPlatformTheme::Font, QFont*> m_fonts;
|
||||
const QQnxIntegration *m_integration;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user