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 "qqnxbpseventfilter.h"
|
||||||
#include "qqnxscreen.h"
|
#include "qqnxscreen.h"
|
||||||
|
#include "qqnxintegration.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
@ -58,9 +59,9 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QQnxFileDialogHelper::QQnxFileDialogHelper(QQnxBpsEventFilter *eventFilter)
|
QQnxFileDialogHelper::QQnxFileDialogHelper(const QQnxIntegration *integration)
|
||||||
: QPlatformFileDialogHelper(),
|
: QPlatformFileDialogHelper(),
|
||||||
m_eventFilter(eventFilter),
|
m_integration(integration),
|
||||||
m_dialog(0),
|
m_dialog(0),
|
||||||
m_acceptMode(QFileDialogOptions::AcceptOpen),
|
m_acceptMode(QFileDialogOptions::AcceptOpen),
|
||||||
m_selectedFilter(),
|
m_selectedFilter(),
|
||||||
@ -144,8 +145,9 @@ bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modali
|
|||||||
Q_UNUSED(flags);
|
Q_UNUSED(flags);
|
||||||
qFileDialogHelperDebug() << Q_FUNC_INFO;
|
qFileDialogHelperDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
QQnxBpsEventFilter *eventFilter = m_integration->bpsEventFilter();
|
||||||
// We *really* need the bps event filter ;)
|
// We *really* need the bps event filter ;)
|
||||||
if (!m_eventFilter)
|
if (!eventFilter)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Native dialogs can only handle application modal use cases so far
|
// 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();
|
m_acceptMode = opts->acceptMode();
|
||||||
|
|
||||||
// Set the libscreen window group and common properties
|
// 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_group_id(m_dialog, nativeScreen->windowGroupName());
|
||||||
dialog_set_title_text(m_dialog, opts->windowTitle().toLocal8Bit().constData());
|
dialog_set_title_text(m_dialog, opts->windowTitle().toLocal8Bit().constData());
|
||||||
|
|
||||||
// Register ourselves for dialog domain events from bps
|
// Register ourselves for dialog domain events from bps
|
||||||
m_eventFilter->registerForDialogEvents(this);
|
eventFilter->registerForDialogEvents(this);
|
||||||
|
|
||||||
// Show the dialog
|
// Show the dialog
|
||||||
dialog_show(m_dialog);
|
dialog_show(m_dialog);
|
||||||
|
@ -48,13 +48,13 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QQnxBpsEventFilter;
|
class QQnxIntegration;
|
||||||
|
|
||||||
class QQnxFileDialogHelper : public QPlatformFileDialogHelper
|
class QQnxFileDialogHelper : public QPlatformFileDialogHelper
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QQnxFileDialogHelper(QQnxBpsEventFilter *eventFilter);
|
explicit QQnxFileDialogHelper(const QQnxIntegration *);
|
||||||
~QQnxFileDialogHelper();
|
~QQnxFileDialogHelper();
|
||||||
|
|
||||||
bool handleEvent(bps_event_t *event);
|
bool handleEvent(bps_event_t *event);
|
||||||
@ -81,7 +81,7 @@ Q_SIGNALS:
|
|||||||
private:
|
private:
|
||||||
void setNameFilter(const QString &filter);
|
void setNameFilter(const QString &filter);
|
||||||
|
|
||||||
QQnxBpsEventFilter *m_eventFilter;
|
const QQnxIntegration *m_integration;
|
||||||
dialog_instance_t m_dialog;
|
dialog_instance_t m_dialog;
|
||||||
QFileDialogOptions::AcceptMode m_acceptMode;
|
QFileDialogOptions::AcceptMode m_acceptMode;
|
||||||
QString m_selectedFilter;
|
QString m_selectedFilter;
|
||||||
|
@ -406,7 +406,7 @@ QPlatformTheme *QQnxIntegration::createPlatformTheme(const QString &name) const
|
|||||||
{
|
{
|
||||||
qIntegrationDebug() << Q_FUNC_INFO << "name =" << name;
|
qIntegrationDebug() << Q_FUNC_INFO << "name =" << name;
|
||||||
if (name == QQnxTheme::name())
|
if (name == QQnxTheme::name())
|
||||||
return new QQnxTheme(m_fontDatabase, m_bpsEventFilter);
|
return new QQnxTheme(this);
|
||||||
return QPlatformIntegration::createPlatformTheme(name);
|
return QPlatformIntegration::createPlatformTheme(name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -128,10 +128,10 @@ public:
|
|||||||
|
|
||||||
void createDisplay(screen_display_t display, bool isPrimary);
|
void createDisplay(screen_display_t display, bool isPrimary);
|
||||||
void removeDisplay(QQnxScreen *screen);
|
void removeDisplay(QQnxScreen *screen);
|
||||||
|
QQnxScreen *primaryDisplay() const;
|
||||||
private:
|
private:
|
||||||
void createDisplays();
|
void createDisplays();
|
||||||
void destroyDisplays();
|
void destroyDisplays();
|
||||||
QQnxScreen *primaryDisplay() const;
|
|
||||||
|
|
||||||
static void addWindow(screen_window_t qnxWindow, QWindow *window);
|
static void addWindow(screen_window_t qnxWindow, QWindow *window);
|
||||||
static void removeWindow(screen_window_t qnxWindow);
|
static void removeWindow(screen_window_t qnxWindow);
|
||||||
|
@ -43,13 +43,11 @@
|
|||||||
|
|
||||||
#include "qqnxfiledialoghelper.h"
|
#include "qqnxfiledialoghelper.h"
|
||||||
#include "qqnxsystemsettings.h"
|
#include "qqnxsystemsettings.h"
|
||||||
|
#include "qqnxintegration.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QQnxTheme::QQnxTheme(QPlatformFontDatabase *fontDatabase,
|
QQnxTheme::QQnxTheme(const QQnxIntegration *integration) : m_integration(integration)
|
||||||
QQnxBpsEventFilter *eventFilter)
|
|
||||||
: m_fontDatabase(fontDatabase),
|
|
||||||
m_eventFilter(eventFilter)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +75,7 @@ QPlatformDialogHelper *QQnxTheme::createPlatformDialogHelper(DialogType type) co
|
|||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QPlatformTheme::FileDialog:
|
case QPlatformTheme::FileDialog:
|
||||||
return new QQnxFileDialogHelper(m_eventFilter);
|
return new QQnxFileDialogHelper(m_integration);
|
||||||
#ifndef QT_NO_COLORDIALOG
|
#ifndef QT_NO_COLORDIALOG
|
||||||
case QPlatformTheme::ColorDialog:
|
case QPlatformTheme::ColorDialog:
|
||||||
#endif
|
#endif
|
||||||
@ -91,8 +89,10 @@ QPlatformDialogHelper *QQnxTheme::createPlatformDialogHelper(DialogType type) co
|
|||||||
|
|
||||||
const QFont *QQnxTheme::font(Font type) const
|
const QFont *QQnxTheme::font(Font type) const
|
||||||
{
|
{
|
||||||
if (m_fonts.isEmpty() && m_fontDatabase)
|
QPlatformFontDatabase *fontDatabase = m_integration->fontDatabase();
|
||||||
m_fonts = qt_qnx_createRoleFonts(m_fontDatabase);
|
|
||||||
|
if (fontDatabase && m_fonts.isEmpty())
|
||||||
|
m_fonts = qt_qnx_createRoleFonts(fontDatabase);
|
||||||
return m_fonts.value(type, 0);
|
return m_fonts.value(type, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,14 +51,12 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QQnxBpsEventFilter;
|
class QQnxIntegration;
|
||||||
|
|
||||||
class QPlatformFontDatabase;
|
|
||||||
|
|
||||||
class QQnxTheme : public QPlatformTheme
|
class QQnxTheme : public QPlatformTheme
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QQnxTheme(QPlatformFontDatabase *fontDatabase, QQnxBpsEventFilter *eventFilter);
|
explicit QQnxTheme(const QQnxIntegration *);
|
||||||
~QQnxTheme();
|
~QQnxTheme();
|
||||||
|
|
||||||
static QString name() { return QStringLiteral("blackberry"); }
|
static QString name() { return QStringLiteral("blackberry"); }
|
||||||
@ -69,9 +67,8 @@ public:
|
|||||||
const QFont *font(Font type = SystemFont) const;
|
const QFont *font(Font type = SystemFont) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPlatformFontDatabase *m_fontDatabase;
|
|
||||||
QQnxBpsEventFilter *m_eventFilter;
|
|
||||||
mutable QHash<QPlatformTheme::Font, QFont*> m_fonts;
|
mutable QHash<QPlatformTheme::Font, QFont*> m_fonts;
|
||||||
|
const QQnxIntegration *m_integration;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user