From 021c142ceeb2e445fcf8394c942688c44f000f0d Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 14 Apr 2016 14:24:56 +0200 Subject: [PATCH] Small fixes for porting recent changes to windows --- src/common/rclinit.cpp | 4 +++- src/qtgui/recoll-win.pro | 3 +++ src/qtgui/webcache.cpp | 12 ++++++++---- src/utils/circache.cpp | 2 +- src/utils/cpuconf.cpp | 37 ++++++++++++++++++++++++++++++++----- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/common/rclinit.cpp b/src/common/rclinit.cpp index 97a08fed..c3704c7e 100644 --- a/src/common/rclinit.cpp +++ b/src/common/rclinit.cpp @@ -337,7 +337,9 @@ RclConfig *recollinit(RclInitFlags flags, // Keep threads init behind log init, but make sure it's done before // we do the vfork choice ! The latter is not used any more actually, // we always use vfork except if forbidden by config. - config->initThrConf(); + if ((flags & RCLINIT_IDX)) { + config->initThrConf(); + } bool novfork; config->getConfParam("novfork", &novfork); diff --git a/src/qtgui/recoll-win.pro b/src/qtgui/recoll-win.pro index ad8419a5..487fba3f 100644 --- a/src/qtgui/recoll-win.pro +++ b/src/qtgui/recoll-win.pro @@ -45,6 +45,7 @@ HEADERS += \ systray.h \ uiprefs_w.h \ viewaction_w.h \ + webcache.h SOURCES += \ advsearch_w.cpp \ @@ -79,6 +80,7 @@ SOURCES += \ systray.cpp \ uiprefs_w.cpp \ viewaction_w.cpp \ + webcache.cpp \ widgets/qxtconfirmationmessage.cpp \ xmltosd.cpp @@ -99,6 +101,7 @@ FORMS = \ ssearchb.ui \ uiprefs.ui \ viewaction.ui \ + webcache.ui RESOURCES = recoll.qrc diff --git a/src/qtgui/webcache.cpp b/src/qtgui/webcache.cpp index ceac8275..b9d9a53c 100644 --- a/src/qtgui/webcache.cpp +++ b/src/qtgui/webcache.cpp @@ -21,6 +21,10 @@ #include MEMORY_INCLUDE #include UNORDERED_MAP_INCLUDE +#ifdef _WIN32 +#define USING_STD_REGEX +#endif + #ifndef USING_STD_REGEX #include #include @@ -99,7 +103,7 @@ void WebcacheModel::reload() break; } } - emit dataChanged(createIndex(0,0,0), createIndex(1, m->all.size(),0)); + emit dataChanged(createIndex(0,0), createIndex(1, m->all.size())); } bool WebcacheModel::deleteIdx(unsigned int idx) @@ -194,9 +198,9 @@ void WebcacheModel::setSearchFilter(const QString& _txt) return; } #else - basic_regex exp; + basic_regex exp; try { - exp = basic_regexp(txt, std::regex_constants::nosubs | + exp = basic_regex(txt, std::regex_constants::nosubs | std::regex_constants::extended); } catch(...) { return; @@ -212,7 +216,7 @@ void WebcacheModel::setSearchFilter(const QString& _txt) // m->all[i].url.c_str(); } } - emit dataChanged(createIndex(0,0,0), createIndex(1, m->all.size(),0)); + emit dataChanged(createIndex(0,0), createIndex(1, m->all.size())); } static const int ROWHEIGHTPAD = 2; diff --git a/src/utils/circache.cpp b/src/utils/circache.cpp index bcd66d6a..08b148a5 100644 --- a/src/utils/circache.cpp +++ b/src/utils/circache.cpp @@ -466,7 +466,7 @@ public: return false; } string buf(d.padsize, ' '); - if (write(m_fd, buf.c_str(), d.padsize) != d.padsize) { + if (write(m_fd, buf.c_str(), d.padsize) != (ssize_t)d.padsize) { m_reason << "CirCache::weh: write failed. errno " << errno; return false; } diff --git a/src/utils/cpuconf.cpp b/src/utils/cpuconf.cpp index c715a1b5..e17674e5 100644 --- a/src/utils/cpuconf.cpp +++ b/src/utils/cpuconf.cpp @@ -14,21 +14,21 @@ * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #ifndef TEST_CPUCONF #include "autoconfig.h" +#include "cpuconf.h" + +#if defined(__gnu_linux__) #include - -#include "cpuconf.h" #include "execmd.h" #include "smallut.h" using std::string; using std::vector; -#if defined(__gnu_linux__) +// It seems that we could use sysconf as on macosx actually bool getCpuConf(CpuConf& conf) { vector cmdv = create_vector("sh")("-c") @@ -56,8 +56,35 @@ bool getCpuConf(CpuConf& conf) conf.ncpus = 1; return true; } -//#elif defined(__APPLE__) +#elif 0 && defined(_WIN32) +// On windows, indexing is actually twice slower with threads enabled + +// there is a bug and the process does not exit at the end of indexing. +// Until these are solved, pretend there is only 1 cpu +#include +bool getCpuConf(CpuConf& cpus) +{ +#if 0 + // Native way + SYSTEM_INFO sysinfo; + GetSystemInfo( &sysinfo ); + cpus.ncpus = sysinfo.dwNumberOfProcessors; +#else + // c++11 + cpus.ncpus = std::thread::hardware_concurrency(); +#endif + return true; +} + +#elif defined(__APPLE__) + +#include +bool getCpuConf(CpuConf& cpus) +{ + cpus.ncpus = sysconf( _SC_NPROCESSORS_ONLN ); + return true; +} + #else // Any other system // Generic, pretend there is one