A few are supposed to be fatal.
#include "accountmanager.h"
#include "filesystem.h"
#include "lockwatcher.h"
+#include "asserts.h"
#include <syncengine.h>
#ifdef Q_OS_MAC
_lockWatcher(new LockWatcher),
_appRestartRequired(false)
{
- Q_ASSERT(!_instance);
+ ASSERT(!_instance);
_instance = this;
_socketApi.reset(new SocketApi);
delete f;
cnt++;
}
+ ASSERT(_folderMap.isEmpty());
+
_lastSyncFolder = 0;
_currentSyncFolder = 0;
_scheduledFolders.clear();
emit scheduleQueueChanged();
- Q_ASSERT(_folderMap.count() == 0);
return cnt;
}
void FolderMan::slotFolderCanSyncChanged()
{
Folder *f = qobject_cast<Folder*>(sender());
- Q_ASSERT(f);
+ ASSERT(f);
if (f->canSync()) {
_socketApi->slotRegisterPath(f->alias());
} else {
#include "folderman.h"
#include "accountstate.h"
#include "utility.h"
+#include "asserts.h"
#include <theme.h>
#include <account.h>
#include "folderstatusdelegate.h"
}
auto pathIdx = static_cast<SubFolderInfo*>(child.internalPointer())->_pathIdx;
int i = 1;
- Q_ASSERT(pathIdx.at(0) < _folders.count());
+ ASSERT(pathIdx.at(0) < _folders.count());
if (pathIdx.count() == 1) {
return createIndex(pathIdx.at(0), 0/*, nullptr*/);
}
const SubFolderInfo *info = &_folders[pathIdx.at(0)];
while (i < pathIdx.count() - 1) {
- Q_ASSERT(pathIdx.at(i) < info->_subs.count());
+ ASSERT(pathIdx.at(i) < info->_subs.count());
info = &info->_subs[pathIdx.at(i)];
++i;
}
auto job = sender();
auto permissionMap = job->property(propertyPermissionMap).toMap();
job->setProperty(propertyPermissionMap, QVariant()); // avoid a detach of the map while it is modified
- Q_ASSERT(!href.endsWith(QLatin1Char('/'))); // LsColXMLParser::parse removes the trailing slash before calling us.
+ ASSERT(!href.endsWith(QLatin1Char('/')), "LsColXMLParser::parse should remove the trailing slash before calling us.");
permissionMap[href] = *it;
job->setProperty(propertyPermissionMap, permissionMap);
}
void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
{
auto job = qobject_cast<LsColJob *>(sender());
- Q_ASSERT(job);
+ ASSERT(job);
QModelIndex idx = qvariant_cast<QPersistentModelIndex>(job->property(propertyParentIndexC));
auto parentInfo = infoForIndex(idx);
if (!parentInfo) {
void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply* r)
{
auto job = qobject_cast<LsColJob *>(sender());
- Q_ASSERT(job);
+ ASSERT(job);
QModelIndex idx = qvariant_cast<QPersistentModelIndex>(job->property(propertyParentIndexC));
if (!idx.isValid()) {
return;
if (r->error() == QNetworkReply::ContentNotFoundError) {
parentInfo->_fetched = true;
} else {
- Q_ASSERT(!parentInfo->hasLabel());
+ ASSERT(!parentInfo->hasLabel());
beginInsertRows(idx, 0, 0);
parentInfo->_hasError = true;
endInsertRows();
void FolderStatusModel::slotNewBigFolder()
{
auto f = qobject_cast<Folder *>(sender());
- Q_ASSERT(f);
+ ASSERT(f);
int folderIndex = -1;
for (int i = 0; i < _folders.count(); ++i) {
#include "notificationwidget.h"
#include "QProgressIndicator.h"
#include "utility.h"
+#include "asserts.h"
#include <QPushButton>
{
_myActivity = activity;
- Q_ASSERT( !activity._accName.isEmpty() );
_accountName = activity._accName;
+ ASSERT(!_accountName.isEmpty());
// _ui._headerLabel->setText( );
_ui._subjectLabel->setVisible( !activity._subject.isEmpty() );
#include "accountstate.h"
#include "account.h"
#include "capabilities.h"
+#include "asserts.h"
#include <QBitArray>
#include <QDebug>
DEBUG << "dtor";
_localServer.close();
// All remaining sockets will be destroyed with _localServer, their parent
- Q_ASSERT(_listeners.isEmpty() || _listeners.first().socket->parent() == &_localServer);
+ ASSERT(_listeners.isEmpty() || _listeners.first().socket->parent() == &_localServer);
_listeners.clear();
}
connect(socket, SIGNAL(readyRead()), this, SLOT(slotReadSocket()));
connect(socket, SIGNAL(disconnected()), this, SLOT(onLostConnection()));
connect(socket, SIGNAL(destroyed(QObject*)), this, SLOT(slotSocketDestroyed(QObject*)));
- Q_ASSERT(socket->readAll().isEmpty());
+ ASSERT(socket->readAll().isEmpty());
_listeners.append(SocketListener(socket));
SocketListener &listener = _listeners.last();
void SocketApi::slotReadSocket()
{
QIODevice* socket = qobject_cast<QIODevice*>(sender());
- Q_ASSERT(socket);
+ ASSERT(socket);
SocketListener *listener = &*std::find_if(_listeners.begin(), _listeners.end(), ListenerHasSocketPred(socket));
while(socket->canReadLine()) {
#include "creds/abstractcredentials.h"
#include "capabilities.h"
#include "theme.h"
+#include "asserts.h"
#include <QSettings>
#include <QMutex>
*/
void Account::clearCookieJar()
{
- Q_ASSERT(qobject_cast<CookieJar*>(_am->cookieJar()));
- static_cast<CookieJar*>(_am->cookieJar())->setAllCookies(QList<QNetworkCookie>());
+ auto jar = qobject_cast<CookieJar*>(_am->cookieJar());
+ ASSERT(jar);
+ jar->setAllCookies(QList<QNetworkCookie>());
emit wantsAccountSaved(this);
}
--- /dev/null
+#ifndef OWNCLOUD_ASSERTS_H
+#define OWNCLOUD_ASSERTS_H
+
+#include <qglobal.h>
+
+#if defined(QT_FORCE_ASSERTS) || !defined(QT_NO_DEBUG)
+#define OC_ASSERT_MSG qFatal
+#else
+#define OC_ASSERT_MSG qWarning
+#endif
+
+// For overloading macros by argument count
+// See stackoverflow.com/questions/16683146/can-macros-be-overloaded-by-number-of-arguments
+#define OC_ASSERT_CAT(A, B) A ## B
+#define OC_ASSERT_SELECT(NAME, NUM) OC_ASSERT_CAT(NAME ## _, NUM)
+#define OC_ASSERT_GET_COUNT(_1, _2, _3, COUNT, ...) COUNT
+#define OC_ASSERT_VA_SIZE(...) OC_ASSERT_GET_COUNT(__VA_ARGS__, 3, 2, 1, 0)
+
+#define OC_ASSERT_OVERLOAD(NAME, ...) OC_ASSERT_SELECT(NAME, OC_ASSERT_VA_SIZE(__VA_ARGS__))(__VA_ARGS__)
+
+// Default assert: If the condition is false in debug builds, terminate.
+//
+// Prints a message on failure, even in release builds.
+#define ASSERT(...) OC_ASSERT_OVERLOAD(ASSERT, __VA_ARGS__)
+#define ASSERT_1(cond) \
+ if (!(cond)) { \
+ OC_ASSERT_MSG("ASSERT: \"%s\" in file %s, line %d", #cond, __FILE__, __LINE__); \
+ } else {}
+#define ASSERT_2(cond, message) \
+ if (!(cond)) { \
+ OC_ASSERT_MSG("ASSERT: \"%s\" in file %s, line %d with message: %s", #cond, __FILE__, __LINE__, message); \
+ } else {}
+
+// Enforce condition to be true, even in release builds.
+//
+// Prints 'message' and aborts execution if 'cond' is false.
+#define ENFORCE(...) OC_ASSERT_OVERLOAD(ENFORCE, __VA_ARGS__)
+#define ENFORCE_1(cond) \
+ if (!(cond)) { \
+ qFatal("ENFORCE: \"%s\" in file %s, line %d", #cond, __FILE__, __LINE__); \
+ } else {}
+#define ENFORCE_2(cond, message) \
+ if (!(cond)) { \
+ qFatal("ENFORCE: \"%s\" in file %s, line %d with message: %s", #cond, __FILE__, __LINE__, message); \
+ } else {}
+
+// An assert that is only present in debug builds: typically used for
+// asserts that are too expensive for release mode.
+//
+// Q_ASSERT
+
+#endif
#include "configfile.h"
#include "theme.h"
#include "utility.h"
+#include "asserts.h"
#include "creds/abstractcredentials.h"
void ConfigFile::saveGeometry(QWidget *w)
{
#ifndef TOKEN_AUTH_ONLY
- Q_ASSERT(!w->objectName().isNull());
+ ASSERT(!w->objectName().isNull());
QSettings settings(configFile(), QSettings::IniFormat);
settings.beginGroup(w->objectName());
settings.setValue(QLatin1String(geometryC), w->saveGeometry());
{
#ifndef TOKEN_AUTH_ONLY
if(!header) return;
- Q_ASSERT(!header->objectName().isEmpty());
+ ASSERT(!header->objectName().isEmpty());
QSettings settings(configFile(), QSettings::IniFormat);
settings.beginGroup(header->objectName());
{
#ifndef TOKEN_AUTH_ONLY
if(!header) return;
- Q_ASSERT(!header->objectName().isNull());
+ ASSERT(!header->objectName().isNull());
QSettings settings(configFile(), QSettings::IniFormat);
settings.beginGroup(header->objectName());
// directories.
QFileInfo fi;
- if (scope != SystemScope) {
- QFileInfo fi;
+ switch (scope) {
+ case UserScope:
fi.setFile( configPath(), exclFile );
if( ! fi.isReadable() ) {
fi.setFile( configPath(), exclFile );
}
return fi.absoluteFilePath();
- } else if (scope != UserScope) {
+ case SystemScope:
return ConfigFile::excludeFileFromSystem();
- } else {
- Q_ASSERT(false);
- return QString(); // unreachable
}
+
+ ASSERT(false);
+ return QString();
}
QString ConfigFile::excludeFileFromSystem()
* for more details.
*/
-
#include <QString>
#include <QDebug>
+#include "asserts.h"
#include "creds/abstractcredentials.h"
namespace OCC
void AbstractCredentials::setAccount(Account *account)
{
- Q_ASSERT(!_account);
+ ENFORCE(!_account, "should only setAccount once");
_account = account;
}
*/
#include "discoveryphase.h"
+
+#include "account.h"
+#include "theme.h"
+#include "asserts.h"
+
#include <csync_private.h>
#include <csync_rename.h>
-#include <qdebug.h>
+#include <qdebug.h>
#include <QUrl>
-#include "account.h"
#include <QFileInfo>
-#include "theme.h"
#include <cstring>
#include "configfile.h"
#include "utility.h"
#include "account.h"
+#include "asserts.h"
#include <json.h>
#ifdef Q_OS_WIN
return true;
}
- Q_ASSERT(_subJobs.at(i)->_state == Running);
+ ASSERT(_subJobs.at(i)->_state == Running);
auto paral = _subJobs.at(i)->parallelism();
if (paral == WaitForFinished) {
void PropagateDirectory::slotSubJobFinished(SyncFileItem::Status status)
{
PropagatorJob *subJob = static_cast<PropagatorJob *>(sender());
+ ASSERT(subJob);
// Delete the job and remove it from our list of jobs.
subJob->deleteLater();
_firstJob.reset();
} else {
int i = _subJobs.indexOf(subJob);
- Q_ASSERT(i >= 0);
+ ASSERT(i >= 0);
_subJobs.remove(i);
}
void CleanupPollsJob::slotPollFinished()
{
PollJob *job = qobject_cast<PollJob *>(sender());
- Q_ASSERT(job);
+ ASSERT(job);
if (job->_item->_status == SyncFileItem::FatalError) {
emit aborted(job->_item->_errorString);
deleteLater();
#include "ownsql.h"
#include "utility.h"
+#include "asserts.h"
#define SQLITE_SLEEP_TIME_USEC 100000
#define SQLITE_REPEAT_COUNT 20
{
if( _db ) {
SQLITE_DO(sqlite3_close(_db) );
- if (_errId != SQLITE_OK) {
- qWarning() << "ERROR When closing DB" << _error;
- Q_ASSERT(!"SQLite Close Error");
- }
+ // Fatal because reopening an unclosed db might be problematic.
+ ENFORCE(_errId == SQLITE_OK, "Error when closing DB");
_db = 0;
}
}
if( _errId != SQLITE_OK ) {
_error = QString::fromUtf8(sqlite3_errmsg(_db));
qWarning() << "Sqlite prepare statement error:" << _error << "in" <<_sql;
- if (!allow_failure) {
- qFatal("SQLITE Prepare error: %s in %s",
- _error.toLocal8Bit().data(),
- sql.toLocal8Bit().data());
- }
+ ENFORCE(allow_failure, "SQLITE Prepare error");
}
}
return _errId;
void SqlQuery::bindValue(int pos, const QVariant& value)
{
int res = -1;
- Q_ASSERT(_stmt);
- if( _stmt ) {
- switch (value.type()) {
- case QVariant::Int:
- case QVariant::Bool:
- res = sqlite3_bind_int(_stmt, pos, value.toInt());
- break;
- case QVariant::Double:
- res = sqlite3_bind_double(_stmt, pos, value.toDouble());
- break;
- case QVariant::UInt:
- case QVariant::LongLong:
- res = sqlite3_bind_int64(_stmt, pos, value.toLongLong());
- break;
- case QVariant::DateTime: {
- const QDateTime dateTime = value.toDateTime();
- const QString str = dateTime.toString(QLatin1String("yyyy-MM-ddThh:mm:ss.zzz"));
- res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
- str.size() * sizeof(ushort), SQLITE_TRANSIENT);
- break;
- }
- case QVariant::Time: {
- const QTime time = value.toTime();
- const QString str = time.toString(QLatin1String("hh:mm:ss.zzz"));
- res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
- str.size() * sizeof(ushort), SQLITE_TRANSIENT);
- break;
- }
- case QVariant::String: {
- if( !value.toString().isNull() ) {
- // lifetime of string == lifetime of its qvariant
- const QString *str = static_cast<const QString*>(value.constData());
- res = sqlite3_bind_text16(_stmt, pos, str->utf16(),
- (str->size()) * sizeof(QChar), SQLITE_TRANSIENT);
- } else {
- res = sqlite3_bind_null(_stmt, pos);
- }
- break; }
- case QVariant::ByteArray: {
- auto ba = value.toByteArray();
- res = sqlite3_bind_text(_stmt, pos, ba.constData(), ba.size(), SQLITE_TRANSIENT);
- break;
- }
- default: {
- QString str = value.toString();
- // SQLITE_TRANSIENT makes sure that sqlite buffers the data
- res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
- (str.size()) * sizeof(QChar), SQLITE_TRANSIENT);
- break; }
+ if (!_stmt) {
+ ASSERT(false);
+ return;
+ }
+
+ switch (value.type()) {
+ case QVariant::Int:
+ case QVariant::Bool:
+ res = sqlite3_bind_int(_stmt, pos, value.toInt());
+ break;
+ case QVariant::Double:
+ res = sqlite3_bind_double(_stmt, pos, value.toDouble());
+ break;
+ case QVariant::UInt:
+ case QVariant::LongLong:
+ res = sqlite3_bind_int64(_stmt, pos, value.toLongLong());
+ break;
+ case QVariant::DateTime: {
+ const QDateTime dateTime = value.toDateTime();
+ const QString str = dateTime.toString(QLatin1String("yyyy-MM-ddThh:mm:ss.zzz"));
+ res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
+ str.size() * sizeof(ushort), SQLITE_TRANSIENT);
+ break;
+ }
+ case QVariant::Time: {
+ const QTime time = value.toTime();
+ const QString str = time.toString(QLatin1String("hh:mm:ss.zzz"));
+ res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
+ str.size() * sizeof(ushort), SQLITE_TRANSIENT);
+ break;
+ }
+ case QVariant::String: {
+ if( !value.toString().isNull() ) {
+ // lifetime of string == lifetime of its qvariant
+ const QString *str = static_cast<const QString*>(value.constData());
+ res = sqlite3_bind_text16(_stmt, pos, str->utf16(),
+ (str->size()) * sizeof(QChar), SQLITE_TRANSIENT);
+ } else {
+ res = sqlite3_bind_null(_stmt, pos);
}
+ break; }
+ case QVariant::ByteArray: {
+ auto ba = value.toByteArray();
+ res = sqlite3_bind_text(_stmt, pos, ba.constData(), ba.size(), SQLITE_TRANSIENT);
+ break;
+ }
+ default: {
+ QString str = value.toString();
+ // SQLITE_TRANSIENT makes sure that sqlite buffers the data
+ res = sqlite3_bind_text16(_stmt, pos, str.utf16(),
+ (str.size()) * sizeof(QChar), SQLITE_TRANSIENT);
+ break; }
}
if (res != SQLITE_OK) {
qDebug() << Q_FUNC_INFO << "ERROR" << value << res;
}
- Q_ASSERT( res == SQLITE_OK );
+ ASSERT( res == SQLITE_OK );
}
bool SqlQuery::nullValue(int index)
#include "filesystem.h"
#include "propagatorjobs.h"
#include "checksums.h"
+#include "asserts.h"
#include <json.h>
#include <QNetworkAccessManager>
propagator()->_activeJobList.removeOne(this);
GETFileJob *job = qobject_cast<GETFileJob *>(sender());
- Q_ASSERT(job);
+ ASSERT(job);
qDebug() << Q_FUNC_INFO << job->reply()->request().url() << "FINISHED WITH STATUS"
<< job->reply()->error()
#include "propagateremotedelete.h"
#include "owncloudpropagator_p.h"
#include "account.h"
+#include "asserts.h"
namespace OCC {
{
propagator()->_activeJobList.removeOne(this);
- Q_ASSERT(_job);
+ ASSERT(_job);
qDebug() << Q_FUNC_INFO << _job->reply()->request().url() << "FINISHED WITH STATUS"
<< _job->reply()->error()
#include "account.h"
#include "syncjournalfilerecord.h"
#include "propagateremotedelete.h"
+#include "asserts.h"
#include <QFile>
namespace OCC {
{
propagator()->_activeJobList.removeOne(this);
- Q_ASSERT(_job);
+ ASSERT(_job);
qDebug() << Q_FUNC_INFO << _job->reply()->request().url() << "FINISHED WITH STATUS"
<< _job->reply()->error()
#include "account.h"
#include "syncjournalfilerecord.h"
#include "filesystem.h"
+#include "asserts.h"
#include <QFile>
#include <QStringList>
#include <QDir>
{
propagator()->_activeJobList.removeOne(this);
- Q_ASSERT(_job);
+ ASSERT(_job);
qDebug() << Q_FUNC_INFO << _job->reply()->request().url() << "FINISHED WITH STATUS"
<< _job->reply()->error()
return false;
bool changed = false;
- Q_ASSERT(!from_.endsWith(QLatin1String("/")));
- Q_ASSERT(!to_.endsWith(QLatin1String("/")));
+ ASSERT(!from_.endsWith(QLatin1String("/")));
+ ASSERT(!to_.endsWith(QLatin1String("/")));
QString from = from_ + QLatin1String("/");
QString to = to_ + QLatin1String("/");
#include "checksums.h"
#include "syncengine.h"
#include "propagateremotedelete.h"
+#include "asserts.h"
#include <json.h>
#include <QNetworkAccessManager>
qint64 UploadDevice::writeData(const char* , qint64 ) {
- Q_ASSERT(!"write to read only device");
+ ASSERT(false, "write to read only device");
return 0;
}
void PropagateUploadFileCommon::slotPollFinished()
{
PollJob *job = qobject_cast<PollJob *>(sender());
- Q_ASSERT(job);
+ ASSERT(job);
propagator()->_activeJobList.removeOne(this);
#include "syncengine.h"
#include "propagateremotemove.h"
#include "propagateremotedelete.h"
-
+#include "asserts.h"
#include <QNetworkAccessManager>
#include <QFileInfo>
void PropagateUploadFileNG::slotDeleteJobFinished()
{
auto job = qobject_cast<DeleteJob *>(sender());
- Q_ASSERT(job);
+ ASSERT(job);
_jobs.remove(_jobs.indexOf(job));
QNetworkReply::NetworkError err = job->reply()->error();
void PropagateUploadFileNG::startNewUpload()
{
- Q_ASSERT(propagator()->_activeJobList.count(this) == 1);
+ ASSERT(propagator()->_activeJobList.count(this) == 1);
_transferId = qrand() ^ _item->_modtime ^ (_item->_size << 16) ^ qHash(_item->_file);
_sent = 0;
_currentChunk = 0;
return;
quint64 fileSize = _item->_size;
- Q_ASSERT(fileSize >= _sent);
+ ENFORCE(fileSize >= _sent, "Sent data exceeds file size");
+
quint64 currentChunkSize = qMin(chunkSize(), fileSize - _sent);
if (currentChunkSize == 0) {
- Q_ASSERT(_jobs.isEmpty()); // There should be no running job anymore
+ ASSERT(_jobs.isEmpty());
_finished = true;
// Finish with a MOVE
QString destination = QDir::cleanPath(propagator()->account()->url().path() + QLatin1Char('/')
void PropagateUploadFileNG::slotPutFinished()
{
PUTFileJob *job = qobject_cast<PUTFileJob *>(sender());
- Q_ASSERT(job);
+ ASSERT(job);
+
slotJobDestroyed(job); // remove it from the _jobs list
qDebug() << job->reply()->request().url() << "FINISHED WITH STATUS"
return;
}
- Q_ASSERT(_sent <= _item->_size);
+ ENFORCE(_sent <= _item->_size, "can't send more than size");
bool finished = _sent == _item->_size;
// Check if the file still exists
#include "checksums.h"
#include "syncengine.h"
#include "propagateremotedelete.h"
+#include "asserts.h"
#include <json.h>
#include <QNetworkAccessManager>
void PropagateUploadFileV1::slotPutFinished()
{
PUTFileJob *job = qobject_cast<PUTFileJob *>(sender());
- Q_ASSERT(job);
+ ASSERT(job);
+
slotJobDestroyed(job); // remove it from the _jobs list
qDebug() << Q_FUNC_INFO << job->reply()->request().url() << "FINISHED WITH STATUS"
#include "csync_private.h"
#include "filesystem.h"
#include "propagateremotedelete.h"
+#include "asserts.h"
#ifdef Q_OS_WIN
#include <windows.h>
qRegisterMetaType<SyncFileItem::Direction>("SyncFileItem::Direction");
// Everything in the SyncEngine expects a trailing slash for the localPath.
- Q_ASSERT(localPath.endsWith(QLatin1Char('/')));
+ ASSERT(localPath.endsWith(QLatin1Char('/')));
csync_create(&_csync_ctx, localPath.toUtf8().data());
QTextCodec::ConverterState utf8State;
static QTextCodec *codec = QTextCodec::codecForName("UTF-8");
- Q_ASSERT(codec);
+ ASSERT(codec);
QString fileUtf8 = codec->toUnicode(file->path, qstrlen(file->path), &utf8State);
QString renameTarget;
QString key = fileUtf8;
item->_modtime = file->modtime;
} else {
if (instruction != CSYNC_INSTRUCTION_NONE) {
- qDebug() << "ERROR: Instruction" << item->_instruction << "vs" << instruction << "for" << fileUtf8;
- Q_ASSERT(!"Instructions are both unequal NONE");
- return -1;
+ qWarning() << "ERROR: Instruction" << item->_instruction << "vs" << instruction << "for" << fileUtf8;
+ ASSERT(false);
+ // Set instruction to NONE for safety.
+ file->instruction = item->_instruction = instruction = CSYNC_INSTRUCTION_NONE;
+ return -1; // should lead to treewalk error
}
}
item->_status = SyncFileItem::SoftError;
break;
default:
- Q_ASSERT("Non handled error-status");
+ ASSERT(false, "Non handled error-status");
/* No error string */
}
}
}
- Q_ASSERT(!s_anySyncRunning);
- Q_ASSERT(!_syncRunning);
+ if (s_anySyncRunning || _syncRunning) {
+ ASSERT(false);
+ return;
+ }
+
s_anySyncRunning = true;
_syncRunning = true;
_anotherSyncNeeded = NoFollowUpSync;
#include "syncengine.h"
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
+#include "asserts.h"
namespace OCC {
SyncFileStatus SyncFileStatusTracker::fileStatus(const QString& relativePath)
{
- Q_ASSERT(!relativePath.endsWith(QLatin1Char('/')));
+ ASSERT(!relativePath.endsWith(QLatin1Char('/')));
if (relativePath.isEmpty()) {
// This is the root sync folder, it doesn't have an entry in the database and won't be walked by csync, so resolve manually.
void SyncFileStatusTracker::slotPathTouched(const QString& fileName)
{
QString folderPath = _syncEngine->localPath();
- Q_ASSERT(fileName.startsWith(folderPath));
+ ASSERT(fileName.startsWith(folderPath));
QString localPath = fileName.mid(folderPath.size());
_dirtyPaths.insert(localPath);
// We passed from OK to SYNC, increment the parent to keep it marked as
// SYNC while we propagate ourselves and our own children.
- Q_ASSERT(!relativePath.endsWith('/'));
+ ASSERT(!relativePath.endsWith('/'));
int lastSlashIndex = relativePath.lastIndexOf('/');
if (lastSlashIndex != -1)
incSyncCountAndEmitStatusChanged(relativePath.left(lastSlashIndex), UnknownShared);
emit fileStatusChanged(getSystemDestination(relativePath), status);
// We passed from SYNC to OK, decrement our parent.
- Q_ASSERT(!relativePath.endsWith('/'));
+ ASSERT(!relativePath.endsWith('/'));
int lastSlashIndex = relativePath.lastIndexOf('/');
if (lastSlashIndex != -1)
decSyncCountAndEmitStatusChanged(relativePath.left(lastSlashIndex), UnknownShared);
void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector& items)
{
- Q_ASSERT(_syncCount.isEmpty());
+ ASSERT(_syncCount.isEmpty());
std::map<QString, SyncFileStatus::SyncFileStatusTag> oldProblems;
std::swap(_syncProblems, oldProblems);
status.set(problemStatus);
}
- // The shared status needs to have been fetched from a SyncFileItem or the DB at this point.
- Q_ASSERT(sharedFlag != UnknownShared);
+ ASSERT(sharedFlag != UnknownShared,
+ "The shared status needs to have been fetched from a SyncFileItem or the DB at this point.");
if (sharedFlag == Shared)
status.setSharedWithMe(true);
#include "utility.h"
#include "version.h"
#include "filesystem.h"
+#include "asserts.h"
#include "../../csync/src/std/c_jhash.h"
{
commitTransaction();
qWarning() << "SQL Error" << log << query.error();
- Q_ASSERT(!"SQL ERROR");
+ ASSERT(false);
_db.close();
return false;
}
QStringList SyncJournalDb::getSelectiveSyncList(SyncJournalDb::SelectiveSyncListType type, bool *ok )
{
QStringList result;
- Q_ASSERT(ok);
+ ASSERT(ok);
QMutexLocker locker(&_mutex);
if( !checkConnect() ) {