Changes: Exception handlers for test applications added

RevBy: TrustMe
pull/1/head
Alexey Shilov 14 years ago
parent f661df43ca
commit 0c244451de

@ -20,6 +20,7 @@
#include "multiwindowcontent.h"
#include <QString>
#include <MApplication>
#include <exception>
#ifdef HAVE_MCOMPONENTCACHE
#include <mcomponentcache.h>
@ -28,36 +29,46 @@
M_EXPORT int main(int argc, char **argv)
{
MApplication *app;
try
{
#ifdef HAVE_MCOMPONENTCACHE
MApplication *app = MComponentCache::mApplication(argc, argv);
app = MComponentCache::mApplication(argc, argv);
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
bWindowNotFromCache = true;
break;
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
bWindowNotFromCache = true;
break;
}
}
if (bWindowNotFromCache) {
MultiWindowContent mwContent(false);
mwContent.createWindows();
mwContent.activateWindow(1);
} else {
MultiWindowContent mwContent(true);
mwContent.createWindows();
mwContent.activateWindow(1);
}
}
if (bWindowNotFromCache) {
#else
app = new MApplication(argc, argv);
MultiWindowContent mwContent(false);
mwContent.createWindows();
mwContent.activateWindow(1);
} else {
MultiWindowContent mwContent(true);
mwContent.createWindows();
mwContent.activateWindow(1);
}
#else
MApplication *app = new MApplication(argc, argv);
MultiWindowContent mwContent(false);
mwContent.createWindows();
mwContent.activateWindow(1);
#endif
}
catch(std::exception& e)
{
return -1;
}
return app->exec();
}

@ -21,6 +21,8 @@
#include <QFile>
#include <sys/time.h>
#include "mdeclarativecache.h"
#include <exception>
QString log_file = "/tmp/fala_qml_helloworld.log";
@ -64,69 +66,79 @@ void timestamp(const QString& s)
Q_DECL_EXPORT int main(int argc, char **argv)
{
QString appName(argv[0]);
if (appName.endsWith("fala_qml_wl"))
{
log_file = "/tmp/fala_qml_wl.log";
}
else if (appName.endsWith("fala_qml_wol"))
QApplication *app;
try
{
log_file = "/tmp/fala_qml_wol.log";
}
timestamp("application main");
QApplication *app = MDeclarativeCache::qApplication(argc, argv);
timestamp("QApplication from cache");
QString appName(argv[0]);
if (appName.endsWith("fala_qml_wl"))
{
log_file = "/tmp/fala_qml_wl.log";
}
else if (appName.endsWith("fala_qml_wol"))
{
log_file = "/tmp/fala_qml_wol.log";
}
timestamp("application main");
QDeclarativeView *window = NULL;
app = MDeclarativeCache::qApplication(argc, argv);
timestamp("QApplication from cache");
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
QDeclarativeView *window = NULL;
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
bWindowNotFromCache = true;
break;
}
}
if (bWindowNotFromCache) {
window = new QDeclarativeView();
timestamp("QDeclarativeView NOT from cache");
} else {
window = MDeclarativeCache::qDeclarativeView();
timestamp("QDeclarativeView from cache");
}
timestamp(QString("applicationDirPath: ").append(QApplication::applicationDirPath()));
timestamp(QString("applicationFilePath: ").append(QApplication::applicationFilePath()));
}
}
if (argc > 2 && QString(argv[1]) == QString("--log-args")) {
FANGORNLOG("argv:", false);
for (int i = 0; i < argc; i++) {
FANGORNLOG(" ", false);
FANGORNLOG(argv[i], false);
if (bWindowNotFromCache) {
window = new QDeclarativeView();
timestamp("QDeclarativeView NOT from cache");
} else {
window = MDeclarativeCache::qDeclarativeView();
timestamp("QDeclarativeView from cache");
}
FANGORNLOG("");
FANGORNLOG("argv:", false);
QStringList args = QCoreApplication::arguments();
for (int i = 0; i < args.size(); i++) {
FANGORNLOG(" ", false);
FANGORNLOG(args.at(i), false);
timestamp(QString("applicationDirPath: ").append(QApplication::applicationDirPath()));
timestamp(QString("applicationFilePath: ").append(QApplication::applicationFilePath()));
if (argc > 2 && QString(argv[1]) == QString("--log-args")) {
FANGORNLOG("argv:", false);
for (int i = 0; i < argc; i++) {
FANGORNLOG(" ", false);
FANGORNLOG(argv[i], false);
}
FANGORNLOG("");
FANGORNLOG("argv:", false);
QStringList args = QCoreApplication::arguments();
for (int i = 0; i < args.size(); i++) {
FANGORNLOG(" ", false);
FANGORNLOG(args.at(i), false);
}
FANGORNLOG("");
}
FANGORNLOG("");
}
window->setWindowTitle("Applauncherd QML testapp");
window->setWindowTitle("Applauncherd QML testapp");
window->setResizeMode(QDeclarativeView::SizeRootObjectToView);
window->setResizeMode(QDeclarativeView::SizeRootObjectToView);
//window->setSource(QUrl::fromLocalFile("/usr/share/fala_qml_helloworld/main.qml"));
window->setSource(QUrl("qrc:/main.qml"));
window->showFullScreen();
timestamp("Calling app->exec()");
}
catch(std::exception& e)
{
return -1;
}
//window->setSource(QUrl::fromLocalFile("/usr/share/fala_qml_helloworld/main.qml"));
window->setSource(QUrl("qrc:/main.qml"));
window->showFullScreen();
timestamp("Calling app->exec()");
_exit(app->exec());
}

@ -20,6 +20,7 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <cstdlib>
#include <exception>
using std::atoi;
@ -94,18 +95,26 @@ int main(int argc, char **argv)
{
if(argc < 2) return EXIT_FAILURE;
const int pid = atoi(argv[1]);
try
{
const int pid = atoi(argv[1]);
// Start with the root window.
Display *display = XOpenDisplay(0);
// Start with the root window.
Display *display = XOpenDisplay(0);
WindowsMatchingPid match(display, XDefaultRootWindow(display), pid);
WindowsMatchingPid match(display, XDefaultRootWindow(display), pid);
// Print the resulting window id's
const list<Window> &result = match.result();
for(list<Window>::const_iterator it = result.begin(); it != result.end(); it++)
cout << "0x" << std::hex << (unsigned long)(*it) << std::dec << endl;
// Print the resulting window id's
const list<Window> &result = match.result();
for(list<Window>::const_iterator it = result.begin(); it != result.end(); it++)
cout << "0x" << std::hex << (unsigned long)(*it) << std::dec << endl;
}
catch(std::exception& e)
{
return -1;
}
return EXIT_SUCCESS;
return EXIT_FAILURE;
}

@ -30,6 +30,7 @@
#include <MLinearLayoutPolicy>
#include <QFile>
#include <sys/time.h>
#include <exception>
#ifdef HAVE_MCOMPONENTCACHE
#include <mcomponentcache.h>
@ -66,61 +67,70 @@ void timestamp(const QString& s)
M_EXPORT int main(int argc, char ** argv)
{
MApplication *app;
try
{
#ifdef HAVE_MCOMPONENTCACHE
MApplication *app = MComponentCache::mApplication(argc, argv);
MApplicationWindow *window = NULL;
app = MComponentCache::mApplication(argc, argv);
MApplicationWindow *window = NULL;
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
bWindowNotFromCache = true;
break;
}
}
}
}
if (bWindowNotFromCache) {
window = new MApplicationWindow();
timestamp("MApplicationWindow NOT from cache");
} else {
window = MComponentCache::mApplicationWindow();
timestamp("MApplicationWindow from cache");
}
if (bWindowNotFromCache) {
window = new MApplicationWindow();
timestamp("MApplicationWindow NOT from cache");
} else {
window = MComponentCache::mApplicationWindow();
timestamp("MApplicationWindow from cache");
}
#else
MApplication *app = new MApplication(argc, argv);
MApplicationWindow *window = new MApplicationWindow;
app = new MApplication(argc, argv);
MApplicationWindow *window = new MApplicationWindow;
#endif
timestamp(QString("applicationDirPath: ").append(QApplication::applicationDirPath()));
timestamp(QString("applicationFilePath: ").append(QApplication::applicationFilePath()));
timestamp(QString("applicationDirPath: ").append(QApplication::applicationDirPath()));
timestamp(QString("applicationFilePath: ").append(QApplication::applicationFilePath()));
MApplicationPage *mainPage = new MApplicationPage;
mainPage->setTitle("Hello World! (Now supports Launcher)");
mainPage->centralWidget()->setObjectName("centralWidget");
MApplicationPage *mainPage = new MApplicationPage;
mainPage->setTitle("Hello World! (Now supports Launcher)");
mainPage->centralWidget()->setObjectName("centralWidget");
MLayout *layout = new MLayout(mainPage->centralWidget());
MLinearLayoutPolicy *linearPolicy = new MLinearLayoutPolicy(layout,
Qt::Vertical);
MLayout *layout = new MLayout(mainPage->centralWidget());
MLinearLayoutPolicy *linearPolicy = new MLinearLayoutPolicy(layout,
Qt::Vertical);
linearPolicy->addItem(new MLabel("I'm a label"));
linearPolicy->addItem(new MButton("Click me!"));
linearPolicy->addItem(new MSlider);
linearPolicy->addItem(new MLabel("I'm a label"));
linearPolicy->addItem(new MButton("Click me!"));
linearPolicy->addItem(new MSlider);
window->show();
window->show();
const char *foobar = "foo!";
for (int i = 0; i < argc; ++i)
{
if (QString(argv[i]) == "-segfault")
const char *foobar = "foo!";
for (int i = 0; i < argc; ++i)
{
const_cast<char *>(foobar)[3] = 'z';
if (QString(argv[i]) == "-segfault")
{
const_cast<char *>(foobar)[3] = 'z';
}
}
}
// Explicitly state where to appear, just to be sure :-)
mainPage->appear(window);
// Explicitly state where to appear, just to be sure :-)
mainPage->appear(window);
}
catch(std::exception& e)
{
return -1;
}
_exit(app->exec());
}

@ -29,6 +29,8 @@
#include <QFile>
#include <sys/time.h>
#include <exception>
QString log_file = "/tmp/fala_testapp.log";
void FANGORNLOG(const char* s, bool eol = true)
@ -73,58 +75,68 @@ public:
M_EXPORT int main(int, char**);
int main(int argc, char **argv) {
QString appName(argv[0]);
if (appName.endsWith("fala_wl"))
{
log_file = "/tmp/fala_wl.log";
}
else if (appName.endsWith("fala_wol"))
MApplication *app;
try
{
log_file = "/tmp/fala_wol.log";
}
timestamp("application main");
QString appName(argv[0]);
if (appName.endsWith("fala_wl"))
{
log_file = "/tmp/fala_wl.log";
}
else if (appName.endsWith("fala_wol"))
{
log_file = "/tmp/fala_wol.log";
}
timestamp("application main");
#ifdef HAVE_MCOMPONENTCACHE
MApplication* app = MComponentCache::mApplication(argc, argv);
timestamp("app from cache");
MApplicationWindow* w = MComponentCache::mApplicationWindow();
timestamp("win from cache");
app = MComponentCache::mApplication(argc, argv);
timestamp("app from cache");
MApplicationWindow* w = MComponentCache::mApplicationWindow();
timestamp("win from cache");
#else
MApplication* app = new MApplication(argc, argv);
timestamp("app created without cache");
app = new MApplication(argc, argv);
timestamp("app created without cache");
MApplicationWindow* w = new MApplicationWindow;
timestamp("win created without cache");
MApplicationWindow* w = new MApplicationWindow;
timestamp("win created without cache");
#endif
if (argc > 2 && QString(argv[1]) == QString("--log-args")) {
FANGORNLOG("argv:", false);
for (int i = 0; i < argc; i++) {
FANGORNLOG(" ", false);
FANGORNLOG(argv[i], false);
}
FANGORNLOG("");
FANGORNLOG("argv:", false);
QStringList args = QCoreApplication::arguments();
for (int i = 0; i < args.size(); i++) {
FANGORNLOG(" ", false);
FANGORNLOG(args.at(i), false);
if (argc > 2 && QString(argv[1]) == QString("--log-args")) {
FANGORNLOG("argv:", false);
for (int i = 0; i < argc; i++) {
FANGORNLOG(" ", false);
FANGORNLOG(argv[i], false);
}
FANGORNLOG("");
FANGORNLOG("argv:", false);
QStringList args = QCoreApplication::arguments();
for (int i = 0; i < args.size(); i++) {
FANGORNLOG(" ", false);
FANGORNLOG(args.at(i), false);
}
FANGORNLOG("");
}
FANGORNLOG("");
}
MyApplicationPage p;
timestamp("page created");
MyApplicationPage p;
timestamp("page created");
MApplication::setPrestartMode(M::LazyShutdown);
p.setTitle("Applauncherd testapp");
MApplication::setPrestartMode(M::LazyShutdown);
p.setTitle("Applauncherd testapp");
p.appear();
timestamp("page.appear() called");
p.appear();
timestamp("page.appear() called");
w->show();
timestamp("w->show() called");
w->show();
timestamp("w->show() called");
}
catch(std::exception& e)
{
return -1;
}
_exit(app->exec());
}

@ -26,7 +26,7 @@
#include <MLinearLayoutPolicy>
#include <MLayout>
#include <MTheme>
#include <exception>
#include <mcomponentcache.h>
@ -34,27 +34,35 @@ extern "C" __attribute__((visibility("default"))) int main(int, char**);
int main(int argc, char ** argv)
{
MApplication *app = MComponentCache::mApplication(argc, argv, "fala_ft_themetest");
MApplicationWindow *window = MComponentCache::mApplicationWindow();
MApplicationPage page;
page.setTitle("fala_ft_themetest");
MLayout *layout = new MLayout;
MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
policy->setSpacing(10);
MLabel *label = new MLabel(QString("Hello, themed world!"));
label->setObjectName("themedlabel");
label->setAlignment(Qt::AlignCenter);
policy->addItem(label);
label = new MLabel(QString("With sheep"));
label->setObjectName("themedlabelwithgraphics");
label->setAlignment(Qt::AlignLeft);
policy->addItem(label);
page.centralWidget()->setLayout(layout);
page.appear();
window->show();
MApplication *app;
try
{
MApplication *app = MComponentCache::mApplication(argc, argv, "fala_ft_themetest");
MApplicationWindow *window = MComponentCache::mApplicationWindow();
MApplicationPage page;
page.setTitle("fala_ft_themetest");
MLayout *layout = new MLayout;
MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
policy->setSpacing(10);
MLabel *label = new MLabel(QString("Hello, themed world!"));
label->setObjectName("themedlabel");
label->setAlignment(Qt::AlignCenter);
policy->addItem(label);
label = new MLabel(QString("With sheep"));
label->setObjectName("themedlabelwithgraphics");
label->setAlignment(Qt::AlignLeft);
policy->addItem(label);
page.centralWidget()->setLayout(layout);
page.appear();
window->show();
}
catch(std::exception& e)
{
return -1;
}
_exit(app->exec());
}

Loading…
Cancel
Save