Skip to content

Commit 80306a7

Browse files
committed
Fix GUI crash on job completion...
1 parent 7938973 commit 80306a7

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

src/FoldersMonitorForNewFiles.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <QFileInfoList>
2929
#include <QMap>
3030
#include <QSet>
31-
using QAtomicBool = QAtomicInteger<unsigned short>; // 16 bit only (faster than using 8 bit variable...)
31+
using AtomicBool = QAtomicInteger<unsigned short>; // 16 bit only (faster than using 8 bit variable...)
3232
using PathSet = QSet<QString>;
3333

3434
class FolderScan
@@ -52,7 +52,7 @@ class FoldersMonitorForNewFiles : public QObject
5252
private:
5353
QFileSystemWatcher _monitor; //!< monitor
5454
QMap<QString, FolderScan*> _folders; //!< track files processed (their date might be > _lastCheck)
55-
QAtomicBool _stopListening;
55+
AtomicBool _stopListening;
5656

5757
static const ulong sMSleep = 1000; //!< 1sec in case we move file from samba or unrar when the system is quite loaded
5858

src/NgPost.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ class NzbCheck;
5353

5454
#define NB_ARTICLES_TO_PREPARE_PER_CONNECTION 3
5555

56-
57-
//using QAtomicBool = QAtomicInteger<unsigned short>; // 16 bit only (faster than using 8 bit variable...)
58-
5956
#include <QTimer>
6057

6158
/*!

src/PostingJob.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ void PostingJob::onDisconnectedConnection(NntpConnection *con)
411411
if (con->hasNoMoreFiles())
412412
{
413413
_finishPosting();
414-
emit noMoreConnection();
414+
if (!_postFinished)
415+
emit noMoreConnection();
415416
}
416417
else
417418
{
@@ -426,7 +427,8 @@ void PostingJob::onDisconnectedConnection(NntpConnection *con)
426427
else
427428
{
428429
_finishPosting();
429-
emit noMoreConnection();
430+
if (!_postFinished)
431+
emit noMoreConnection();
430432
}
431433
}
432434
}

src/PostingJob.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class NntpArticle;
4040
class PostingWidget;
4141
class Poster;
4242

43-
using QAtomicBool = QAtomicInteger<unsigned short>; // 16 bit only (faster than using 8 bit variable...)
43+
using AtomicBool = QAtomicInteger<unsigned short>; // 16 bit only (faster than using 8 bit variable...)
4444

4545
/*!
4646
* \brief PostingJob is an active object that will do a posting job
@@ -120,8 +120,8 @@ class PostingJob : public QObject
120120
uint _nbArticlesTotal; //!< number of Articles of all the files to post
121121

122122

123-
QAtomicBool _stopPosting;
124-
QAtomicBool _noMoreFiles;
123+
AtomicBool _stopPosting;
124+
AtomicBool _noMoreFiles;
125125

126126
bool _postStarted;
127127
bool _packed;
@@ -131,7 +131,7 @@ class PostingJob : public QObject
131131
const bool _obfuscateFileName;
132132

133133

134-
QAtomicBool _delFilesAfterPost;
134+
AtomicBool _delFilesAfterPost;
135135
const QFileInfoList _originalFiles;
136136

137137

src/hmi/PostingWidget.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ void PostingWidget::onArticlesNumber(int nbArticles)
102102

103103
void PostingWidget::onPostingJobDone()
104104
{
105+
// we could arrive here twice: from PostingJob::postingFinished or PostingJob::noMoreConnection
106+
// This could happen especially when we exceed the number of connections allowed by a provider
107+
if (!_postingJob)
108+
return;
109+
105110
if (_postingJob->nbArticlesTotal() > 0)
106111
{
107112
if (_postingJob->nbArticlesFailed() > 0)
@@ -112,6 +117,7 @@ void PostingWidget::onPostingJobDone()
112117
else
113118
_hmi->clearJobTab(this);
114119

120+
disconnect(_postingJob);
115121
_postingJob = nullptr; //!< we don't own it, NgPost will delete it
116122
_postingFinished = true;
117123
setIDLE();

0 commit comments

Comments
 (0)