mirror of https://github.com/cutefishos/appmotor
				
				
				
			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 changespull/1/head
							parent
							
								
									7c8c2decd1
								
							
						
					
					
						commit
						ba085e6a5a
					
				@ -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
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue