mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-11 08:05:59 +08:00
修复快速从应用列表进入应用详情时的崩溃
正确地断开过期的信号,正确地处理过期的请求
This commit is contained in:
parent
6491b19f6e
commit
2e04d05b34
@ -148,6 +148,7 @@ namespace SpkUi
|
||||
void SpkPageAppDetails::ResourceAcquisitionFinished(int id, ResourceResult result)
|
||||
{
|
||||
QPixmap icon;
|
||||
// qDebug() << "PageAppDetails: Resource" << id << "acquired";
|
||||
if(!id)
|
||||
{
|
||||
// id == 0, icon
|
||||
|
@ -97,6 +97,7 @@ namespace SpkUi
|
||||
void SpkPageAppList::ResourceAcquisitionFinished(int id, ResourceResult result)
|
||||
{
|
||||
QPixmap icon;
|
||||
// qDebug() << "PageAppList: Resource" << id << "acquired";
|
||||
auto item = mAppItemList[id];
|
||||
if(result.status == SpkResource::ResourceStatus::Ready)
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ void SpkResource::ResourceDownloaded()
|
||||
if(!QDir().mkpath(path))
|
||||
{
|
||||
sWarn(tr("Cache directory \"%1\" cannot be created.").arg(path));
|
||||
return;
|
||||
goto ContinueNext;
|
||||
}
|
||||
}
|
||||
if(writeCache.open(QFile::WriteOnly))
|
||||
@ -85,32 +85,41 @@ void SpkResource::ResourceDownloaded()
|
||||
else
|
||||
sWarn("Save cache to \"" + cacheFile + "\" failed! Msg: " + writeCache.errorString());
|
||||
|
||||
qInfo() << "Resource " << reply->property("dest_file").toString() << " downloaded";
|
||||
|
||||
// Tell ResourceContext
|
||||
AcquisitionFinish(id, ret);
|
||||
if(!reply->property("outdated").toBool())
|
||||
AcquisitionFinish(id, ret);
|
||||
|
||||
ContinueNext:
|
||||
// Start next possible mission
|
||||
TryBeginAwaitingTasks();
|
||||
}
|
||||
|
||||
void SpkResource::Acquire(SpkPageBase *dest, bool stopOngoing, bool clearQueue)
|
||||
{
|
||||
for(auto &i : mWorkingRequests.keys())
|
||||
{
|
||||
// Don't let an outdated task falsely report a finish signal.
|
||||
// This is the designed way of stopping it from emitting a finish signal
|
||||
i->setProperty("outdated", true);
|
||||
// And abort as requested.
|
||||
if(stopOngoing)
|
||||
i->abort();
|
||||
delete i;
|
||||
}
|
||||
|
||||
if(stopOngoing)
|
||||
{
|
||||
for(auto &i : mWorkingRequests.keys())
|
||||
{
|
||||
// Don't let forced abort falsely report a finish signal. Disconnect them first.
|
||||
i->disconnect(i, &QNetworkReply::finished, this, &SpkResource::ResourceDownloaded);
|
||||
i->abort();
|
||||
delete i;
|
||||
}
|
||||
mWorkingRequests.clear();
|
||||
|
||||
mRequestSemaphore->release(mMaximumConcurrent); // Release all semaphore users
|
||||
}
|
||||
|
||||
if(clearQueue)
|
||||
mAwaitingRequests.clear();
|
||||
|
||||
disconnect(this, SLOT(AcquisitionFinish(int, ResourceResult)));
|
||||
auto discResult = disconnect(this, SIGNAL(AcquisitionFinish(int, ResourceResult)), nullptr, nullptr);
|
||||
// qDebug() << "SpkResource: Acquisition disconnection" << (discResult ? "success" : "failure");
|
||||
|
||||
connect(this, &SpkResource::AcquisitionFinish,
|
||||
dest, &SpkPageBase::ResourceAcquisitionFinished,
|
||||
|
Loading…
x
Reference in New Issue
Block a user