Don't use MDeclarativeCache::qDeclarativeView()

Commit d687d11240 unfortunately caused
two severe regressions for MeeGo:

QTCREATORBUG-6473: The application creates two QDeclarativeViews
QTCREATORBUG-6490: QDView functions inaccessible. Existing apps broken

This commit removes most of d687d11240
just leaving the boosted QApplication. Now, QmlApplicationViewer *is*
again the QDeclarativeView.

Change-Id: I219540353ff4dd1061221d6cbe69ce9a58500e91
Task-Id: QTCREATORBUG-6473
Task-Id: QTCREATORBUG-6490
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Alessandro Portale
2011-11-16 13:09:03 +01:00
parent bb48e072be
commit b41237f01e
4 changed files with 17 additions and 42 deletions

View File

@@ -4,12 +4,12 @@
Q_DECL_EXPORT int main(int argc, char *argv[]) Q_DECL_EXPORT int main(int argc, char *argv[])
{ {
QScopedPointer<QApplication> app(createApplication(argc, argv)); QScopedPointer<QApplication> app(createApplication(argc, argv));
QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
viewer->addImportPath(QLatin1String("modules")); // ADDIMPORTPATH QmlApplicationViewer viewer;
viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION viewer.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH
viewer->setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION
viewer->showExpanded(); viewer.setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML
viewer.showExpanded();
return app->exec(); return app->exec();
} }

View File

@@ -11,10 +11,10 @@
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtGui/QApplication>
#include <QtDeclarative/QDeclarativeComponent> #include <QtDeclarative/QDeclarativeComponent>
#include <QtDeclarative/QDeclarativeEngine> #include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeContext> #include <QtDeclarative/QDeclarativeContext>
#include <QtGui/QApplication>
#include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
@@ -49,12 +49,9 @@ static QmlJsDebuggingEnabler enableDebuggingHelper;
class QmlApplicationViewerPrivate class QmlApplicationViewerPrivate
{ {
QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
QString mainQmlFile; QString mainQmlFile;
QDeclarativeView *view;
friend class QmlApplicationViewer; friend class QmlApplicationViewer;
QString adjustPath(const QString &path); static QString adjustPath(const QString &path);
}; };
QString QmlApplicationViewerPrivate::adjustPath(const QString &path) QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
@@ -76,34 +73,17 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
: QDeclarativeView(parent) : QDeclarativeView(parent)
, d(new QmlApplicationViewerPrivate(this)) , d(new QmlApplicationViewerPrivate())
{ {
connect(engine(), SIGNAL(quit()), SLOT(close())); connect(engine(), SIGNAL(quit()), SLOT(close()));
setResizeMode(QDeclarativeView::SizeRootObjectToView); setResizeMode(QDeclarativeView::SizeRootObjectToView);
// Qt versions prior to 4.8.0 don't have QML/JS debugging services built in // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
#if !defined(NO_JSDEBUGGER) #if !defined(NO_JSDEBUGGER)
new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); new QmlJSDebugger::JSDebuggerAgent(engine());
#endif #endif
#if !defined(NO_QMLOBSERVER) #if !defined(NO_QMLOBSERVER)
new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); new QmlJSDebugger::QDeclarativeViewObserver(this, this);
#endif
#endif
}
QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
: QDeclarativeView(parent)
, d(new QmlApplicationViewerPrivate(view))
{
connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
// Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
#if !defined(NO_JSDEBUGGER)
new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
#endif
#if !defined(NO_QMLOBSERVER)
new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
#endif #endif
#endif #endif
} }
@@ -115,22 +95,18 @@ QmlApplicationViewer::~QmlApplicationViewer()
QmlApplicationViewer *QmlApplicationViewer::create() QmlApplicationViewer *QmlApplicationViewer::create()
{ {
#ifdef HARMATTAN_BOOSTER
return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
#else
return new QmlApplicationViewer(); return new QmlApplicationViewer();
#endif
} }
void QmlApplicationViewer::setMainQmlFile(const QString &file) void QmlApplicationViewer::setMainQmlFile(const QString &file)
{ {
d->mainQmlFile = d->adjustPath(file); d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file);
d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); setSource(QUrl::fromLocalFile(d->mainQmlFile));
} }
void QmlApplicationViewer::addImportPath(const QString &path) void QmlApplicationViewer::addImportPath(const QString &path)
{ {
d->view->engine()->addImportPath(d->adjustPath(path)); engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path));
} }
void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
@@ -179,11 +155,11 @@ void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
void QmlApplicationViewer::showExpanded() void QmlApplicationViewer::showExpanded()
{ {
#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
d->view->showFullScreen(); showFullScreen();
#elif defined(Q_WS_MAEMO_5) #elif defined(Q_WS_MAEMO_5)
d->view->showMaximized(); showMaximized();
#else #else
d->view->show(); show();
#endif #endif
} }

View File

@@ -37,7 +37,6 @@ public:
void showExpanded(); void showExpanded();
private: private:
explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
class QmlApplicationViewerPrivate *d; class QmlApplicationViewerPrivate *d;
}; };

View File

@@ -466,7 +466,7 @@ QString QtQuickApp::componentSetDir(ComponentSet componentSet) const
} }
} }
const int QtQuickApp::StubVersion = 18; const int QtQuickApp::StubVersion = 19;
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager