forked from openkylin/ukui-search
[FIX] Updating status with QSettings will get stuck sometimes.
This commit is contained in:
parent
051447ec82
commit
fbb15e4a14
|
@ -35,8 +35,9 @@ GlobalSettings *GlobalSettings::getInstance()
|
||||||
|
|
||||||
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_settings = new QSettings("org.ukui", "ukui-search", this);
|
m_settings = new QSettings("org.ukui/ukui-search", "ukui-search", this);
|
||||||
m_block_dirs_settings = new QSettings("org.ukui","ukui-search-block-dirs",this);
|
// m_settings->setAtomicSyncRequired(false);
|
||||||
|
m_block_dirs_settings = new QSettings("org.ukui/ukui-search","ukui-search-block-dirs",this);
|
||||||
m_block_dirs_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
m_block_dirs_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
this->forceSync();
|
this->forceSync();
|
||||||
//the default number of transparency in mainwindow is 0.7
|
//the default number of transparency in mainwindow is 0.7
|
||||||
|
@ -58,7 +59,6 @@ GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||||
|
|
||||||
GlobalSettings::~GlobalSettings()
|
GlobalSettings::~GlobalSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVariant GlobalSettings::getValue(const QString &key)
|
const QVariant GlobalSettings::getValue(const QString &key)
|
||||||
|
@ -75,11 +75,11 @@ void GlobalSettings::reset(const QString &key)
|
||||||
{
|
{
|
||||||
m_cache.remove(key);
|
m_cache.remove(key);
|
||||||
QtConcurrent::run([=]() {
|
QtConcurrent::run([=]() {
|
||||||
if (m_mutex.tryLock(1000)) {
|
// if (m_mutex.tryLock(1000)) {
|
||||||
m_settings->remove(key);
|
m_settings->remove(key);
|
||||||
m_settings->sync();
|
// m_settings->sync();
|
||||||
m_mutex.unlock();
|
// m_mutex.unlock();
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
Q_EMIT this->valueChanged(key);
|
Q_EMIT this->valueChanged(key);
|
||||||
}
|
}
|
||||||
|
@ -149,14 +149,19 @@ QStringList GlobalSettings::getBlockDirs()
|
||||||
//MouseZhangZh
|
//MouseZhangZh
|
||||||
void GlobalSettings::setValue(const QString &key, const QVariant &value)
|
void GlobalSettings::setValue(const QString &key, const QVariant &value)
|
||||||
{
|
{
|
||||||
|
// qDebug()<<"setvalue========"<<key<<":"<<value;
|
||||||
m_cache.insert(key, value);
|
m_cache.insert(key, value);
|
||||||
|
// m_settings->sync();
|
||||||
QtConcurrent::run([=]() {
|
QtConcurrent::run([=]() {
|
||||||
// if (m_mutex.tryLock(1000)) {
|
// qDebug()<<m_settings->status();
|
||||||
m_mutex.lock();
|
// if (m_mutex.tryLock(1000)) {
|
||||||
m_settings->setValue(key, value);
|
// m_mutex.lock();
|
||||||
m_settings->sync();
|
m_settings->setValue(key, value);
|
||||||
m_mutex.unlock();
|
// qDebug()<<"setvalue========finish!!!"<<key<<":"<<value;
|
||||||
// }
|
m_settings->sync();
|
||||||
|
// qDebug()<<"setvalue========sync!!!"<<key<<":"<<value;
|
||||||
|
// m_mutex.unlock();
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,7 @@ void FirstIndex::run(){
|
||||||
if (p_indexGenerator)
|
if (p_indexGenerator)
|
||||||
delete p_indexGenerator;
|
delete p_indexGenerator;
|
||||||
p_indexGenerator = nullptr;
|
p_indexGenerator = nullptr;
|
||||||
|
GlobalSettings::getInstance()->forceSync();
|
||||||
::_exit(0);
|
::_exit(0);
|
||||||
}
|
}
|
||||||
else if(pid < 0)
|
else if(pid < 0)
|
||||||
|
@ -182,13 +183,14 @@ void FirstIndex::run(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "2");
|
||||||
int retval = write(fifo_fd, buffer, strlen(buffer));
|
int retval = write(fifo_fd, buffer, strlen(buffer));
|
||||||
if(retval == -1)
|
if(retval == -1)
|
||||||
{
|
{
|
||||||
qWarning("write error\n");
|
qWarning("write error\n");
|
||||||
}
|
}
|
||||||
qDebug("write data ok!\n");
|
qDebug("write data ok!\n");
|
||||||
GlobalSettings::getInstance()->reset(INOTIFY_NORMAL_EXIT);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,6 +420,7 @@ fork:
|
||||||
qDebug() << "select timeout!";
|
qDebug() << "select timeout!";
|
||||||
::free(read_timeout);
|
::free(read_timeout);
|
||||||
IndexGenerator::getInstance()->~IndexGenerator();
|
IndexGenerator::getInstance()->~IndexGenerator();
|
||||||
|
GlobalSettings::getInstance()->forceSync();
|
||||||
::_exit(0);
|
::_exit(0);
|
||||||
}else{
|
}else{
|
||||||
GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "0");
|
GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "0");
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "config-file.h"
|
#include "config-file.h"
|
||||||
|
|
||||||
bool ConfigFile::writeCommonly(QString message){
|
bool ConfigFile::writeCommonly(QString message){
|
||||||
QSettings *m_qSettings=new QSettings(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf",QSettings::IniFormat);
|
QSettings *m_qSettings=new QSettings(HOMEPAGE_SETTINGS,QSettings::IniFormat);
|
||||||
QStringList messagelist=message.split("/");
|
QStringList messagelist=message.split("/");
|
||||||
QString appname=messagelist.last();
|
QString appname=messagelist.last();
|
||||||
if(!appname.contains("desktop"))
|
if(!appname.contains("desktop"))
|
||||||
|
@ -39,7 +39,7 @@ bool ConfigFile::writeCommonly(QString message){
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ConfigFile::readCommonly(){
|
QStringList ConfigFile::readCommonly(){
|
||||||
QSettings *m_qSettings=new QSettings(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf",QSettings::IniFormat);
|
QSettings *m_qSettings=new QSettings(HOMEPAGE_SETTINGS,QSettings::IniFormat);
|
||||||
QStringList returnlist;
|
QStringList returnlist;
|
||||||
QMap<QString,int> quicklycount;
|
QMap<QString,int> quicklycount;
|
||||||
m_qSettings->beginGroup("Commonly");
|
m_qSettings->beginGroup("Commonly");
|
||||||
|
@ -66,7 +66,7 @@ QStringList ConfigFile::readCommonly(){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigFile::writeRecently(QString message){
|
bool ConfigFile::writeRecently(QString message){
|
||||||
QSettings *m_qSettings=new QSettings(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf",QSettings::IniFormat);
|
QSettings *m_qSettings=new QSettings(HOMEPAGE_SETTINGS,QSettings::IniFormat);
|
||||||
|
|
||||||
m_qSettings->beginGroup("Recently");
|
m_qSettings->beginGroup("Recently");
|
||||||
QStringList recently=m_qSettings->value("Recently").toStringList();
|
QStringList recently=m_qSettings->value("Recently").toStringList();
|
||||||
|
@ -89,7 +89,7 @@ bool ConfigFile::writeRecently(QString message){
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ConfigFile::readRecently(){
|
QStringList ConfigFile::readRecently(){
|
||||||
QSettings *m_qSettings=new QSettings(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf",QSettings::IniFormat);
|
QSettings *m_qSettings=new QSettings(HOMEPAGE_SETTINGS,QSettings::IniFormat);
|
||||||
|
|
||||||
m_qSettings->beginGroup("Recently");
|
m_qSettings->beginGroup("Recently");
|
||||||
QStringList recently=m_qSettings->value("Recently").toStringList();
|
QStringList recently=m_qSettings->value("Recently").toStringList();
|
||||||
|
@ -113,7 +113,7 @@ QMap<QString,QStringList> ConfigFile::readConfig(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigFile::receiveMessage(QString message){
|
void ConfigFile::receiveMessage(QString message){
|
||||||
QFile file(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf");
|
QFile file(HOMEPAGE_SETTINGS);
|
||||||
if(!file.exists()){
|
if(!file.exists()){
|
||||||
file.open( QIODevice::ReadWrite | QIODevice::Text );
|
file.open( QIODevice::ReadWrite | QIODevice::Text );
|
||||||
file.close();
|
file.close();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#define HOMEPAGE_SETTINGS QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search-homepage.conf"
|
||||||
class ConfigFile : public QObject
|
class ConfigFile : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -72,6 +72,7 @@ void messageOutput(QtMsgType type, const QMessageLogContext &context, const QStr
|
||||||
|
|
||||||
bool showDebug = true;
|
bool showDebug = true;
|
||||||
// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/ukui-search.log";
|
// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/ukui-search.log";
|
||||||
|
// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search/ukui-search.log";
|
||||||
QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search.log";
|
QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search.log";
|
||||||
if (!QFile::exists(logFilePath)) {
|
if (!QFile::exists(logFilePath)) {
|
||||||
showDebug = false;
|
showDebug = false;
|
||||||
|
|
Loading…
Reference in New Issue