update languages, fix recent PR compilation error
This commit is contained in:
parent
edad7fad32
commit
c83ab230f9
File diff suppressed because it is too large
Load Diff
@ -195,6 +195,7 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
|||||||
? feed_lookup.custom_data[QSL("postProcessScript")].toString()
|
? feed_lookup.custom_data[QSL("postProcessScript")].toString()
|
||||||
: feed_lookup.post_process_script;
|
: feed_lookup.post_process_script;
|
||||||
|
|
||||||
|
try {
|
||||||
new_feed = StandardFeed::guessFeed(source_type,
|
new_feed = StandardFeed::guessFeed(source_type,
|
||||||
feed_lookup.url,
|
feed_lookup.url,
|
||||||
pp_script,
|
pp_script,
|
||||||
@ -227,55 +228,20 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
if (feed_lookup.add_errored_feeds) {
|
||||||
|
// Feed guessing failed, add like regular feed anyway.
|
||||||
|
new_feed = new StandardFeed();
|
||||||
|
fillFeedFromFeedLookupData(new_feed, feed_lookup);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
new_feed = new StandardFeed();
|
new_feed = new StandardFeed();
|
||||||
|
fillFeedFromFeedLookupData(new_feed, feed_lookup);
|
||||||
if (feed_lookup.custom_data.isEmpty()) {
|
|
||||||
// We assume these are "best-guess" defaults.
|
|
||||||
new_feed->setSourceType(StandardFeed::SourceType::Url);
|
|
||||||
new_feed->setType(StandardFeed::Type::Rss2X);
|
|
||||||
|
|
||||||
new_feed->setSource(feed_lookup.url);
|
|
||||||
new_feed->setTitle(feed_lookup.url);
|
|
||||||
new_feed->setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
|
|
||||||
new_feed->setEncoding(QSL(DEFAULT_FEED_ENCODING));
|
|
||||||
new_feed->setPostProcessScript(feed_lookup.post_process_script);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QString feed_title = feed_lookup.custom_data[QSL("title")].toString();
|
|
||||||
QString feed_encoding = feed_lookup.custom_data.value(QSL("encoding"), QSL(DEFAULT_FEED_ENCODING)).toString();
|
|
||||||
QString feed_type = feed_lookup.custom_data.value(QSL("type"), QSL(DEFAULT_FEED_TYPE)).toString().toUpper();
|
|
||||||
QString feed_description = feed_lookup.custom_data[QSL("description")].toString();
|
|
||||||
QIcon feed_icon = feed_lookup.custom_data[QSL("icon")].value<QIcon>();
|
|
||||||
StandardFeed::SourceType source_type =
|
|
||||||
feed_lookup.custom_data[QSL("sourceType")].value<StandardFeed::SourceType>();
|
|
||||||
QString post_process = feed_lookup.custom_data[QSL("postProcessScript")].toString();
|
|
||||||
|
|
||||||
new_feed->setTitle(feed_title);
|
|
||||||
new_feed->setDescription(feed_description);
|
|
||||||
new_feed->setEncoding(feed_encoding);
|
|
||||||
new_feed->setSource(feed_lookup.url);
|
|
||||||
new_feed->setSourceType(source_type);
|
|
||||||
new_feed->setPostProcessScript(feed_lookup.post_process_script.isEmpty() ? post_process
|
|
||||||
: feed_lookup.post_process_script);
|
|
||||||
|
|
||||||
if (!feed_icon.isNull()) {
|
|
||||||
new_feed->setIcon(feed_icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (feed_type == QL1S("RSS1")) {
|
|
||||||
new_feed->setType(StandardFeed::Type::Rdf);
|
|
||||||
}
|
|
||||||
else if (feed_type == QL1S("JSON")) {
|
|
||||||
new_feed->setType(StandardFeed::Type::Json);
|
|
||||||
}
|
|
||||||
else if (feed_type == QL1S("ATOM")) {
|
|
||||||
new_feed->setType(StandardFeed::Type::Atom10);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
new_feed->setType(StandardFeed::Type::Rss2X);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutexLocker mtx(&m_mtxLookup);
|
QMutexLocker mtx(&m_mtxLookup);
|
||||||
@ -295,6 +261,53 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FeedsImportExportModel::fillFeedFromFeedLookupData(StandardFeed* feed, const FeedLookup& feed_lookup) {
|
||||||
|
if (feed_lookup.custom_data.isEmpty()) {
|
||||||
|
// We assume these are "best-guess" defaults.
|
||||||
|
feed->setSourceType(StandardFeed::SourceType::Url);
|
||||||
|
feed->setType(StandardFeed::Type::Rss2X);
|
||||||
|
feed->setSource(feed_lookup.url);
|
||||||
|
feed->setTitle(feed_lookup.url);
|
||||||
|
feed->setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
|
||||||
|
feed->setEncoding(QSL(DEFAULT_FEED_ENCODING));
|
||||||
|
feed->setPostProcessScript(feed_lookup.post_process_script);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QString feed_title = feed_lookup.custom_data[QSL("title")].toString();
|
||||||
|
QString feed_encoding = feed_lookup.custom_data.value(QSL("encoding"), QSL(DEFAULT_FEED_ENCODING)).toString();
|
||||||
|
QString feed_type = feed_lookup.custom_data.value(QSL("type"), QSL(DEFAULT_FEED_TYPE)).toString().toUpper();
|
||||||
|
QString feed_description = feed_lookup.custom_data[QSL("description")].toString();
|
||||||
|
QIcon feed_icon = feed_lookup.custom_data[QSL("icon")].value<QIcon>();
|
||||||
|
StandardFeed::SourceType source_type = feed_lookup.custom_data[QSL("sourceType")].value<StandardFeed::SourceType>();
|
||||||
|
QString post_process = feed_lookup.custom_data[QSL("postProcessScript")].toString();
|
||||||
|
|
||||||
|
feed->setTitle(feed_title);
|
||||||
|
feed->setDescription(feed_description);
|
||||||
|
feed->setEncoding(feed_encoding);
|
||||||
|
feed->setSource(feed_lookup.url);
|
||||||
|
feed->setSourceType(source_type);
|
||||||
|
feed->setPostProcessScript(feed_lookup.post_process_script.isEmpty() ? post_process
|
||||||
|
: feed_lookup.post_process_script);
|
||||||
|
|
||||||
|
if (!feed_icon.isNull()) {
|
||||||
|
feed->setIcon(feed_icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (feed_type == QL1S("RSS1")) {
|
||||||
|
feed->setType(StandardFeed::Type::Rdf);
|
||||||
|
}
|
||||||
|
else if (feed_type == QL1S("JSON")) {
|
||||||
|
feed->setType(StandardFeed::Type::Json);
|
||||||
|
}
|
||||||
|
else if (feed_type == QL1S("ATOM")) {
|
||||||
|
feed->setType(StandardFeed::Type::Atom10);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
feed->setType(StandardFeed::Type::Rss2X);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FeedsImportExportModel::importAsOPML20(const QByteArray& data,
|
void FeedsImportExportModel::importAsOPML20(const QByteArray& data,
|
||||||
bool fetch_metadata_online,
|
bool fetch_metadata_online,
|
||||||
bool do_not_fetch_titles,
|
bool do_not_fetch_titles,
|
||||||
|
@ -19,6 +19,7 @@ struct FeedLookup {
|
|||||||
bool fetch_metadata_online;
|
bool fetch_metadata_online;
|
||||||
bool do_not_fetch_titles;
|
bool do_not_fetch_titles;
|
||||||
bool do_not_fetch_icons;
|
bool do_not_fetch_icons;
|
||||||
|
bool add_errored_feeds;
|
||||||
QNetworkProxy custom_proxy;
|
QNetworkProxy custom_proxy;
|
||||||
QString post_process_script;
|
QString post_process_script;
|
||||||
};
|
};
|
||||||
@ -62,6 +63,8 @@ class FeedsImportExportModel : public AccountCheckSortedModel {
|
|||||||
private:
|
private:
|
||||||
bool produceFeed(const FeedLookup& feed_lookup);
|
bool produceFeed(const FeedLookup& feed_lookup);
|
||||||
|
|
||||||
|
void fillFeedFromFeedLookupData(StandardFeed* feed, const FeedLookup& feed_lookup);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StandardServiceRoot* m_account;
|
StandardServiceRoot* m_account;
|
||||||
QMutex m_mtxLookup;
|
QMutex m_mtxLookup;
|
||||||
|
@ -155,9 +155,9 @@ void FeedDownloader::updateFeeds(const QList<Feed*>& feeds) {
|
|||||||
|
|
||||||
std::function<FeedUpdateResult(const FeedUpdateRequest&)> func =
|
std::function<FeedUpdateResult(const FeedUpdateRequest&)> func =
|
||||||
[=](const FeedUpdateRequest& fd) -> FeedUpdateResult {
|
[=](const FeedUpdateRequest& fd) -> FeedUpdateResult {
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
setThreadPriority(Priority::LOWEST);
|
setThreadPriority(Priority::Lowest);
|
||||||
#endif
|
#endif
|
||||||
return updateThreadedFeed(fd);
|
return updateThreadedFeed(fd);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -437,8 +437,7 @@ void FeedDownloader::updateOneFeed(ServiceRoot* acc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedDownloader::finalizeUpdate() {
|
void FeedDownloader::finalizeUpdate() {
|
||||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Finished feed updates in thread"
|
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Finished feed updates in thread" << QUOTE_W_SPACE_DOT(getThreadID());
|
||||||
<< QUOTE_W_SPACE_DOT(getThreadID());
|
|
||||||
|
|
||||||
m_feeds.clear();
|
m_feeds.clear();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ TextBrowserViewer::TextBrowserViewer(QWidget* parent)
|
|||||||
setDocument(m_document.data());
|
setDocument(m_document.data());
|
||||||
|
|
||||||
m_resourceDownloader->moveToThread(m_resourceDownloaderThread);
|
m_resourceDownloader->moveToThread(m_resourceDownloaderThread);
|
||||||
m_resourceDownloaderThread->start(QThread::LowPriority);
|
m_resourceDownloaderThread->start(QThread::Priority::LowPriority);
|
||||||
|
|
||||||
connect(this, &TextBrowserViewer::reloadDocument, this, [this]() {
|
connect(this, &TextBrowserViewer::reloadDocument, this, [this]() {
|
||||||
const auto scr = verticalScrollBarPosition();
|
const auto scr = verticalScrollBarPosition();
|
||||||
|
@ -1157,10 +1157,10 @@ void Application::setupWorkHorsePool() {
|
|||||||
m_workHorsePool->setMaxThreadCount((std::min)(MAX_THREADPOOL_THREADS, 2 * ideal_th_count));
|
m_workHorsePool->setMaxThreadCount((std::min)(MAX_THREADPOOL_THREADS, 2 * ideal_th_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION_MAJOR == 6
|
#if QT_VERSION >= 0x060200 // Qt >= 6.2.0
|
||||||
// Avoid competing with interactive processes/threads by running the
|
// Avoid competing with interactive processes/threads by running the
|
||||||
// worker pool at a very low priority
|
// worker pool at a very low priority
|
||||||
m_workHorsePool->setThreadPriority(QThread::LowestPriority);
|
m_workHorsePool->setThreadPriority(QThread::Priority::LowestPriority);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NOTE: Do not expire threads so that their IDs are not reused.
|
// NOTE: Do not expire threads so that their IDs are not reused.
|
||||||
|
@ -128,7 +128,7 @@ void FeedReader::initializeFeedDownloader() {
|
|||||||
connect(m_feedDownloader, &FeedDownloader::updateStarted, this, &FeedReader::feedUpdatesStarted);
|
connect(m_feedDownloader, &FeedDownloader::updateStarted, this, &FeedReader::feedUpdatesStarted);
|
||||||
connect(m_feedDownloader, &FeedDownloader::updateFinished, qApp->feedUpdateLock(), &Mutex::unlock);
|
connect(m_feedDownloader, &FeedDownloader::updateFinished, qApp->feedUpdateLock(), &Mutex::unlock);
|
||||||
|
|
||||||
m_feedDownloaderThread->start(QThread::LowPriority);
|
m_feedDownloaderThread->start(QThread::Priority::LowPriority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
#include "definitions/definitions.h"
|
|
||||||
#include "miscellaneous/thread.h"
|
#include "miscellaneous/thread.h"
|
||||||
|
|
||||||
|
#include "definitions/definitions.h"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
@ -11,57 +12,61 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Returns the thread ID of the caller
|
// Returns the thread ID of the caller.
|
||||||
qlonglong getThreadID() {
|
qlonglong getThreadID() {
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
return qlonglong(gettid());
|
return qlonglong(gettid());
|
||||||
#else
|
#else
|
||||||
return qlonglong(QThread::currentThreadId());
|
return qlonglong(QThread::currentThreadId());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
// On Linux QThread priorities do nothing with the default scheduler SCHED_OTHER
|
// On Linux QThread priorities do nothing with the default scheduler SCHED_OTHER.
|
||||||
// Set the nice value manually in this case until Qt supports nice values
|
//
|
||||||
|
// Set the nice value manually in this case until Qt supports nice values.
|
||||||
void setThreadPriority(Priority prio) {
|
void setThreadPriority(Priority prio) {
|
||||||
int current_policy = sched_getscheduler(0);
|
int current_policy = sched_getscheduler(0);
|
||||||
|
|
||||||
if (current_policy != -1) {
|
if (current_policy != -1) {
|
||||||
// If the current scheduling policy is neither of these the QThread priority should be working
|
// If the current scheduling policy is neither of these the QThread priority should be working.
|
||||||
if (current_policy != SCHED_BATCH && current_policy != SCHED_OTHER) {
|
if (current_policy != SCHED_BATCH && current_policy != SCHED_OTHER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the scheduler to SCHED_BATCH if needed, indicating that this process is non-interactive
|
// Set the scheduler to SCHED_BATCH if needed, indicating that this process is non-interactive.
|
||||||
if (current_policy == SCHED_OTHER) {
|
if (current_policy == SCHED_OTHER) {
|
||||||
struct sched_param p = {0};
|
struct sched_param p = {0};
|
||||||
|
|
||||||
if (sched_setscheduler(0, SCHED_BATCH, &p) != 0) {
|
if (sched_setscheduler(0, SCHED_BATCH, &p) != 0) {
|
||||||
qDebugNN << "Setting the scheduler to SCHED_BATCH for thread"
|
qDebugNN << "Setting the scheduler to SCHED_BATCH for thread" << QUOTE_W_SPACE(getThreadID())
|
||||||
<< QUOTE_W_SPACE(getThreadID())
|
|
||||||
<< "failed with error" << QUOTE_W_SPACE_DOT(errno);
|
<< "failed with error" << QUOTE_W_SPACE_DOT(errno);
|
||||||
// We can still try to set the nice value
|
// We can still try to set the nice value.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0; // Clear errno since -1 is a legitimate return value
|
errno = 0; // Clear errno since -1 is a legitimate return value.
|
||||||
|
|
||||||
int current_priority = getpriority(PRIO_PROCESS, 0);
|
int current_priority = getpriority(PRIO_PROCESS, 0);
|
||||||
|
|
||||||
if (errno != 0) {
|
if (errno != 0) {
|
||||||
qDebugNN << "Getting the priority for thread"
|
qDebugNN << "Getting the priority for thread" << QUOTE_W_SPACE(getThreadID()) << "failed with error"
|
||||||
<< QUOTE_W_SPACE(getThreadID())
|
<< QUOTE_W_SPACE_DOT(errno);
|
||||||
<< "failed with error" << QUOTE_W_SPACE_DOT(errno);
|
}
|
||||||
} else {
|
else {
|
||||||
if (current_priority != prio) {
|
if (current_priority != prio) {
|
||||||
setpriority(PRIO_PROCESS, 0, prio);
|
setpriority(PRIO_PROCESS, 0, prio);
|
||||||
|
|
||||||
if (errno != 0) {
|
if (errno != 0) {
|
||||||
qDebugNN << "Setting the priority for thread"
|
qDebugNN << "Setting the priority for thread" << QUOTE_W_SPACE(getThreadID()) << "failed with error"
|
||||||
<< QUOTE_W_SPACE(getThreadID())
|
<< QUOTE_W_SPACE_DOT(errno);
|
||||||
<< "failed with error" << QUOTE_W_SPACE_DOT(errno);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
qDebugNN << "Getting the priority for thread"
|
else {
|
||||||
<< QUOTE_W_SPACE(getThreadID())
|
qDebugNN << "Getting the priority for thread" << QUOTE_W_SPACE(getThreadID()) << "failed with error"
|
||||||
<< "failed with error" << QUOTE_W_SPACE_DOT(errno);
|
<< QUOTE_W_SPACE_DOT(errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,14 +3,16 @@
|
|||||||
#ifndef THREAD_H
|
#ifndef THREAD_H
|
||||||
#define THREAD_H
|
#define THREAD_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
qlonglong getThreadID();
|
qlonglong getThreadID();
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
// Values corresponding to nice values
|
// Values corresponding to nice values.
|
||||||
enum Priority {
|
enum Priority {
|
||||||
LOWEST = 19,
|
Lowest = 19,
|
||||||
LOW = 10,
|
Low = 10,
|
||||||
NORMAL = 0
|
Normal = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
void setThreadPriority(Priority);
|
void setThreadPriority(Priority);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user