added way to disable just debug outputs, fixes #645

This commit is contained in:
Martin Rotter 2022-02-22 09:32:57 +01:00
parent 7b19910e0b
commit 7c96a97503
8 changed files with 57 additions and 32 deletions

View File

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" />
<releases>
<release version="4.1.2" date="2022-02-21"/>
<release version="4.1.2" date="2022-02-22"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -422,9 +422,11 @@ bool FeedDownloader::isCacheSynchronizationRunning() const {
void FeedDownloader::removeDuplicateMessages(QList<Message>& messages) {
auto idx = 0;
while (idx < messages.size()) {
Message& message = messages[idx];
std::function<bool(const Message& a, const Message& b)> is_duplicate;
if (message.m_id > 0) {
is_duplicate = [](const Message& a, const Message& b) {
return a.m_id == b.m_id;
@ -440,27 +442,37 @@ void FeedDownloader::removeDuplicateMessages(QList<Message>& messages) {
return a.m_customId == b.m_customId;
};
}
auto next_idx = idx + 1; // Index of next message to check after removing all duplicates.
auto last_idx = idx; // Index of the last kept duplicate.
idx = next_idx;
// Remove all duplicate messages, and keep the message with the latest created date.
// If the created date is identical for all duplicate messages then keep the last message in the list.
while (idx < messages.size()) {
auto& last_duplicate = messages[last_idx];
if (is_duplicate(last_duplicate, messages[idx])) {
if (last_duplicate.m_created <= messages[idx].m_created) {
// The last seen message was created earlier or at the same date -- keep the current, and remove the last.
qWarningNN << LOGSEC_CORE << "Removing article" << QUOTE_W_SPACE(last_duplicate.m_title)
<< "before saving articles to DB, because it is duplicate.";
messages.removeAt(last_idx);
if (last_idx + 1 == next_idx) {
// The `next_idx` was pointing to the message following the duplicate. With that duplicate removed the
// next index needs to be adjusted.
next_idx = last_idx;
}
last_idx = idx;
++idx;
}
else {
qWarningNN << LOGSEC_CORE << "Removing article" << QUOTE_W_SPACE(messages[idx].m_title)
<< "before saving articles to DB, because it is duplicate.";
messages.removeAt(idx);
}
}

View File

@ -59,7 +59,7 @@ class FeedDownloader : public QObject {
const QHash<ServiceRoot::BagOfMessages, QStringList>& stated_messages,
const QHash<QString, QStringList>& tagged_messages);
void finalizeUpdate();
static void removeDuplicateMessages(QList<Message>& messages);
void removeDuplicateMessages(QList<Message>& messages);
bool m_isCacheSynchronizationRunning;
bool m_stopCacheSynchronization;

View File

@ -103,16 +103,25 @@
#define CLI_VER_SHORT "v"
#define CLI_VER_LONG "version"
#define CLI_HELP_SHORT "h"
#define CLI_HELP_LONG "help"
#define CLI_LOG_SHORT "l"
#define CLI_LOG_LONG "log"
#define CLI_DAT_SHORT "d"
#define CLI_DAT_LONG "data"
#define CLI_SIN_SHORT "s"
#define CLI_SIN_LONG "no-single-instance"
#define CLI_NDEBUG_SHORT "n"
#define CLI_NSTDOUTERR_SHORT "n"
#define CLI_NSTDOUTERR_LONG "no-standard-output"
#define CLI_NDEBUG_SHORT "g"
#define CLI_NDEBUG_LONG "no-debug-output"
#define CLI_QUIT_INSTANCE "q"
#define CLI_IS_RUNNING "a"

View File

@ -35,7 +35,7 @@ SettingsGui::SettingsGui(Settings* settings, QWidget* parent) : SettingsPanel(se
<< tr("Author"));
#if !defined(Q_OS_UNIX) || defined(Q_OS_MACOS)
m_ui->m_tabUi->setTabVisible(m_ui->m_tabUi->indexOf(m_ui->m_taskBar), false);
m_ui->m_tabUi->setTabVisible(m_ui->m_tabUi->indexOf(m_ui->m_tabTaskBar), false);
#endif
m_ui->m_helpCustomSkinColors->setHelpText(tr("You can override some colors defined by your skin here. "

View File

@ -199,6 +199,20 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="m_tabTaskBar">
<attribute name="title">
<string>Task bar</string>
</attribute>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QCheckBox" name="m_displayUnreadMessageCountOnTaskBar">
<property name="text">
<string>Display count of unread messages</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_tabTabs">
<attribute name="title">
<string>Tabs</string>
@ -410,24 +424,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="m_taskBar">
<attribute name="title">
<string>Task bar</string>
</attribute>
<widget class="QCheckBox" name="m_displayUnreadMessageCountOnTaskBar">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>321</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Display count of unread messages</string>
</property>
</widget>
</widget>
</widget>
</item>
</layout>

View File

@ -25,6 +25,7 @@
#include <iostream>
#include <QLoggingCategory>
#include <QProcess>
#include <QSessionManager>
#include <QSslSocket>
@ -795,10 +796,13 @@ void Application::parseCmdArgumentsFromMyInstance() {
QSL("user-data-folder"));
QCommandLineOption disable_singleinstance({ QSL(CLI_SIN_SHORT), QSL(CLI_SIN_LONG) },
QSL("Allow running of multiple application instances."));
QCommandLineOption disable_debug({ QSL(CLI_NDEBUG_SHORT), QSL(CLI_NDEBUG_LONG) },
QCommandLineOption disable_only_debug({ QSL(CLI_NDEBUG_SHORT), QSL(CLI_NDEBUG_LONG) },
QSL("Disable just \"debug\" outputs."));
QCommandLineOption disable_debug({ QSL(CLI_NSTDOUTERR_SHORT), QSL(CLI_NSTDOUTERR_LONG) },
QSL("Completely disable stdout/stderr outputs."));
m_cmdParser.addOptions({ help, version, log_file, custom_data_folder, disable_singleinstance, disable_debug });
m_cmdParser.addOptions({ help, version, log_file, custom_data_folder,
disable_singleinstance, disable_only_debug, disable_debug });
m_cmdParser.addPositionalArgument(QSL("urls"),
QSL("List of URL addresses pointing to individual online feeds which should be added."),
QSL("[url-1 ... url-n]"));
@ -818,6 +822,10 @@ void Application::parseCmdArgumentsFromMyInstance() {
s_customLogFile.chop(1);
}
if (m_cmdParser.isSet(QSL(CLI_NDEBUG_SHORT))) {
QLoggingCategory::setFilterRules(QSL("*.debug=false"));
}
if (!m_cmdParser.value(QSL(CLI_DAT_SHORT)).isEmpty()) {
auto data_folder = QDir::toNativeSeparators(m_cmdParser.value(QSL(CLI_DAT_SHORT)));
@ -843,7 +851,7 @@ void Application::parseCmdArgumentsFromMyInstance() {
qDebugNN << LOGSEC_CORE << "Explicitly allowing this instance to run.";
}
if (m_cmdParser.isSet(QSL(CLI_NDEBUG_SHORT))) {
if (m_cmdParser.isSet(QSL(CLI_NSTDOUTERR_SHORT))) {
s_disableDebug = true;
qDebugNN << LOGSEC_CORE << "Disabling any stdout/stderr outputs.";
}

View File

@ -61,10 +61,10 @@ QList<ServiceEntryPoint*> FeedReader::feedServices() {
m_feedServices.append(new FeedlyEntryPoint());
m_feedServices.append(new GmailEntryPoint());
m_feedServices.append(new GreaderEntryPoint());
m_feedServices.append(new NewsBlurEntryPoint());
m_feedServices.append(new OwnCloudServiceEntryPoint());
#if defined(DEBUG)
m_feedServices.append(new NewsBlurEntryPoint());
m_feedServices.append(new RedditEntryPoint());
#endif