From caff4b884f7037f646bedac59da01fcd4340525e Mon Sep 17 00:00:00 2001 From: Yihe Li Date: Sun, 1 Jun 2025 18:31:27 +0800 Subject: [PATCH] Use null QString instead of empty Signed-off-by: Yihe Li --- launcher/FileSystem.cpp | 24 ++++++++++++------------ launcher/FileSystem.h | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index c5386a43b..5136e7954 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -905,19 +905,19 @@ QString createShortcut(QString destination, QString target, QStringList args, QS } if (!ensureFilePathExists(destination)) { qWarning() << "Destination path can't be created!"; - return ""; + return QString(); } #if defined(Q_OS_MACOS) QDir application = destination + ".app/"; if (application.exists()) { qWarning() << "Application already exists!"; - return ""; + return QString(); } if (!application.mkpath(".")) { qWarning() << "Couldn't create application"; - return ""; + return QString(); } QDir content = application.path() + "/Contents/"; @@ -927,7 +927,7 @@ QString createShortcut(QString destination, QString target, QStringList args, QS if (!(content.mkpath(".") && resources.mkpath(".") && binaryDir.mkpath("."))) { qWarning() << "Couldn't create directories within application"; - return ""; + return QString(); } info.open(QIODevice::WriteOnly | QIODevice::Text); @@ -1008,26 +1008,26 @@ QString createShortcut(QString destination, QString target, QStringList args, QS if (!targetInfo.exists()) { qWarning() << "Target file does not exist!"; - return ""; + return QString(); } target = targetInfo.absoluteFilePath(); if (target.length() >= MAX_PATH) { qWarning() << "Target file path is too long!"; - return ""; + return QString(); } if (!icon.isEmpty() && icon.length() >= MAX_PATH) { qWarning() << "Icon path is too long!"; - return ""; + return QString(); } destination += ".lnk"; if (destination.length() >= MAX_PATH) { qWarning() << "Destination path is too long!"; - return ""; + return QString(); } QString argStr; @@ -1046,7 +1046,7 @@ QString createShortcut(QString destination, QString target, QStringList args, QS if (argStr.length() >= MAX_PATH) { qWarning() << "Arguments string is too long!"; - return ""; + return QString(); } HRESULT hres; @@ -1055,7 +1055,7 @@ QString createShortcut(QString destination, QString target, QStringList args, QS hres = CoInitialize(nullptr); if (FAILED(hres)) { qWarning() << "Failed to initialize COM!"; - return ""; + return QString(); } WCHAR wsz[MAX_PATH]; @@ -1111,10 +1111,10 @@ QString createShortcut(QString destination, QString target, QStringList args, QS if (SUCCEEDED(hres)) return destination; - return ""; + return QString(); #else qWarning("Desktop Shortcuts not supported on your platform!"); - return ""; + return QString(); #endif } diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h index 83cf41d7f..0e573a09e 100644 --- a/launcher/FileSystem.h +++ b/launcher/FileSystem.h @@ -362,7 +362,7 @@ bool overrideFolder(QString overwritten_path, QString override_path); /** * Creates a shortcut to the specified target file at the specified destination path. - * Returns empty string if creation failed; otherwise returns the path to the created shortcut. + * Returns null QString if creation failed; otherwise returns the path to the created shortcut. */ QString createShortcut(QString destination, QString target, QStringList args, QString name, QString icon);