[SailfishDevel] Why does sailfishapplication.cpp contain conditional preprocessor statements for desktop?

Superpelican superpelican at zoho.com
Sun May 5 13:32:06 UTC 2013


Well I decided to try it myself and it seems that that desktop support 
is needed to be able to deploy/run your app on the SailfishOS emulator, 
otherwise your app just exits.

I copy and pasted together this new main.cpp:
<code>
#include <QApplication>
#include <QGraphicsObject>
#include <QDir>
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>

#ifdef HAS_BOOSTER
#include <MDeclarativeCache>
#endif



Q_DECL_EXPORT int main(int argc, char *argv[])
{
     /*
     QScopedPointer<QApplication> app(Sailfish::createApplication(argc, 
argv));
     QScopedPointer<QDeclarativeView> 
view(Sailfish::createView("main.qml"));

     Sailfish::showView(view.data());
     */
     #ifdef HAS_BOOSTER
         MDeclarativeCache::qApplication(argc, argv);
     #else
         new QApplication(argc, argv);
     #endif

     QDeclarativeView *appview;
     #ifdef HAS_BOOSTER
         appview = MDeclarativeCache::qDeclarativeView();
     #else
         appview = new QDeclarativeView;
     #endif
     QString file = "main.qml";
     QString path = QString(DEPLOYMENT_PATH);
     appview->setSource(QUrl::fromLocalFile(path + file));
appview->setResizeMode(QDeclarativeView::SizeRootObjectToView);
     appview->setAttribute(Qt::WA_OpaquePaintEvent);
     appview->setAttribute(Qt::WA_NoSystemBackground);
appview->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
appview->viewport()->setAttribute(Qt::WA_NoSystemBackground);
     appview->showFullScreen();
}
</code>
It succesfully compiles and runs, but the Application Output area in the 
Qt Creator/Sailfish IDE gives me this:
<output>

Display on requested

Qml debugging is enabled. Only use this in a safe environment!

Using the meego graphics system

libEGL warning: DRI2: failed to authenticate

Warning: specifying an object instance for initialPage is sub-optimal - 
prefer to use a Component

Remote application finished with exit code 0.

</output>

While when I run the example application (with sailfishapplication.cpp 
etc.) it gives me this:
<output>

Display on requested

Qml debugging is enabled. Only use this in a safe environment!

Using the meego graphics system

libEGL warning: DRI2: failed to authenticate

Warning: specifying an object instance for initialPage is sub-optimal - 
prefer to use a Component

loaded the Generic plugin

Loaded the MeeGo sensor plugin

Requested sensor id ' "orientationsensor" ' interface not granted

Requested sensor id ' "orientationsensor" ' interface not granted

hijackWindow() context created for QDeclarativeView(0x6ffd9eb8) 1

QGLWindowSurface: Using plain widget as window surface 
QGLWindowSurface(0x702e8a48)

Successfully resolved MeeGo graphics system: 
/usr/lib/qt4/plugins/graphicssystems/libqmeegographicssystem.so

</output>

And when I exit the application in the emulator:
<output>
Remote application finished with exit code 0.
</output>

So basically the app isn't shown on the screen and just immediately 
exits after being started,

Superpelican
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sailfishos.org/pipermail/devel/attachments/20130505/66055cc9/attachment.html>


More information about the Devel mailing list