We have moved to a new Sailfish OS Forum. Please start new discussions there.
1

Help with .cpp file [answered]

asked 2015-02-24 23:47:47 +0300

Jonas gravatar image

updated 2015-02-24 23:53:37 +0300

Acce gravatar image

After changing the .cpp file to get translation for to my app I can't start from the "app-list". However I can start it from the terminal. When starting the app from the "app-list" the busy indication starts and after a while it disappears.

This is my .cpp file

//#ifdef QT_QML_DEBUG
#include <QtQuick>
//#endif


#include <sailfishapp.h>
#include <QTranslator>
#include <QTextCodec>
#include <QLocale>
#include <QtQml/QQmlEngine>
#include <QScopedPointer>
#include <QQuickView>
#include <QtGui/QGuiApplication>

#include <qqml.h>

int main(int argc, char *argv[])
{
    // SailfishApp::main() will display "qml/template.qml", if you need more
    // control over initialization, you can use:
    //
    //   - SailfishApp::application(int, char *[]) to get the QGuiApplication *
    //   - SailfishApp::createView() to get a new QQuickView * instance
    //   - SailfishApp::pathTo(QString) to get a QUrl to a resource file
    //
    // To display the view, call "show()" (will show fullscreen on device).

    QGuiApplication *app = (SailfishApp::application(argc, argv));

    //Translations
    QString translationPath(SailfishApp::pathTo("translations").toLocalFile());

    qDebug() << "Translation Path:" << translationPath;
    static QTranslator translator;
    if(translator.load(QLocale(), "SLSailor", "_", translationPath)) {
        app->installTranslator(&translator);
        qDebug() << "Translation file loaded";
    } else
        qDebug() << "Translation file not loaded";


    QScopedPointer <QQuickView> view(SailfishApp::createView());
    app->setApplicationName("SLSailor");
    app->setOrganizationDomain("SLSailor");
    app->setOrganizationName("SLSailor");
    view->setTitle("SLSailor");
    QUrl pageSource = SailfishApp::pathTo("qml/SLSailor.qml");
    view->setSource(pageSource);
    view->showFullScreen();
    return app->exec();
}
edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by Jonas
close date 2015-03-02 19:41:41.357584

Comments

What is an app-list, and does your code work in Emulator wirh SailfishOS SDK?

foss4ever ( 2015-02-25 08:45:15 +0300 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2015-02-25 00:04:41 +0300

Acce gravatar image

Try debugging by launching the app with the invoker:

invoker --type=qt5 yourapp-executable

Afaik the invoker is used to launch apps when launched from the app launcher. I don't see anything immediate cause for crashing.

edit flag offensive delete publish link more

Comments

I tried and it launched with the same output as when launching with just yourapp-executable

This is the output from the terminal:

invoker: Invoking execution: '/usr/bin/SLSailor'

    [D] main:63 - Translation Path: "/usr/share/SLSailor/translations" 
    [D] main:67 - Translation file loaded 
    [D] QWaylandEglClientBufferIntegration::QWaylandEglClientBufferIntegration:62 - Using Wayland-EGL 
    [W] QQmlImportDatabase::registerPluginTypes:1875 - Module 'Sailfish.Silica' does not contain a module identifier directive - it cannot be protected from external registrations.
    [D] DeclarativeCoverWindow::DeclarativeCoverWindow:63 - DeclarativeCoverWindow: I have a default alpha buffer

Still no luck from app-icon

Jonas ( 2015-02-25 00:11:02 +0300 )edit

well, next I would suggest adding some more debug printing, for what QLocale you get and check if the values are the same when running from terminal or app launcher. The debug messages should show up in journalctl -qaf when launching from app-icon.

Acce ( 2015-02-25 00:59:26 +0300 )edit

I rebooted my phone and then it worked. Strange, but good ;)

Jonas ( 2015-03-02 19:40:38 +0300 )edit

Question tools

Follow
1 follower

Stats

Asked: 2015-02-24 23:47:47 +0300

Seen: 246 times

Last updated: Feb 25 '15