Use null QString instead of empty
Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
parent
d9884f0d03
commit
caff4b884f
2 changed files with 13 additions and 13 deletions
|
@ -905,19 +905,19 @@ QString createShortcut(QString destination, QString target, QStringList args, QS
|
||||||
}
|
}
|
||||||
if (!ensureFilePathExists(destination)) {
|
if (!ensureFilePathExists(destination)) {
|
||||||
qWarning() << "Destination path can't be created!";
|
qWarning() << "Destination path can't be created!";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
#if defined(Q_OS_MACOS)
|
#if defined(Q_OS_MACOS)
|
||||||
QDir application = destination + ".app/";
|
QDir application = destination + ".app/";
|
||||||
|
|
||||||
if (application.exists()) {
|
if (application.exists()) {
|
||||||
qWarning() << "Application already exists!";
|
qWarning() << "Application already exists!";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!application.mkpath(".")) {
|
if (!application.mkpath(".")) {
|
||||||
qWarning() << "Couldn't create application";
|
qWarning() << "Couldn't create application";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir content = application.path() + "/Contents/";
|
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("."))) {
|
if (!(content.mkpath(".") && resources.mkpath(".") && binaryDir.mkpath("."))) {
|
||||||
qWarning() << "Couldn't create directories within application";
|
qWarning() << "Couldn't create directories within application";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
info.open(QIODevice::WriteOnly | QIODevice::Text);
|
info.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
|
|
||||||
|
@ -1008,26 +1008,26 @@ QString createShortcut(QString destination, QString target, QStringList args, QS
|
||||||
|
|
||||||
if (!targetInfo.exists()) {
|
if (!targetInfo.exists()) {
|
||||||
qWarning() << "Target file does not exist!";
|
qWarning() << "Target file does not exist!";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
target = targetInfo.absoluteFilePath();
|
target = targetInfo.absoluteFilePath();
|
||||||
|
|
||||||
if (target.length() >= MAX_PATH) {
|
if (target.length() >= MAX_PATH) {
|
||||||
qWarning() << "Target file path is too long!";
|
qWarning() << "Target file path is too long!";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!icon.isEmpty() && icon.length() >= MAX_PATH) {
|
if (!icon.isEmpty() && icon.length() >= MAX_PATH) {
|
||||||
qWarning() << "Icon path is too long!";
|
qWarning() << "Icon path is too long!";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
destination += ".lnk";
|
destination += ".lnk";
|
||||||
|
|
||||||
if (destination.length() >= MAX_PATH) {
|
if (destination.length() >= MAX_PATH) {
|
||||||
qWarning() << "Destination path is too long!";
|
qWarning() << "Destination path is too long!";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString argStr;
|
QString argStr;
|
||||||
|
@ -1046,7 +1046,7 @@ QString createShortcut(QString destination, QString target, QStringList args, QS
|
||||||
|
|
||||||
if (argStr.length() >= MAX_PATH) {
|
if (argStr.length() >= MAX_PATH) {
|
||||||
qWarning() << "Arguments string is too long!";
|
qWarning() << "Arguments string is too long!";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
@ -1055,7 +1055,7 @@ QString createShortcut(QString destination, QString target, QStringList args, QS
|
||||||
hres = CoInitialize(nullptr);
|
hres = CoInitialize(nullptr);
|
||||||
if (FAILED(hres)) {
|
if (FAILED(hres)) {
|
||||||
qWarning() << "Failed to initialize COM!";
|
qWarning() << "Failed to initialize COM!";
|
||||||
return "";
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
WCHAR wsz[MAX_PATH];
|
WCHAR wsz[MAX_PATH];
|
||||||
|
@ -1111,10 +1111,10 @@ QString createShortcut(QString destination, QString target, QStringList args, QS
|
||||||
|
|
||||||
if (SUCCEEDED(hres))
|
if (SUCCEEDED(hres))
|
||||||
return destination;
|
return destination;
|
||||||
return "";
|
return QString();
|
||||||
#else
|
#else
|
||||||
qWarning("Desktop Shortcuts not supported on your platform!");
|
qWarning("Desktop Shortcuts not supported on your platform!");
|
||||||
return "";
|
return QString();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* 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);
|
QString createShortcut(QString destination, QString target, QStringList args, QString name, QString icon);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue