[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)
|
||||
{
|
||||
m_settings = new QSettings("org.ukui", "ukui-search", this);
|
||||
m_block_dirs_settings = new QSettings("org.ukui","ukui-search-block-dirs",this);
|
||||
m_settings = new QSettings("org.ukui/ukui-search", "ukui-search", 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"));
|
||||
this->forceSync();
|
||||
//the default number of transparency in mainwindow is 0.7
|
||||
|
@ -58,7 +59,6 @@ GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
|||
|
||||
GlobalSettings::~GlobalSettings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const QVariant GlobalSettings::getValue(const QString &key)
|
||||
|
@ -75,11 +75,11 @@ void GlobalSettings::reset(const QString &key)
|
|||
{
|
||||
m_cache.remove(key);
|
||||
QtConcurrent::run([=]() {
|
||||
if (m_mutex.tryLock(1000)) {
|
||||
// if (m_mutex.tryLock(1000)) {
|
||||
m_settings->remove(key);
|
||||
m_settings->sync();
|
||||
m_mutex.unlock();
|
||||
}
|
||||
// m_settings->sync();
|
||||
// m_mutex.unlock();
|
||||
// }
|
||||
});
|
||||
Q_EMIT this->valueChanged(key);
|
||||
}
|
||||
|
@ -149,14 +149,19 @@ QStringList GlobalSettings::getBlockDirs()
|
|||
//MouseZhangZh
|
||||
void GlobalSettings::setValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
// qDebug()<<"setvalue========"<<key<<":"<<value;
|
||||
m_cache.insert(key, value);
|
||||
// m_settings->sync();
|
||||
QtConcurrent::run([=]() {
|
||||
// if (m_mutex.tryLock(1000)) {
|
||||
m_mutex.lock();
|
||||
m_settings->setValue(key, value);
|
||||
m_settings->sync();
|
||||
m_mutex.unlock();
|
||||
// }
|
||||
// qDebug()<<m_settings->status();
|
||||
// if (m_mutex.tryLock(1000)) {
|
||||
// m_mutex.lock();
|
||||
m_settings->setValue(key, value);
|
||||
// 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)
|
||||
delete p_indexGenerator;
|
||||
p_indexGenerator = nullptr;
|
||||
GlobalSettings::getInstance()->forceSync();
|
||||
::_exit(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));
|
||||
if(retval == -1)
|
||||
{
|
||||
qWarning("write error\n");
|
||||
}
|
||||
qDebug("write data ok!\n");
|
||||
GlobalSettings::getInstance()->reset(INOTIFY_NORMAL_EXIT);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
|
|
@ -420,6 +420,7 @@ fork:
|
|||
qDebug() << "select timeout!";
|
||||
::free(read_timeout);
|
||||
IndexGenerator::getInstance()->~IndexGenerator();
|
||||
GlobalSettings::getInstance()->forceSync();
|
||||
::_exit(0);
|
||||
}else{
|
||||
GlobalSettings::getInstance()->setValue(INOTIFY_NORMAL_EXIT, "0");
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "config-file.h"
|
||||
|
||||
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("/");
|
||||
QString appname=messagelist.last();
|
||||
if(!appname.contains("desktop"))
|
||||
|
@ -39,7 +39,7 @@ bool ConfigFile::writeCommonly(QString message){
|
|||
}
|
||||
|
||||
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;
|
||||
QMap<QString,int> quicklycount;
|
||||
m_qSettings->beginGroup("Commonly");
|
||||
|
@ -66,7 +66,7 @@ QStringList ConfigFile::readCommonly(){
|
|||
}
|
||||
|
||||
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");
|
||||
QStringList recently=m_qSettings->value("Recently").toStringList();
|
||||
|
@ -89,7 +89,7 @@ bool ConfigFile::writeRecently(QString message){
|
|||
}
|
||||
|
||||
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");
|
||||
QStringList recently=m_qSettings->value("Recently").toStringList();
|
||||
|
@ -113,7 +113,7 @@ QMap<QString,QStringList> ConfigFile::readConfig(){
|
|||
}
|
||||
|
||||
void ConfigFile::receiveMessage(QString message){
|
||||
QFile file(QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search.conf");
|
||||
QFile file(HOMEPAGE_SETTINGS);
|
||||
if(!file.exists()){
|
||||
file.open( QIODevice::ReadWrite | QIODevice::Text );
|
||||
file.close();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#define HOMEPAGE_SETTINGS QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search-homepage.conf"
|
||||
class ConfigFile : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -72,6 +72,7 @@ void messageOutput(QtMsgType type, const QMessageLogContext &context, const QStr
|
|||
|
||||
bool showDebug = true;
|
||||
// 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";
|
||||
if (!QFile::exists(logFilePath)) {
|
||||
showDebug = false;
|
||||
|
|
Loading…
Reference in New Issue