Sleep(DWORD(ms));
#else
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
- nanosleep(&ts, NULL);
+ nanosleep(&ts, nullptr);
#endif
}
if (!connOk)
QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv)
: QApplication(argc, argv),
firstPeer(-1),
- pidPeer(0)
+ pidPeer(nullptr)
{
this->appId = appId;
// This shared memory holds a zero-terminated array of active (or crashed) instances
instances = new QSharedMemory(appSessionId, this);
- actWin = 0;
+ actWin = nullptr;
block = false;
// First instance creates the shared memory, later instances attach to it
qWarning() << "Failed to initialize instances shared memory: "
<< instances->errorString();
delete instances;
- instances = 0;
+ instances = nullptr;
return;
}
}
// we can't use csync_set_userdata because the SyncEngine sets it already.
// So we have to use a global variable
-CmdOptions *opts = 0;
+CmdOptions *opts = nullptr;
class EchoDisabler
{
{
QByteArray type = parseChecksumHeaderType(QByteArray(otherChecksumHeader));
if (type.isEmpty())
- return NULL;
+ return nullptr;
qCInfo(lcChecksums) << "Computing" << type << "checksum of" << path << "in the csync hook";
QByteArray checksum = ComputeChecksum::computeNow(QString::fromUtf8(path), type);
if (checksum.isNull()) {
qCWarning(lcChecksums) << "Failed to compute checksum" << type << "for" << path;
- return NULL;
+ return nullptr;
}
return makeChecksumHeader(type, checksum);
Q_LOGGING_CATEGORY(lcSql, "nextcloud.sync.database.sql", QtInfoMsg)
SqlDatabase::SqlDatabase()
- : _db(0)
+ : _db(nullptr)
, _errId(0)
{
}
bool SqlDatabase::isOpen()
{
- return _db != 0;
+ return _db != nullptr;
}
bool SqlDatabase::openHelper(const QString &filename, int sqliteFlags)
sqliteFlags |= SQLITE_OPEN_NOMUTEX;
- SQLITE_DO(sqlite3_open_v2(filename.toUtf8().constData(), &_db, sqliteFlags, 0));
+ SQLITE_DO(sqlite3_open_v2(filename.toUtf8().constData(), &_db, sqliteFlags, nullptr));
if (_errId != SQLITE_OK) {
qCWarning(lcSql) << "Error:" << _error << "for" << filename;
SQLITE_DO(sqlite3_close(_db));
if (_errId != SQLITE_OK)
qCWarning(lcSql) << "Closing database failed" << _error;
- _db = 0;
+ _db = nullptr;
}
}
if (!_db) {
return false;
}
- SQLITE_DO(sqlite3_exec(_db, "BEGIN", 0, 0, 0));
+ SQLITE_DO(sqlite3_exec(_db, "BEGIN", nullptr, nullptr, nullptr));
return _errId == SQLITE_OK;
}
if (!_db) {
return false;
}
- SQLITE_DO(sqlite3_exec(_db, "COMMIT", 0, 0, 0));
+ SQLITE_DO(sqlite3_exec(_db, "COMMIT", nullptr, nullptr, nullptr));
return _errId == SQLITE_OK;
}
int n = 0;
int rc;
do {
- rc = sqlite3_prepare_v2(_db, _sql.constData(), -1, &_stmt, 0);
+ rc = sqlite3_prepare_v2(_db, _sql.constData(), -1, &_stmt, nullptr);
if ((rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED)) {
n++;
OCC::Utility::usleep(SQLITE_SLEEP_TIME_USEC);
if (!_stmt)
return;
SQLITE_DO(sqlite3_finalize(_stmt));
- _stmt = 0;
+ _stmt = nullptr;
if (_sqldb) {
_sqldb->_queries.remove(this);
}
return {};
query.bindValue(1, checksumTypeId);
if (!query.exec()) {
- return 0;
+ return nullptr;
}
if (!query.next()) {
qCWarning(lcDb) << "No checksum type mapping found for" << checksumTypeId;
- return 0;
+ return nullptr;
}
return query.baValue(0);
}
QString description(quint64 value) const
{
- return QCoreApplication::translate("Utility", name, 0, value);
+ return QCoreApplication::translate("Utility", name, nullptr, value);
}
};
// QTBUG-3945 and issue #4855: QT_TRANSLATE_NOOP does not work with plural form because lupdate
{ QT_TRANSLATE_NOOP("Utility", "%n hour(s)", 0, _), 3600 * 1000LL },
{ QT_TRANSLATE_NOOP("Utility", "%n minute(s)", 0, _), 60 * 1000LL },
{ QT_TRANSLATE_NOOP("Utility", "%n second(s)", 0, _), 1000LL },
- { 0, 0 }
+ { nullptr, 0 }
};
} // anonymous namespace
void Utility::crash()
{
- volatile int *a = (int *)(NULL);
+ volatile int *a = (int *)nullptr;
*a = 1;
}
int csync_update(CSYNC *ctx) {
int rc = -1;
- if (ctx == NULL) {
+ if (ctx == nullptr) {
errno = EBADF;
return -1;
}
other_file_it = other_tree->find(renamed_path);
}
- csync_file_stat_t *other = (other_file_it != other_tree->cend()) ? other_file_it->second.get() : NULL;
+ csync_file_stat_t *other = (other_file_it != other_tree->cend()) ? other_file_it->second.get() : nullptr;
ctx->status_code = CSYNC_STATUS_OK;
}
void *csync_get_userdata(CSYNC *ctx) {
- if (ctx == NULL) {
- return NULL;
+ if (ctx == nullptr) {
+ return nullptr;
}
return ctx->callbacks.userdata;
}
int csync_set_userdata(CSYNC *ctx, void *userdata) {
- if (ctx == NULL) {
+ if (ctx == nullptr) {
return -1;
}
}
csync_auth_callback csync_get_auth_callback(CSYNC *ctx) {
- if (ctx == NULL) {
- return NULL;
+ if (ctx == nullptr) {
+ return nullptr;
}
return ctx->callbacks.auth_function;
}
int csync_set_status(CSYNC *ctx, int status) {
- if (ctx == NULL || status < 0) {
+ if (ctx == nullptr || status < 0) {
return -1;
}
}
CSYNC_STATUS csync_get_status(CSYNC *ctx) {
- if (ctx == NULL) {
+ if (ctx == nullptr) {
return CSYNC_STATUS_ERROR;
}
void csync_request_abort(CSYNC *ctx)
{
- if (ctx != NULL) {
+ if (ctx != nullptr) {
ctx->abort = true;
}
}
void csync_resume(CSYNC *ctx)
{
- if (ctx != NULL) {
+ if (ctx != nullptr) {
ctx->abort = false;
}
}
int csync_abort_requested(CSYNC *ctx)
{
- if (ctx != NULL) {
+ if (ctx != nullptr) {
return ctx->abort;
} else {
return (1 == 0);
static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const char *path, bool excludeConflictFiles)
{
- const char *bname = NULL;
+ const char *bname = nullptr;
size_t blen = 0;
int rc = -1;
CSYNC_EXCLUDE_TYPE match = CSYNC_NOT_EXCLUDED;
unsigned int depth) {
QByteArray filename;
QByteArray fullpath;
- csync_vio_handle_t *dh = NULL;
+ csync_vio_handle_t *dh = nullptr;
std::unique_ptr<csync_file_stat_t> dirent;
- csync_file_stat_t *previous_fs = NULL;
+ csync_file_stat_t *previous_fs = nullptr;
int read_from_db = 0;
int rc = 0;
return 0;
}
- if ((dh = csync_vio_opendir(ctx, uri)) == NULL) {
+ if ((dh = csync_vio_opendir(ctx, uri)) == nullptr) {
if (ctx->abort) {
qCDebug(lcUpdate, "Aborted!");
ctx->status_code = CSYNC_STATUS_ABORTED;
error:
ctx->remote.read_from_db = read_from_db;
- if (dh != NULL) {
+ if (dh != nullptr) {
csync_vio_closedir(ctx, dh);
}
return -1;
{ "INSTRUCTION_ERROR", CSYNC_INSTRUCTION_ERROR },
{ "INSTRUCTION_TYPE_CHANGE", CSYNC_INSTRUCTION_TYPE_CHANGE },
{ "INSTRUCTION_UPDATE_METADATA", CSYNC_INSTRUCTION_UPDATE_METADATA },
- { NULL, CSYNC_INSTRUCTION_ERROR }
+ { nullptr, CSYNC_INSTRUCTION_ERROR }
};
struct csync_memstat_s {
{
int idx = 0;
- while (_instr[idx].instr_str != NULL) {
+ while (_instr[idx].instr_str != nullptr) {
if (_instr[idx].instr_code == instr) {
return _instr[idx].instr_str;
}
/* get process memory stats */
fp = fopen("/proc/self/statm","r");
- if (fp == NULL) {
+ if (fp == nullptr) {
return;
}
s = fscanf(fp, "%d%d%d%d%d%d%d", &m.size, &m.resident, &m.shared, &m.trs,
/* Convert a locale String to UTF8 */
QByteArray c_utf8_from_locale(const mbchar_t *wstr)
{
- if (wstr == NULL) {
+ if (wstr == nullptr) {
return QByteArray();
}
/* Convert a an UTF8 string to locale */
mbchar_t* c_utf8_string_to_locale(const char *str)
{
- if (str == NULL ) {
- return NULL;
+ if (str == nullptr ) {
+ return nullptr;
}
#ifdef _WIN32
mbchar_t *dst = NULL;
mbchar_t* c_utf8_path_to_locale(const char *str)
{
- if( str == NULL ) {
- return NULL;
+ if( str == nullptr ) {
+ return nullptr;
} else {
#ifdef _WIN32
size_t strLength = strlen(str);
default:
ASSERT(false);
}
- return NULL;
+ return nullptr;
}
int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle) {
int rc = -1;
- if (dhandle == NULL) {
+ if (dhandle == nullptr) {
errno = EBADF;
return -1;
}
ASSERT(false);
}
- return NULL;
+ return nullptr;
}
char *csync_vio_get_status_string(CSYNC *ctx) {
if(ctx->error_string) {
return ctx->error_string;
}
- return 0;
+ return nullptr;
}
static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf);
csync_vio_handle_t *csync_vio_local_opendir(const char *name) {
- dhandle_t *handle = NULL;
- mbchar_t *dirname = NULL;
+ dhandle_t *handle = nullptr;
+ mbchar_t *dirname = nullptr;
handle = (dhandle_t*)c_malloc(sizeof(dhandle_t));
dirname = c_utf8_path_to_locale(name);
handle->dh = _topendir( dirname );
- if (handle->dh == NULL) {
+ if (handle->dh == nullptr) {
c_free_locale_string(dirname);
SAFE_FREE(handle);
- return NULL;
+ return nullptr;
}
handle->path = c_strdup(name);
}
int csync_vio_local_closedir(csync_vio_handle_t *dhandle) {
- dhandle_t *handle = NULL;
+ dhandle_t *handle = nullptr;
int rc = -1;
- if (dhandle == NULL) {
+ if (dhandle == nullptr) {
errno = EBADF;
return -1;
}
std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *dhandle) {
- dhandle_t *handle = NULL;
+ dhandle_t *handle = nullptr;
handle = (dhandle_t *) dhandle;
- struct _tdirent *dirent = NULL;
+ struct _tdirent *dirent = nullptr;
std::unique_ptr<csync_file_stat_t> file_stat;
do {
dirent = _treaddir(handle->dh);
- if (dirent == NULL)
+ if (dirent == nullptr)
return {};
} while (qstrcmp(dirent->d_name, ".") == 0 || qstrcmp(dirent->d_name, "..") == 0);
return;
}
- _ui.folderTreeWidget->setCurrentItem(0);
+ _ui.folderTreeWidget->setCurrentItem(nullptr);
_lscolTimer.start(); // avoid sending a request on each keystroke
}
LsColJob *job = runLsColJob(path);
// No error handling, no updating, we do this manually
// because of extra logic in the typed-path case.
- disconnect(job, 0, this, 0);
+ disconnect(job, nullptr, this, nullptr);
connect(job, &LsColJob::finishedWithError,
this, &FolderWizardRemotePath::slotTypedPathError);
connect(job, &LsColJob::directoryListingSubfolders,
{
QStyle *style = parentWidget()->style();
//const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
- int topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, parentWidget());
- int topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, parentWidget());
- int topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, parentWidget());
+ int topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, parentWidget());
+ int topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, parentWidget());
+ int topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, parentWidget());
//int topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, parentWidget());
layout->setRowMinimumHeight(0, ModernHeaderTopMargin);
void WebViewPageUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request) {
QUrl url = request->requestUrl();
- QString path = url.path(0).mid(1); // get undecoded path
+ QString path = url.path(nullptr).mid(1); // get undecoded path
const QStringList parts = path.split("&");
QString server;
Logger::~Logger()
{
#ifndef NO_MSG_HANDLER
- qInstallMessageHandler(0);
+ qInstallMessageHandler(nullptr);
#endif
}