Skip to content

Commit

Permalink
Merge pull request robert7#228 from boo-yee/develop
Browse files Browse the repository at this point in the history
Fix issue 222: crash with 'qevercloud::EverCloudException' and incomplete note content
  • Loading branch information
robert7 authored Sep 12, 2024
2 parents aeb6872 + 92f8eda commit cb0ec31
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/communication/communicationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif // End windows check

#include <qtconcurrentmap.h>
#include <QMutexLocker>

#include "src/utilities/debugtool.h"

Expand Down Expand Up @@ -84,6 +85,7 @@ CommunicationManager::CommunicationManager(DatabaseConnection *db) {
if (networkAccessManager == nullptr) {
networkAccessManager = new QNetworkAccessManager(this);
}
threadException = nullptr;
}


Expand Down Expand Up @@ -299,6 +301,9 @@ CommunicationManager::getSyncChunk(SyncChunk &chunk, int start, int chunkSize, i
try {
chunk = myNoteStore->getFilteredSyncChunk(start, chunkSize, filter, newRequestContext(token, requestTimeout));
processSyncChunk(chunk, token);
if (threadException != nullptr) {
return false;
}
} catch (ThriftException &e) {
reportError(CommunicationError::ThriftException, static_cast<int>(e.type()), e.what());
return false;
Expand Down Expand Up @@ -707,6 +712,9 @@ bool CommunicationManager::getLinkedNotebookSyncChunk(SyncChunk &chunk, LinkedNo
try {
chunk = linkedNoteStore->getLinkedNotebookSyncChunk(book, start, chunkSize, fullSync, newRequestContext(authToken, requestTimeout));
processSyncChunk(chunk, linkedAuthToken);
if (threadException != nullptr) {
return false;
}
} catch (ThriftException &e) {
reportError(CommunicationError::ThriftException, static_cast<int>(e.type()), e.what());
return false;
Expand Down Expand Up @@ -786,7 +794,15 @@ bool CommunicationManager::getNoteVersion(Note &note, QString guid, qint32 usn,
Note CommunicationManager::downloadNote(const Note &n) {
QLOG_DEBUG() << "downloadNote guid=" << n.guid;
Note tmp = n;
this->getNote(tmp, n.guid, true, true, true);
try {
this->getNote(tmp, n.guid, true, true, true);
} catch (const EverCloudException &e) {
QMutexLocker locker(&mutex);
if (threadException == nullptr) {
threadException = new EverCloudException(e);
reportError(CommunicationError::StdException, 16, e.what());
}
}
return tmp;
}

Expand Down Expand Up @@ -1032,6 +1048,9 @@ void CommunicationManager::processSyncChunk(SyncChunk &chunk, QString token) {
}
downloadedNotes.append(QtConcurrent::blockingMapped<QList<Note> >(tmpNotes,
std::bind(&CommunicationManager::downloadNote, this, std::placeholders::_1)));
if (threadException != nullptr) {
return;
}
QLOG_TRACE() << "A set of notes Retrieved";
}

Expand Down
3 changes: 3 additions & 0 deletions src/communication/communicationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QObject>
#include <QNetworkAccessManager>
#include <QSqlDatabase>
#include <QMutex>

#include "src/qevercloud/QEverCloud/headers/QEverCloud.h"
using namespace qevercloud;
Expand Down Expand Up @@ -103,6 +104,8 @@ class CommunicationManager : public QObject
const QString &internalMessage = QString());

CommunicationError error;
EverCloudException *threadException;
QMutex mutex;

public:

Expand Down

0 comments on commit cb0ec31

Please sign in to comment.