appro: 添加一些基本判空判断

This commit is contained in:
taynpg 2024-04-12 08:57:49 +08:00
parent 29b29b1507
commit b208dddf4f
2 changed files with 9 additions and 1 deletions

View File

@ -7,7 +7,7 @@
MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget)
{
ui->setupUi(this);
setWindowTitle("packqt v1.0.1");
setWindowTitle("packqt v1.0.2");
connect_operator();
control_init();
}

View File

@ -60,6 +60,10 @@ void AddDesktop::install_to_desktop()
}
std::string binaryPath = ui->edBinary->text().trimmed().toStdString();
if (binaryPath.empty()) {
MainWidget::message(this, "二进制路径为空");
return;
}
std::string binaryName = fs::path(binaryPath).filename().string();
fs::path sh_path = fs::path(binaryPath).parent_path().append("run.sh");
if (!fs::exists(sh_path)) {
@ -89,6 +93,10 @@ void AddDesktop::install_to_desktop()
} else {
std::string icn = ui->edIco->text().trimmed().toStdString();
if (icn.empty()) {
MainWidget::message(this, "图标路径为空");
return;
}
default_ico_path.append(fs::path(icn).filename());
boost::replace_all(ct, "re_icon", default_ico_path.string());
fs::copy_file(icn, default_ico_path, fs::copy_options::overwrite_existing);