Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace 0 with nullptr
Prevents a lot of warnings seen in QtCreator

Change-Id: I63bf95aca68a04fc9fd0eecbe29c63e9b9c47efd
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
  • Loading branch information
kahema committed Jan 9, 2019
1 parent 818c8ab commit 9dacee1
Show file tree
Hide file tree
Showing 51 changed files with 199 additions and 199 deletions.
2 changes: 1 addition & 1 deletion src/libs/installer/binaryformat.cpp
Expand Up @@ -293,7 +293,7 @@ void ResourceCollection::setName(const QByteArray &name)
void ResourceCollection::appendResource(const QSharedPointer<Resource>& resource)
{
Q_ASSERT(resource);
resource->setParent(0);
resource->setParent(nullptr);
m_resources.append(resource);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/installer/binaryformatengine.cpp
Expand Up @@ -81,7 +81,7 @@ namespace QInstaller {
*/
BinaryFormatEngine::BinaryFormatEngine(const QHash<QByteArray, ResourceCollection> &collections,
const QString &fileName)
: m_resource(0)
: m_resource(nullptr)
, m_collections(collections)
{
setFileName(fileName);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/installer/binaryformatenginehandler.cpp
Expand Up @@ -48,7 +48,7 @@ namespace QInstaller {
QAbstractFileEngine *BinaryFormatEngineHandler::create(const QString &fileName) const
{
return fileName.startsWith(QLatin1String("installer://"), Qt::CaseInsensitive )
? new BinaryFormatEngine(m_resources, fileName) : 0;
? new BinaryFormatEngine(m_resources, fileName) : nullptr;
}

/*!
Expand Down
12 changes: 6 additions & 6 deletions src/libs/installer/component_p.cpp
Expand Up @@ -41,9 +41,9 @@ namespace QInstaller {
ComponentPrivate::ComponentPrivate(PackageManagerCore *core, Component *qq)
: q(qq)
, m_core(core)
, m_parentComponent(0)
, m_licenseOperation(0)
, m_minimumProgressOperation(0)
, m_parentComponent(nullptr)
, m_licenseOperation(nullptr)
, m_minimumProgressOperation(nullptr)
, m_newlyInstalled (false)
, m_operationsCreated(false)
, m_autoCreateOperations(true)
Expand Down Expand Up @@ -98,11 +98,11 @@ int ComponentModelHelper::childCount() const
Component *ComponentModelHelper::childAt(int index) const
{
if (index < 0 && index >= childCount())
return 0;
return nullptr;

if (m_componentPrivate->m_core->virtualComponentsVisible())
return m_componentPrivate->m_allChildComponents.value(index, 0);
return m_componentPrivate->m_childComponents.value(index, 0);
return m_componentPrivate->m_allChildComponents.value(index, nullptr);
return m_componentPrivate->m_childComponents.value(index, nullptr);
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion src/libs/installer/componentmodel.cpp
Expand Up @@ -378,7 +378,7 @@ Component *ComponentModel::componentFromIndex(const QModelIndex &index) const
{
if (index.isValid())
return static_cast<Component*>(index.internalPointer());
return 0;
return nullptr;
}


Expand Down
2 changes: 1 addition & 1 deletion src/libs/installer/componentselectionpage_p.cpp
Expand Up @@ -380,7 +380,7 @@ void ComponentSelectionPagePrivate::customButtonClicked(int which)
if (QWizard::WizardButton(which) == QWizard::CustomButton2) {
QString defaultDownloadDirectory =
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
QStringList fileNames = QFileDialog::getOpenFileNames(NULL,
QStringList fileNames = QFileDialog::getOpenFileNames(nullptr,
ComponentSelectionPage::tr("Open File"),defaultDownloadDirectory,
QLatin1String("QBSP or 7z Files (*.qbsp *.7z)"));

Expand Down
2 changes: 1 addition & 1 deletion src/libs/installer/copyfiletask.cpp
Expand Up @@ -104,7 +104,7 @@ void CopyFileTask::doTask(QFutureInterface<FileTaskResult> &fi)
}

observer.addSample(read);
observer.timerEvent(NULL);
observer.timerEvent(nullptr);
observer.addBytesTransfered(read);
observer.addCheckSumData(buffer.data(), read);

Expand Down
2 changes: 1 addition & 1 deletion src/libs/installer/createlocalrepositoryoperation.cpp
Expand Up @@ -251,7 +251,7 @@ bool CreateLocalRepositoryOperation::performOperation()

// start to read the binary layout
ResourceCollectionManager manager;
BinaryContent::readBinaryContent(&file, 0, &manager, 0, BinaryContent::MagicCookie);
BinaryContent::readBinaryContent(&file, nullptr, &manager, 0, BinaryContent::MagicCookie);

emit progressChanged(0.65);

Expand Down
8 changes: 4 additions & 4 deletions src/libs/installer/createshortcutoperation.cpp
Expand Up @@ -50,7 +50,7 @@ typedef ITEMIDLIST *PIDLIST_ABSOLUTE;
struct DeCoInitializer
{
DeCoInitializer()
: neededCoInit(CoInitialize(NULL) == S_OK)
: neededCoInit(CoInitialize(nullptr) == S_OK)
{
}
~DeCoInitializer()
Expand Down Expand Up @@ -100,12 +100,12 @@ static bool createLink(const QString &fileName, const QString &linkName, QString
// CoInitialize cleanup object
DeCoInitializer _;

IUnknown *iunkn = NULL;
IUnknown *iunkn = nullptr;

if (fileName.toLower().startsWith(QLatin1String("http:"))
|| fileName.toLower().startsWith(QLatin1String("ftp:"))) {
IUniformResourceLocator *iurl = NULL;
if (FAILED(CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER,
IUniformResourceLocator *iurl = nullptr;
if (FAILED(CoCreateInstance(CLSID_InternetShortcut, nullptr, CLSCTX_INPROC_SERVER,
IID_IUniformResourceLocator, (LPVOID*)&iurl))) {
return false;
}
Expand Down
14 changes: 7 additions & 7 deletions src/libs/installer/downloadarchivesjob.cpp
Expand Up @@ -49,7 +49,7 @@ using namespace KDUpdater;
DownloadArchivesJob::DownloadArchivesJob(PackageManagerCore *core)
: Job(core)
, m_core(core)
, m_downloader(0)
, m_downloader(nullptr)
, m_archivesDownloaded(0)
, m_archivesToDownloadCount(0)
, m_canceled(false)
Expand Down Expand Up @@ -93,7 +93,7 @@ void DownloadArchivesJob::doStart()
void DownloadArchivesJob::doCancel()
{
m_canceled = true;
if (m_downloader != 0)
if (m_downloader != nullptr)
m_downloader->cancelDownload();
}

Expand Down Expand Up @@ -130,7 +130,7 @@ void DownloadArchivesJob::fetchNextArchiveHash()

void DownloadArchivesJob::finishedHashDownload()
{
Q_ASSERT(m_downloader != 0);
Q_ASSERT(m_downloader != nullptr);

QFile sha1HashFile(m_downloader->downloadedFileName());
if (sha1HashFile.open(QFile::ReadOnly)) {
Expand All @@ -156,7 +156,7 @@ void DownloadArchivesJob::fetchNextArchive()
return;
}

if (m_downloader != 0)
if (m_downloader != nullptr)
m_downloader->deleteLater();

m_downloader = setupDownloader(QString(), m_core->value(scUrlQueryString));
Expand Down Expand Up @@ -202,7 +202,7 @@ void DownloadArchivesJob::timerEvent(QTimerEvent *event)
*/
void DownloadArchivesJob::registerFile()
{
Q_ASSERT(m_downloader != 0);
Q_ASSERT(m_downloader != nullptr);

if (m_canceled)
return;
Expand Down Expand Up @@ -259,15 +259,15 @@ void DownloadArchivesJob::finishWithError(const QString &error)
{
const FileDownloader *const dl = qobject_cast<const FileDownloader*> (sender());
const QString msg = tr("Cannot fetch archives: %1\nError while loading %2");
if (dl != 0)
if (dl != nullptr)
emitFinishedWithError(QInstaller::DownloadError, msg.arg(error, dl->url().toString()));
else
emitFinishedWithError(QInstaller::DownloadError, msg.arg(error, m_downloader->url().toString()));
}

KDUpdater::FileDownloader *DownloadArchivesJob::setupDownloader(const QString &suffix, const QString &queryString)
{
KDUpdater::FileDownloader *downloader = 0;
KDUpdater::FileDownloader *downloader = nullptr;
const QFileInfo fi = QFileInfo(m_archivesToDownload.first().first);
const Component *const component = m_core->componentByName(PackageManagerCore::checkableName(QFileInfo(fi.path()).fileName()));
if (component) {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/installer/elevatedexecuteoperation.cpp
Expand Up @@ -43,7 +43,7 @@ class ElevatedExecuteOperation::Private
public:
explicit Private(ElevatedExecuteOperation *qq)
: q(qq)
, process(0)
, process(nullptr)
, showStandardError(false)
{
}
Expand Down Expand Up @@ -221,7 +221,7 @@ bool ElevatedExecuteOperation::Private::run(const QStringList &arguments)
Q_ASSERT(process);
Q_ASSERT(process->state() == QProcessWrapper::NotRunning);
delete process;
process = 0;
process = nullptr;

return returnValue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/installer/environmentvariablesoperation.cpp
Expand Up @@ -83,8 +83,8 @@ bool handleRegExpandSz(const QString &regPath, const QString &name,
if (res == ERROR_SUCCESS) {
DWORD dataType;
DWORD dataSize;
res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(name.utf16()), 0,
&dataType, 0, &dataSize);
res = RegQueryValueEx(handle, reinterpret_cast<const wchar_t *>(name.utf16()), nullptr,
&dataType, nullptr, &dataSize);
setAsExpandSZ = (res == ERROR_SUCCESS) && (dataType == REG_EXPAND_SZ);
if (setAsExpandSZ) {
RegCloseKey(handle);
Expand Down
6 changes: 3 additions & 3 deletions src/libs/installer/fileutils.cpp
Expand Up @@ -239,7 +239,7 @@ void QInstaller::removeDirectory(const QString &path, bool ignoreErrors)
class RemoveDirectoryThread : public QThread
{
public:
explicit RemoveDirectoryThread(const QString &path, bool ignoreErrors = false, QObject *parent = 0)
explicit RemoveDirectoryThread(const QString &path, bool ignoreErrors = false, QObject *parent = nullptr)
: QThread(parent)
, p(path)
, ignore(ignoreErrors)
Expand Down Expand Up @@ -411,7 +411,7 @@ QString QInstaller::getShortPathName(const QString &name)

// Determine length, then convert.
const LPCTSTR nameC = reinterpret_cast<LPCTSTR>(name.utf16()); // MinGW
const DWORD length = GetShortPathName(nameC, NULL, 0);
const DWORD length = GetShortPathName(nameC, nullptr, 0);
if (length == 0)
return name;
QScopedArrayPointer<TCHAR> buffer(new TCHAR[length]);
Expand All @@ -427,7 +427,7 @@ QString QInstaller::getLongPathName(const QString &name)

// Determine length, then convert.
const LPCTSTR nameC = reinterpret_cast<LPCTSTR>(name.utf16()); // MinGW
const DWORD length = GetLongPathName(nameC, NULL, 0);
const DWORD length = GetLongPathName(nameC, nullptr, 0);
if (length == 0)
return name;
QScopedArrayPointer<TCHAR> buffer(new TCHAR[length]);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/installer/globalsettingsoperation.cpp
Expand Up @@ -96,7 +96,7 @@ bool GlobalSettingsOperation::testOperation()
QSettingsWrapper *GlobalSettingsOperation::setup(QString *key, QString *value, const QStringList &arguments)
{
if (!checkArgumentCount(3, 5))
return 0;
return nullptr;

if (arguments.count() == 5) {
QSettingsWrapper::Scope scope = QSettingsWrapper::UserScope;
Expand All @@ -120,5 +120,5 @@ QSettingsWrapper *GlobalSettingsOperation::setup(QString *key, QString *value, c
return new QSettingsWrapper(filename, QSettingsWrapper::NativeFormat);
}

return 0;
return nullptr;
}
2 changes: 1 addition & 1 deletion src/libs/installer/init.cpp
Expand Up @@ -130,7 +130,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
std::cout << qPrintable(ba) << std::endl;

if (type == QtFatalMsg) {
QtMessageHandler oldMsgHandler = qInstallMessageHandler(0);
QtMessageHandler oldMsgHandler = qInstallMessageHandler(nullptr);
qt_message_output(type, context, msg);
qInstallMessageHandler(oldMsgHandler);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/installer/keepaliveobject.cpp
Expand Up @@ -35,8 +35,8 @@
namespace QInstaller {

KeepAliveObject::KeepAliveObject()
: m_timer(0)
, m_socket(0)
: m_timer(nullptr)
, m_socket(nullptr)
{
}

Expand Down
16 changes: 8 additions & 8 deletions src/libs/installer/lib7z_facade.cpp
Expand Up @@ -64,7 +64,7 @@
#include <memory>

#ifdef Q_OS_WIN
HINSTANCE g_hInstance = 0;
HINSTANCE g_hInstance = nullptr;

# define S_IFMT 00170000
# define S_IFLNK 0120000
Expand Down Expand Up @@ -353,16 +353,16 @@ static quint32 getUInt32Property(IInArchive *archive, int index, int propId, qui
static QFile::Permissions getPermissions(IInArchive *archive, int index, bool *hasPermissions)
{
quint32 attributes = getUInt32Property(archive, index, kpidAttrib, 0);
QFile::Permissions permissions = 0;
QFile::Permissions permissions = nullptr;
if (attributes & FILE_ATTRIBUTE_UNIX_EXTENSION) {
if (hasPermissions != 0)
if (hasPermissions != nullptr)
*hasPermissions = true;
// filter the Unix permissions
attributes = (attributes >> 16) & 0777;
permissions |= static_cast<QFile::Permissions>((attributes & 0700) << 2); // owner rights
permissions |= static_cast<QFile::Permissions>((attributes & 0070) << 1); // group
permissions |= static_cast<QFile::Permissions>((attributes & 0007) << 0); // and world rights
} else if (hasPermissions != 0) {
} else if (hasPermissions != nullptr) {
*hasPermissions = false;
}
return permissions;
Expand Down Expand Up @@ -536,7 +536,7 @@ QVector<File> listArchive(QFileDevice *archive)
f.archiveIndex.setY(item);
f.path = UString2QString(s).replace(QLatin1Char('\\'), QLatin1Char('/'));
Archive_IsItem_Folder(arch, item, f.isDirectory);
f.permissions = getPermissions(arch, item, 0);
f.permissions = getPermissions(arch, item, nullptr);
getDateTimeProperty(arch, item, kpidMTime, &(f.utcTime));
f.uncompressedSize = getUInt64Property(arch, item, kpidSize, 0);
f.compressedSize = getUInt64Property(arch, item, kpidPackSize, 0);
Expand Down Expand Up @@ -579,7 +579,7 @@ STDMETHODIMP ExtractCallback::SetCompleted(const UInt64 *c)
// CDecoder::CodeSpec extracted content to an output stream.
STDMETHODIMP ExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 /*askExtractMode*/)
{
*outStream = 0;
*outStream = nullptr;
if (targetDir.isEmpty())
return E_FAIL;

Expand Down Expand Up @@ -790,14 +790,14 @@ HRESULT UpdateCallback::OpenFileError(const wchar_t*, DWORD)

HRESULT UpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
{
*password = 0;
*password = nullptr;
*passwordIsDefined = false;
return S_OK;
}

HRESULT UpdateCallback::CryptoGetTextPassword(BSTR *password)
{
*password = 0;
*password = nullptr;
return E_NOTIMPL;
}

Expand Down
14 changes: 7 additions & 7 deletions src/libs/installer/link.cpp
Expand Up @@ -84,8 +84,8 @@ class FileHandleWrapper
: m_dirHandle(INVALID_HANDLE_VALUE)
{
QString normalizedPath = QString(path).replace(QLatin1Char('/'), QLatin1Char('\\'));
m_dirHandle = CreateFile((wchar_t*)normalizedPath.utf16(), GENERIC_READ | GENERIC_WRITE, 0, 0,
OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0);
m_dirHandle = CreateFile((wchar_t*)normalizedPath.utf16(), GENERIC_READ | GENERIC_WRITE, 0, nullptr,
OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, nullptr);

if (m_dirHandle == INVALID_HANDLE_VALUE) {
qWarning() << "Cannot open" << path << ":" << QInstaller::windowsErrorString(GetLastError());
Expand All @@ -112,7 +112,7 @@ QString readWindowsSymLink(const QString &path)
if (dirHandle.handle() != INVALID_HANDLE_VALUE) {
REPARSE_DATA_BUFFER* reparseStructData = (REPARSE_DATA_BUFFER*)calloc(1, MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
DWORD bytesReturned = 0;
if (::DeviceIoControl(dirHandle.handle(), FSCTL_GET_REPARSE_POINT, 0, 0, reparseStructData,
if (::DeviceIoControl(dirHandle.handle(), FSCTL_GET_REPARSE_POINT, nullptr, 0, reparseStructData,
MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned, 0)) {
if (reparseStructData->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
int length = reparseStructData->MountPointReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
Expand Down Expand Up @@ -170,8 +170,8 @@ Link createJunction(const QString &linkPath, const QString &targetPath)

DWORD bytesReturned;
if (!::DeviceIoControl(dirHandle.handle(), FSCTL_SET_REPARSE_POINT, reparseStructData,
reparseStructData->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE, 0, 0,
&bytesReturned, 0)) {
reparseStructData->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE, nullptr, 0,
&bytesReturned, nullptr)) {
qWarning() << "Cannot set the reparse point for" << linkPath << "to" << targetPath
<< ":" << QInstaller::windowsErrorString(GetLastError());
}
Expand All @@ -191,8 +191,8 @@ bool removeJunction(const QString &path)

DWORD bytesReturned;
if (!::DeviceIoControl(dirHandle.handle(), FSCTL_DELETE_REPARSE_POINT, reparseStructData,
REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, 0, 0,
&bytesReturned, 0)) {
REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, nullptr, 0,
&bytesReturned, nullptr)) {

qWarning() << "Cannot remove the reparse point" << path << ":" << QInstaller::windowsErrorString(GetLastError());
return false;
Expand Down

0 comments on commit 9dacee1

Please sign in to comment.