Stop download too if dismiss dialog

This can happen if other place calls dismiss dialog
For example screen pushing by network protocols
This commit is contained in:
Benau 2019-12-06 20:53:43 +08:00
parent a45d4fe9f2
commit 0728722f37
5 changed files with 16 additions and 7 deletions

View File

@ -79,6 +79,7 @@ AddonsLoading::AddonsLoading(const std::string &id)
*/
AddonsLoading::~AddonsLoading()
{
stopDownload();
// Select the last selected item in the addons_screen, so that
// users can keep on installing from the last selected item.
// This dialog can be called in network lobby screen atm for live addon
@ -191,7 +192,6 @@ void AddonsLoading::init()
// ----------------------------------------------------------------------------
bool AddonsLoading::onEscapePressed()
{
stopDownload();
ModalDialog::dismiss();
return true;
} // onEscapePressed
@ -229,7 +229,6 @@ GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event
if(selection == "back")
{
stopDownload();
dismiss();
return GUIEngine::EVENT_BLOCK;
}
@ -345,7 +344,7 @@ void AddonsLoading::stopDownload()
{
m_download_request->cancel();
m_download_request = nullptr;
};
}
} // startDownload

View File

@ -116,6 +116,12 @@ AddonsPack::AddonsPack(const std::string& url) : ModalDialog(0.8f, 0.8f)
m_download_request->queue();
} // AddonsPack
// ----------------------------------------------------------------------------
AddonsPack::~AddonsPack()
{
stopDownload();
} // ~AddonsPack
// ----------------------------------------------------------------------------
void AddonsPack::beforeAddingWidgets()
{
@ -131,7 +137,6 @@ void AddonsPack::init()
// ----------------------------------------------------------------------------
bool AddonsPack::onEscapePressed()
{
stopDownload();
ModalDialog::dismiss();
return true;
} // onEscapePressed
@ -148,7 +153,6 @@ GUIEngine::EventPropagation AddonsPack::processEvent(const std::string& event_so
actions_ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == "back")
{
stopDownload();
dismiss();
return GUIEngine::EVENT_BLOCK;
}

View File

@ -41,6 +41,7 @@ private:
* to the progress of a download. */
std::shared_ptr<AddonsPackRequest> m_download_request;
AddonsPack(const std::string& url);
~AddonsPack();
public:
virtual GUIEngine::EventPropagation processEvent(const std::string& event_source) OVERRIDE;
virtual void beforeAddingWidgets() OVERRIDE;

View File

@ -110,6 +110,12 @@ DownloadAssets::DownloadAssets()
getWidget<BubbleWidget>("description")->setText(msg);
} // DownloadAssets
// ----------------------------------------------------------------------------
DownloadAssets::~DownloadAssets()
{
stopDownload();
} // ~DownloadAssets
// ----------------------------------------------------------------------------
void DownloadAssets::beforeAddingWidgets()
{
@ -125,7 +131,6 @@ void DownloadAssets::init()
// ----------------------------------------------------------------------------
bool DownloadAssets::onEscapePressed()
{
stopDownload();
ModalDialog::dismiss();
return true;
} // onEscapePressed
@ -142,7 +147,6 @@ GUIEngine::EventPropagation DownloadAssets::processEvent(const std::string& even
actions_ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == "back")
{
stopDownload();
dismiss();
return GUIEngine::EVENT_BLOCK;
}

View File

@ -45,6 +45,7 @@ private:
public:
DownloadAssets();
~DownloadAssets();
virtual GUIEngine::EventPropagation processEvent(const std::string& event_source) OVERRIDE;
virtual void beforeAddingWidgets() OVERRIDE;