Skip to content

Commit 066c7d6

Browse files
committed
cleaned up the edit stage mess
there should really be just two processing stages: preprocessed and processed, that postprocessing flag was just confusing
1 parent f17dabe commit 066c7d6

File tree

12 files changed

+36
-34
lines changed

12 files changed

+36
-34
lines changed

src/huggle_core/editqueue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,5 @@ bool EditQueue_UnprocessedEdit::IsPostProcessing()
145145
{
146146
if (this->Edit == nullptr)
147147
return false;
148-
return this->Edit->Status != WEStatus::StatusPostProcessed;
148+
return this->Edit->Status != WEStatus::StatusProcessed;
149149
}

src/huggle_core/hugglequeuefilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ bool HuggleQueueFilter::Matches(WikiEdit *edit)
164164
if (this->Self == HuggleQueueFilterMatchRequire && edit->User->Username.toLower() == Configuration::HuggleConfiguration->SystemConfig_UserName.toLower())
165165
return false;
166166
}
167-
if (edit->IsPostProcessed())
167+
if (edit->IsProcessed())
168168
{
169169
if (hcfg->SystemConfig_CatScansAndWatched)
170170
{

src/huggle_core/querypool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ void QueryPool::PreProcessEdit(WikiEdit *edit)
7878
{
7979
if (edit == nullptr)
8080
throw new Huggle::NullPointerException("WikiEdit *edit", BOOST_CURRENT_FUNCTION);
81-
if (edit->Status == StatusProcessed)
81+
if (edit->Status == StatusPreProcessed)
8282
return;
83-
if (edit->Status == StatusPostProcessed)
83+
if (edit->Status == StatusProcessed)
8484
throw new Huggle::Exception("Pre process of edit that was already post processed", BOOST_CURRENT_FUNCTION);
8585
if (edit->User == nullptr)
8686
throw new Huggle::NullPointerException("edit->User", BOOST_CURRENT_FUNCTION);
@@ -115,7 +115,7 @@ void QueryPool::PreProcessEdit(WikiEdit *edit)
115115
if (hcfg->UserConfig->RemoveAfterTrustedEdit && edit->User->IsWhitelisted() && EditQueue::Primary)
116116
EditQueue::Primary->DeleteOlder(edit);
117117

118-
edit->Status = StatusProcessed;
118+
edit->Status = StatusPreProcessed;
119119
Hooks::EditAfterPreProcess(edit);
120120
}
121121

src/huggle_core/revertquery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void RevertQuery::preflightCheck()
258258
while (index < WikiEdit::EditList.count())
259259
{
260260
WikiEdit *w = WikiEdit::EditList.at(index++);
261-
if (!w->IsPostProcessed())
261+
if (!w->IsProcessed())
262262
continue;
263263
if (w != this->editToBeReverted)
264264
{

src/huggle_core/wikiedit.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,14 +617,14 @@ void WikiEdit::PostProcess()
617617
throw new Huggle::NullPointerException("local WikiPage Page", BOOST_CURRENT_FUNCTION);
618618
if (this->Status == Huggle::StatusNone)
619619
{
620-
Exception::ThrowSoftException("Processing edit to " + this->Page->PageName + "which was requested to be post processed,"\
621-
" but wasn't processed yet", BOOST_CURRENT_FUNCTION);
620+
Exception::ThrowSoftException("Processing edit of " + this->Page->PageName + " which was requested to be post-processed,"\
621+
" but wasn't pre-processed yet", BOOST_CURRENT_FUNCTION);
622622
QueryPool::HugglePool->PreProcessEdit(this);
623623
}
624-
if (this->Status == Huggle::StatusPostProcessed)
625-
throw new Huggle::Exception("Unable to post process an edit that is already processed", BOOST_CURRENT_FUNCTION);
626-
if (this->Status != Huggle::StatusProcessed)
627-
throw new Huggle::Exception("Unable to post process an edit that wasn't in processed status", BOOST_CURRENT_FUNCTION);
624+
if (this->Status == Huggle::StatusProcessed)
625+
throw new Huggle::Exception("Unable to process an edit that is already processed", BOOST_CURRENT_FUNCTION);
626+
if (this->Status != Huggle::StatusPreProcessed)
627+
throw new Huggle::Exception("Unable to process an edit that wasn't in preprocessed status", BOOST_CURRENT_FUNCTION);
628628
this->postProcessing = true;
629629
#ifndef HUGGLE_SDK
630630
// Send info to other functions
@@ -899,5 +899,5 @@ void WikiEdit_ProcessorThread::Process(WikiEdit *edit)
899899
// Hooks::EditAfterPostProcess(edit);
900900
edit->postProcessing = false;
901901
edit->processedByWorkerThread = true;
902-
edit->Status = StatusPostProcessed;
902+
edit->Status = StatusProcessed;
903903
}

src/huggle_core/wikiedit.hpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ namespace Huggle
3838
enum WEStatus
3939
{
4040
StatusNone,
41-
StatusProcessed,
42-
StatusPostProcessed
41+
StatusPreProcessed,
42+
StatusProcessed
4343
};
4444

4545
class Query;
@@ -71,9 +71,10 @@ namespace Huggle
7171

7272
//! That means each edit has has one of 3 basic states in its lifecycle:
7373
//! None - edit was just created and is not suitable for use elsewhere in the program as many attributes may be missing, these attributes are inserted during processing and post processing
74-
//! Processed - edit was processed, that means the basic informations about the edit were properly set by various helper functions.
75-
//! Processing is a very quick operation, it happens within the program, no external API calls are needed. It fills up most of essential properties, but not all of them.
76-
//! Postprocessed - edit was processed by the processor thread which handles various API calls asynchronously in order to fetch all available detailed information about the edit and the detailed information.
74+
//! PreProcessed - edit was preprocessed, that means the basic informations about the edit were properly set by various helper functions.
75+
//! Preprocessing is only a very quick operation, it happens within the main thread, no external API calls are needed. It fills up only most of the essential properties, but not all of them.
76+
//! Processed - edit was fully processed by the edit processing thread which handles various API calls, and regex parsing asynchronously in order to fetch all available detailed
77+
//! information about the edit and the detailed information.
7778

7879
//! Edits are heavily cached across Huggle in order to avoid unnecessary API calls
7980

@@ -103,7 +104,7 @@ namespace Huggle
103104
QString GetFullUrl();
104105
bool IsRangeOfEdits();
105106
//! Return true in case this edit was post processed already
106-
bool IsPostProcessed();
107+
bool IsProcessed();
107108
//! If edit is ready to be added to queue
108109
bool IsReady();
109110
//! Processes all score words in text
@@ -163,7 +164,7 @@ namespace Huggle
163164
long Score = 0;
164165
//! This score is used to determine if edit was done in good faith, even if it wasn't OK
165166
long GoodfaithScore = 0;
166-
//! Function to call when post processing of edit is finished
167+
//! Function to call when processing of edit is finished
167168
WEPostprocessedCallback PostprocessCallback = nullptr;
168169
void *PostprocessCallback_Owner = nullptr;
169170
QHash<QString, QVariant> PropertyBag;
@@ -181,10 +182,11 @@ namespace Huggle
181182
bool processingRevs;
182183
bool processingEditInfo;
183184
bool processingDiff = false;
184-
//! This variable is used by worker thread and needs to be public so that it is working
185+
186+
// These 2 variables are used by worker thread
185187
bool postProcessing;
186-
//! This variable is used by worker thread and needs to be public so that it is working
187188
bool processedByWorkerThread;
189+
188190
Collectable_SmartPtr<ApiQuery> qTalkpage;
189191
//! This is a query used to retrieve information about the user
190192
Collectable_SmartPtr<ApiQuery> qUser;
@@ -208,9 +210,9 @@ namespace Huggle
208210
return QDateTime::fromMSecsSinceEpoch(0);
209211
}
210212

211-
inline bool WikiEdit::IsPostProcessed()
213+
inline bool WikiEdit::IsProcessed()
212214
{
213-
return (this->Status == StatusPostProcessed);
215+
return (this->Status == StatusProcessed);
214216
}
215217

216218
inline long WikiEdit::GetSize()

src/huggle_ui/history.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void History::Display()
274274
if (this->DisplayedEdit == nullptr)
275275
return;
276276

277-
if (!this->DisplayedEdit->IsPostProcessed())
277+
if (!this->DisplayedEdit->IsProcessed())
278278
return;
279279

280280
MainWindow::HuggleMain->DisplayEdit(this->DisplayedEdit);
@@ -372,7 +372,7 @@ void History::ShowEdit()
372372
case HistoryProtect:
373373
return;
374374
}
375-
if (!edit->IsPostProcessed())
375+
if (!edit->IsProcessed())
376376
{
377377
// now we need to display it
378378
QueryPool::HugglePool->PreProcessEdit(edit);

src/huggle_ui/historyform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void HistoryForm::onTick01()
136136

137137
if (this->RetrievingEdit && this->RetrievedEdit != nullptr)
138138
{
139-
if (this->RetrievedEdit->IsPostProcessed())
139+
if (this->RetrievedEdit->IsProcessed())
140140
{
141141
MainWindow::HuggleMain->DisplayEdit(this->RetrievedEdit, false, true);
142142
this->RetrievingEdit = false;

src/huggle_ui/hugglequeue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void HuggleQueue::AddItem(WikiEdit *edit)
4343
if (edit == nullptr)
4444
throw new Huggle::NullPointerException("WikiEdit *page", BOOST_CURRENT_FUNCTION);
4545

46-
if (!edit->IsPostProcessed())
46+
if (!edit->IsProcessed())
4747
throw new Huggle::Exception("Insert of non processed edit to queue", BOOST_CURRENT_FUNCTION);
4848

4949
if (!edit->IsValid)
@@ -95,7 +95,7 @@ void HuggleQueue::AddItem(WikiEdit *edit)
9595
{
9696
// retrieve the edit
9797
WikiEdit *current_edit = Huggle::WikiEdit::EditList.at(i++);
98-
if (!current_edit->IsPostProcessed())
98+
if (!current_edit->IsProcessed())
9999
continue;
100100
// if this is a same edit we can go next
101101
if (current_edit == edit)

src/huggle_ui/huggletool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void HuggleTool::finishPage()
226226

227227
void HuggleTool::finishEdit()
228228
{
229-
if (this->edit == nullptr || !this->edit->IsPostProcessed())
229+
if (this->edit == nullptr || !this->edit->IsProcessed())
230230
return;
231231
this->tick->stop();
232232
this->ui->pushButtonLoad->setEnabled(true);

0 commit comments

Comments
 (0)