mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-18 19:42:21 +08:00
fix: 修复退出时崩溃问题
AppIntoPage 析构函数中使用 free 释放 rawHeaders 指针存在问题 Log: 使用 QByteArray 全局变量存储 User-Agent 字符串,无需使用指针,避免析构问题
This commit is contained in:
parent
62e23facfb
commit
0c4f5dacca
src/pages
@ -22,15 +22,12 @@ AppIntoPage::AppIntoPage(QWidget *parent)
|
||||
{
|
||||
initUI();
|
||||
initConnections();
|
||||
QString headers = "Mozilla/5.0 Spark-Store/"+ QString(APP_VERSION)+" (Linux; "+QSysInfo::prettyProductName().toUtf8()+";)";
|
||||
QByteArray ba = headers.toLatin1(); // must
|
||||
rawHeaders=ba.data();
|
||||
m_userAgent = QString("Mozilla/5.0 Spark-Store/" + QString(APP_VERSION) + " (Linux; " + QSysInfo::prettyProductName().toUtf8() + ";)").toLatin1();
|
||||
}
|
||||
|
||||
AppIntoPage::~AppIntoPage()
|
||||
{
|
||||
delete ui;
|
||||
free(rawHeaders);
|
||||
}
|
||||
|
||||
void AppIntoPage::openUrl(const QUrl &url)
|
||||
@ -74,8 +71,8 @@ void AppIntoPage::openUrl(const QUrl &url)
|
||||
// 获取图标
|
||||
QNetworkRequest iconRequest;
|
||||
iconRequest.setUrl(QUrl(pkgUrlBase + "/icon.png"));
|
||||
iconRequest.setRawHeader("User-Agent", rawHeaders);
|
||||
iconRequest.setRawHeader("Content-Type", "charset='utf-8'");
|
||||
iconRequest.setHeader(QNetworkRequest::UserAgentHeader, m_userAgent);
|
||||
iconRequest.setHeader(QNetworkRequest::ContentTypeHeader, "charset='utf-8'");
|
||||
|
||||
iconManager->get(iconRequest);
|
||||
QObject::connect(iconManager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
|
||||
@ -97,8 +94,8 @@ void AppIntoPage::openUrl(const QUrl &url)
|
||||
QNetworkRequest request;
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
request.setUrl(QUrl(imgUrl));
|
||||
request.setRawHeader("User-Agent", rawHeaders);
|
||||
request.setRawHeader("Content-Type", "charset='utf-8'");
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, m_userAgent);
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "charset='utf-8'");
|
||||
manager->get(request);
|
||||
QObject::connect(manager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
|
||||
{
|
||||
|
@ -30,8 +30,6 @@ private:
|
||||
void isDownloading(const QUrl &url);
|
||||
void setAppinfoTags(const QStringList &tagList);
|
||||
void notifyUserUnsupportedTags(bool ubuntuSupport, bool deepinSupport, bool uosSupport);
|
||||
char* rawHeaders;
|
||||
QMap<int, QPixmap> imageMap;
|
||||
|
||||
signals:
|
||||
void clickedDownloadBtn();
|
||||
@ -51,6 +49,8 @@ private:
|
||||
QJsonObject info;
|
||||
QPixmap iconpixmap;
|
||||
QUrl spk;
|
||||
|
||||
QByteArray m_userAgent;
|
||||
};
|
||||
|
||||
#endif // APPINTOPAGE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user