Commit b4aa9ac9 authored by Victor Yacovlev's avatar Victor Yacovlev

Logging initialization state

parent f2e34619
...@@ -90,6 +90,13 @@ public: ...@@ -90,6 +90,13 @@ public:
try { try {
result = QApplication::notify(receiver, event); result = QApplication::notify(receiver, event);
} }
catch (const std::exception & ex) {
const std::string message =
std::string("Caught exception: ") + std::string(ex.what());
qDebug(message.c_str());
if (arguments().contains("--debug"))
abort();
}
catch (...) { catch (...) {
qDebug() << "Exception caught in QApplication::notify!!!"; qDebug() << "Exception caught in QApplication::notify!!!";
if (arguments().contains("--debug")) if (arguments().contains("--debug"))
...@@ -104,6 +111,7 @@ public: ...@@ -104,6 +111,7 @@ public:
inline void initialize() { inline void initialize() {
const QStringList arguments = QCoreApplication::instance()->arguments(); const QStringList arguments = QCoreApplication::instance()->arguments();
qDebug() << "Arguments: " << arguments;
bool mustShowHelpAndExit = false; bool mustShowHelpAndExit = false;
bool mustShowVersionAndExit = false; bool mustShowVersionAndExit = false;
for (int i=1; i<arguments.size(); i++) { for (int i=1; i<arguments.size(); i++) {
...@@ -135,7 +143,7 @@ public: ...@@ -135,7 +143,7 @@ public:
installTranslator(tr); installTranslator(tr);
} }
} }
qDebug() << "Loaded translator files";
setProperty("sharePath", sharePath); setProperty("sharePath", sharePath);
QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setDefaultFormat(QSettings::IniFormat);
...@@ -144,7 +152,7 @@ public: ...@@ -144,7 +152,7 @@ public:
manager->setPluginPath(PLUGINS_PATH); manager->setPluginPath(PLUGINS_PATH);
manager->setSharePath(sharePath); manager->setSharePath(sharePath);
QString error; QString error;
qDebug() << "Initialized plugin manager";
#ifdef CONFIGURATION_TEMPLATE #ifdef CONFIGURATION_TEMPLATE
const QString defaultTemplate = CONFIGURATION_TEMPLATE; const QString defaultTemplate = CONFIGURATION_TEMPLATE;
#else #else
...@@ -157,6 +165,7 @@ public: ...@@ -157,6 +165,7 @@ public:
templ = arg.mid(1, arg.length()-2); templ = arg.mid(1, arg.length()-2);
} }
} }
qDebug() << "Loading plugins by template: " << templ;
error = manager->loadPluginsByTemplate(templ); error = manager->loadPluginsByTemplate(templ);
if (!gui && manager->isGuiRequired()) { if (!gui && manager->isGuiRequired()) {
if (splashScreen_) if (splashScreen_)
...@@ -165,9 +174,9 @@ public: ...@@ -165,9 +174,9 @@ public:
exit(1); exit(1);
} }
qInstallMsgHandler(manager->isGuiRequired() // qInstallMsgHandler(manager->isGuiRequired()
? GuiMessageOutput // ? GuiMessageOutput
: ConsoleMessageOutput); // : ConsoleMessageOutput);
if (!error.isEmpty()) { if (!error.isEmpty()) {
if (splashScreen_) if (splashScreen_)
...@@ -176,6 +185,8 @@ public: ...@@ -176,6 +185,8 @@ public:
exit(1); exit(1);
} }
qDebug() << "Done loading all plugins by template";
if (mustShowHelpAndExit) { if (mustShowHelpAndExit) {
if (splashScreen_) if (splashScreen_)
splashScreen_->finish(0); splashScreen_->finish(0);
...@@ -194,8 +205,8 @@ public: ...@@ -194,8 +205,8 @@ public:
fprintf(stderr, "%s\n", qPrintable(applicationVersion())); fprintf(stderr, "%s\n", qPrintable(applicationVersion()));
exit(0); exit(0);
return; return;
} }
qDebug() << "Begin plugins initialization";
error = manager->initializePlugins(); error = manager->initializePlugins();
if (!error.isEmpty()) { if (!error.isEmpty()) {
if (splashScreen_) if (splashScreen_)
...@@ -206,6 +217,7 @@ public: ...@@ -206,6 +217,7 @@ public:
} }
// GUI requirement may be changed as result of plugins initialization, // GUI requirement may be changed as result of plugins initialization,
// so check it again // so check it again
qDebug() << "Plugins initialization done";
if (!gui && manager->isGuiRequired()) { if (!gui && manager->isGuiRequired()) {
showErrorMessage("Requires X11 session to run this configuration"); showErrorMessage("Requires X11 session to run this configuration");
exit(property("returnCode").isValid() exit(property("returnCode").isValid()
...@@ -213,6 +225,7 @@ public: ...@@ -213,6 +225,7 @@ public:
} }
if (splashScreen_) if (splashScreen_)
splashScreen_->finish(0); splashScreen_->finish(0);
qDebug() << "Starting entry point plugin";
error = manager->start(); error = manager->start();
if (!error.isEmpty()) { if (!error.isEmpty()) {
if (splashScreen_) if (splashScreen_)
...@@ -230,7 +243,9 @@ public: ...@@ -230,7 +243,9 @@ public:
if (!started_) { if (!started_) {
started_ = true; started_ = true;
killTimer(timerId_); killTimer(timerId_);
qDebug() << "Begin initialization";
initialize(); initialize();
qDebug() << "Initialization done";
} }
event->accept(); event->accept();
} }
...@@ -255,6 +270,7 @@ private: ...@@ -255,6 +270,7 @@ private:
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
qInstallMsgHandler(GuiMessageOutput);
QString gitHash = QString::fromAscii(GIT_HASH); QString gitHash = QString::fromAscii(GIT_HASH);
QString gitTag = QString::fromAscii(GIT_TAG); QString gitTag = QString::fromAscii(GIT_TAG);
QString gitBranch = QString::fromAscii(GIT_BRANCH); QString gitBranch = QString::fromAscii(GIT_BRANCH);
...@@ -329,7 +345,19 @@ int main(int argc, char **argv) ...@@ -329,7 +345,19 @@ int main(int argc, char **argv)
app->setSplashScreen(splashScreen); app->setSplashScreen(splashScreen);
} }
#endif #endif
int ret = app->main(); int ret = 0;
try {
ret = app->main();
}
catch (const std::exception & ex) {
const std::string message =
std::string("Caught exception: ") + std::string(ex.what());
qFatal(message.c_str());
}
catch (...) {
qFatal("Caught an exception");
}
ExtensionSystem::PluginManager::destroy(); ExtensionSystem::PluginManager::destroy();
delete app; delete app;
return ret; return ret;
......
...@@ -114,10 +114,11 @@ QString PluginManager::loadPluginsByTemplate(const QString &templ) ...@@ -114,10 +114,11 @@ QString PluginManager::loadPluginsByTemplate(const QString &templ)
QString error = ""; QString error = "";
error = pImpl_->parsePluginsRequest(templ, requests, names); error = pImpl_->parsePluginsRequest(templ, requests, names);
if (!error.isEmpty()) if (!error.isEmpty())
return error; return error;
//QScriptEngine engine; //QScriptEngine engine;
//engine.evaluate("var data = null;\n"); //engine.evaluate("var data = null;\n");
//error = d->loadSpecs(names, &engine); //error = d->loadSpecs(names, &engine);
qDebug() << "Loading plugin spec files for: " << names;
error = pImpl_->loadSpecs(names); error = pImpl_->loadSpecs(names);
if (!error.isEmpty()) if (!error.isEmpty())
return error; return error;
...@@ -155,7 +156,8 @@ QString PluginManager::loadPluginsByTemplate(const QString &templ) ...@@ -155,7 +156,8 @@ QString PluginManager::loadPluginsByTemplate(const QString &templ)
// orderedList will contain names in order of load and initialization // orderedList will contain names in order of load and initialization
QStringList orderedList; QStringList orderedList;
// make dependencies for entry point plugin first // make dependencies for entry point plugin first
error = pImpl_->makeDependencies(pImpl_->mainPluginName,orderedList); qDebug() << "Reordering plugin load order and building dependencies...";
error = pImpl_->makeDependencies(pImpl_->mainPluginName,orderedList);
if (!error.isEmpty()) if (!error.isEmpty())
return error; return error;
// make dependencies for other requests // make dependencies for other requests
...@@ -167,9 +169,12 @@ QString PluginManager::loadPluginsByTemplate(const QString &templ) ...@@ -167,9 +169,12 @@ QString PluginManager::loadPluginsByTemplate(const QString &templ)
error = pImpl_->reorderSpecsAndCreateStates(orderedList); error = pImpl_->reorderSpecsAndCreateStates(orderedList);
if (!error.isEmpty()) if (!error.isEmpty())
return error; return error;
qDebug() << "New plugin load ordered list: " << orderedList;
qDebug() << "Begin loading plugins";
error = pImpl_->loadPlugins(); error = pImpl_->loadPlugins();
if (!error.isEmpty()) if (!error.isEmpty())
return error; return error;
qDebug() << "Done loading plugins";
pImpl_->requests = requests; pImpl_->requests = requests;
return ""; return "";
} }
...@@ -360,12 +365,15 @@ QString PluginManager::initializePlugins() ...@@ -360,12 +365,15 @@ QString PluginManager::initializePlugins()
error += tr("Run with --help for more details.\n"); error += tr("Run with --help for more details.\n");
return error; return error;
} }
qDebug() << "Begin initialization of plugin " <<
pImpl_->specs[i].name << " with parameters " << arguments;
QString error = pImpl_->objects[i]->initialize(arguments, runtimeParameters); QString error = pImpl_->objects[i]->initialize(arguments, runtimeParameters);
if (!error.isEmpty()) { if (!error.isEmpty()) {
return QString("Error initializing %1: %2") return QString("Error initializing %1: %2")
.arg(name) .arg(name)
.arg(error); .arg(error);
} }
qDebug() << "Plugin initialization done";
pImpl_->states[i] = KPlugin::Initialized; pImpl_->states[i] = KPlugin::Initialized;
} }
......
...@@ -58,6 +58,7 @@ QString PluginManagerImpl::loadPlugins() ...@@ -58,6 +58,7 @@ QString PluginManagerImpl::loadPlugins()
{ {
for (int i=0; i<specs.size(); i++) { for (int i=0; i<specs.size(); i++) {
QPluginLoader loader(specs[i].libraryFileName); QPluginLoader loader(specs[i].libraryFileName);
qDebug() << "Loading " << specs[i].libraryFileName << "...";
// qDebug()<<specs[i].libraryFileName; // qDebug()<<specs[i].libraryFileName;
if (!loader.load()) { if (!loader.load()) {
return QString("Can't load module %1: %2") return QString("Can't load module %1: %2")
...@@ -73,6 +74,7 @@ QString PluginManagerImpl::loadPlugins() ...@@ -73,6 +74,7 @@ QString PluginManagerImpl::loadPlugins()
states[i] = KPlugin::Loaded; states[i] = KPlugin::Loaded;
settings[i] = SettingsPtr(new Settings(specs[i].name)); settings[i] = SettingsPtr(new Settings(specs[i].name));
plugin->updateSettings(QStringList()); plugin->updateSettings(QStringList());
qDebug() << "Loading done";
} }
return ""; return "";
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment