Fixes: NB#191847 - First application launched with m-booster after theme change crashes

RevBy: Jussi Lind

Details: m and w boosters are killed and restarted when language or
theme changes
pull/1/head
Antti Kervinen 15 years ago
parent 7c8c2decd1
commit ba085e6a5a

@ -4,17 +4,19 @@ include(${QT_USE_FILE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common)
# Set sources
set(SRC appdata.cpp booster.cpp boosterfactory.cpp connection.cpp daemon.cpp mbooster.cpp logger.cpp main.cpp qtbooster.cpp wrtbooster.cpp)
set(SRC appdata.cpp booster.cpp boosterfactory.cpp boosterkiller.cpp connection.cpp daemon.cpp mbooster.cpp logger.cpp main.cpp qtbooster.cpp wrtbooster.cpp)
set(MOC_HDRS boosterkiller.h)
qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})
# Find libdl
find_library(LIBDL NAMES dl)
# Set libraries to be linked. Shared libraries to be preloaded are not linked in anymore,
# but dlopen():ed and listed in src/launcher/preload.h instead.
link_libraries(${MEEGOTOUCH_LIBRARIES} ${LIBDL})
link_libraries(${MEEGOTOUCH_LIBRARIES} ${LIBDL} ${QT_QTCORE_LIBRARY})
# Set executable
add_executable(applauncherd.bin ${SRC})
add_executable(applauncherd.bin ${SRC} ${MOC_SRC})
# Add install rule
install(PROGRAMS applauncherd.bin scripts/applauncherd DESTINATION /usr/bin/)

@ -0,0 +1,33 @@
#include <QString>
#include <QCoreApplication>
#include <QObject>
#include <MGConfItem>
#include "boosterkiller.h"
#include <cstdlib>
void BoosterKiller::addKey(const QString & key)
{
MGConfItem *item = new MGConfItem(key, 0);
QObject::connect(item, SIGNAL(valueChanged()),
this, SLOT(killProcesses()));
}
void BoosterKiller::addProcessName(const QString & processName)
{
processNames << processName;
}
void BoosterKiller::start()
{
int argc = 0;
//char **argv = 0;
QCoreApplication(argc, 0).exec();
}
void BoosterKiller::killProcesses()
{
Q_FOREACH(QString processName, processNames) {
system( (QString("pkill ") + processName).toStdString().c_str() );
}
}

@ -0,0 +1,35 @@
#ifndef BOOSTERKILLER_H
#define BOOSTERKILLER_H
#include <QObject>
#include <QStringList>
class QString;
class MGConfItem;
class BoosterKiller: public QObject
{
Q_OBJECT
public:
/* Add a GConf key and the name of the process that should be
killed in case the value associated to the key is changed.
*/
void addKey(const QString & key);
void addProcessName(const QString & processName);
/* Starts the killer. This will initialize qcoreapplication, does
not return.
*/
void start();
private slots:
void killProcesses();
private:
QList<MGConfItem*> gconfItems;
QStringList processNames;
};
#endif

@ -25,6 +25,7 @@
#include "qtbooster.h"
#include "wrtbooster.h"
#include "boosterfactory.h"
#include "boosterkiller.h"
#include "preload.h"
@ -154,6 +155,8 @@ void Daemon::run()
// load and resolve all undefined symbols for each dynamic library from the list
preload();
forkKiller();
// Create sockets for each of the boosters
Connection::initSocket(MBooster::socketName());
Connection::initSocket(QtBooster::socketName());
@ -206,6 +209,22 @@ void Daemon::run()
}
}
bool Daemon::forkKiller()
{
pid_t pid = fork();
if (pid == -1)
Logger::logErrorAndDie(EXIT_FAILURE, "Daemon: Forking killer process failed.");
if (pid == 0) { // child
// If theme or language changes, reset boosters
BoosterKiller bk;
bk.addKey("/meegotouch/theme/name");
bk.addKey("/meegotouch/i18n/language");
bk.addProcessName("booster-m");
bk.addProcessName("booster-w");
bk.start(); // does not return.
}
}
bool Daemon::forkBooster(char type, int sleepTime)
{
// Fork a new process

@ -95,6 +95,9 @@ private:
//! Fork to a daemon
void daemonize();
//! Fork process that kills boosters if needed
bool forkKiller();
//! Forks and initializes a new Booster
bool forkBooster(char type, int sleepTime = 0);

Loading…
Cancel
Save