Skip to content

Commit a9761a8

Browse files
committedOct 19, 2017
Use qEnvironmentVariable* instead of qgetenv when appropriate
Now that we use Qt5, we should do that. It is slightly more efficient and declares the intent. (Modified using clazy)
1 parent 84d8624 commit a9761a8

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed
 

‎src/common/checksums.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ QByteArray parseChecksumHeaderType(const QByteArray &header)
120120

121121
bool uploadChecksumEnabled()
122122
{
123-
static bool enabled = qgetenv("OWNCLOUD_DISABLE_CHECKSUM_UPLOAD").isEmpty();
123+
static bool enabled = qEnvironmentVariableIsEmpty("OWNCLOUD_DISABLE_CHECKSUM_UPLOAD");
124124
return enabled;
125125
}
126126

‎src/common/utility.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ bool Utility::isConflictFile(const char *name)
579579

580580
bool Utility::shouldUploadConflictFiles()
581581
{
582-
static bool uploadConflictFiles = qgetenv("OWNCLOUD_UPLOAD_CONFLICT_FILES").toInt() != 0;
582+
static bool uploadConflictFiles = qEnvironmentVariableIntValue("OWNCLOUD_UPLOAD_CONFLICT_FILES") != 0;
583583
return uploadConflictFiles;
584584
}
585585

‎src/gui/creds/shibboleth/shibbolethwebview.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class UserAgentWebPage : public QWebPage
4343
UserAgentWebPage(QObject *parent)
4444
: QWebPage(parent)
4545
{
46-
if (!qgetenv("OWNCLOUD_SHIBBOLETH_DEBUG").isEmpty()) {
46+
if (!qEnvironmentVariableIsEmpty("OWNCLOUD_SHIBBOLETH_DEBUG")) {
4747
settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
4848
}
4949
}
@@ -83,7 +83,7 @@ ShibbolethWebView::ShibbolethWebView(AccountPtr account, QWidget *parent)
8383
setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI()));
8484

8585
// Debug view to display the cipher suite
86-
if (!qgetenv("OWNCLOUD_SHIBBOLETH_DEBUG").isEmpty()) {
86+
if (!qEnvironmentVariableIsEmpty("OWNCLOUD_SHIBBOLETH_DEBUG")) {
8787
// open an additional window to display some cipher debug info
8888
QWebPage *debugPage = new UserAgentWebPage(this);
8989
debugPage->mainFrame()->load(QUrl("https://cc.dcsec.uni-hannover.de/"));

‎src/gui/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int main(int argc, char **argv)
8888

8989
// check a environment variable for core dumps
9090
#ifdef Q_OS_UNIX
91-
if (!qgetenv("OWNCLOUD_CORE_DUMP").isEmpty()) {
91+
if (!qEnvironmentVariableIsEmpty("OWNCLOUD_CORE_DUMP")) {
9292
struct rlimit core_limit;
9393
core_limit.rlim_cur = RLIM_INFINITY;
9494
core_limit.rlim_max = RLIM_INFINITY;

‎src/libsync/owncloudpropagator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ PropagateItemJob::~PropagateItemJob()
114114

115115
static qint64 getMinBlacklistTime()
116116
{
117-
return qMax(qgetenv("OWNCLOUD_BLACKLIST_TIME_MIN").toInt(),
117+
return qMax(qEnvironmentVariableIntValue("OWNCLOUD_BLACKLIST_TIME_MIN"),
118118
25); // 25 seconds
119119
}
120120

121121
static qint64 getMaxBlacklistTime()
122122
{
123-
int v = qgetenv("OWNCLOUD_BLACKLIST_TIME_MAX").toInt();
123+
int v = qEnvironmentVariableIntValue("OWNCLOUD_BLACKLIST_TIME_MAX");
124124
if (v > 0)
125125
return v;
126126
return 24 * 60 * 60; // 1 day

‎src/libsync/syncengine.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
10311031
_progressInfo->startEstimateUpdates();
10321032

10331033
// post update phase script: allow to tweak stuff by a custom script in debug mode.
1034-
if (!qgetenv("OWNCLOUD_POST_UPDATE_SCRIPT").isEmpty()) {
1034+
if (!qEnvironmentVariableIsEmpty("OWNCLOUD_POST_UPDATE_SCRIPT")) {
10351035
#ifndef NDEBUG
10361036
QString script = qgetenv("OWNCLOUD_POST_UPDATE_SCRIPT");
10371037

@@ -1464,7 +1464,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
14641464

14651465
RemotePermissions SyncEngine::getPermissions(const QString &file) const
14661466
{
1467-
static bool isTest = qgetenv("OWNCLOUD_TEST_PERMISSIONS").toInt();
1467+
static bool isTest = qEnvironmentVariableIntValue("OWNCLOUD_TEST_PERMISSIONS");
14681468
if (isTest) {
14691469
QRegExp rx("_PERM_([^_]*)_[^/]*$");
14701470
if (rx.indexIn(file) != -1) {

0 commit comments

Comments
 (0)
Please sign in to comment.