diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2018-07-26 19:29:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-26 19:29:55 +0200 |
commit | 9ec10b91ed01c8d01a44cd557573a745f1c86682 (patch) | |
tree | c0016d5cf79e27cc9d5a19d32c3370de286814f2 | |
parent | ce65dc5c086d10cd51b21b410420ca5abfb02f50 (diff) | |
parent | 5c3a51555b5208f29905cfac6bfe7ab7ba63fdcb (diff) |
Merge pull request #14225 from AkariDN/busydlg
Do not show busy dialog if progress dialog is active while calling a plugin
-rw-r--r-- | xbmc/dialogs/GUIDialogProgress.cpp | 13 | ||||
-rw-r--r-- | xbmc/dialogs/GUIDialogProgress.h | 7 | ||||
-rw-r--r-- | xbmc/filesystem/PluginDirectory.cpp | 16 |
3 files changed, 34 insertions, 2 deletions
diff --git a/xbmc/dialogs/GUIDialogProgress.cpp b/xbmc/dialogs/GUIDialogProgress.cpp index 6c44dfbf15..2009652d90 100644 --- a/xbmc/dialogs/GUIDialogProgress.cpp +++ b/xbmc/dialogs/GUIDialogProgress.cpp @@ -182,6 +182,19 @@ bool CGUIDialogProgress::Wait(int progresstime /*= 10*/) return !m_bCanceled; } +bool CGUIDialogProgress::WaitOnEvent(CEvent& event) +{ + while (!event.WaitMSec(1)) + { + if (m_bCanceled) + return false; + + Progress(); + } + + return !m_bCanceled; +} + void CGUIDialogProgress::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { if (m_bInvalidated) diff --git a/xbmc/dialogs/GUIDialogProgress.h b/xbmc/dialogs/GUIDialogProgress.h index c7f6fac283..5e553df85d 100644 --- a/xbmc/dialogs/GUIDialogProgress.h +++ b/xbmc/dialogs/GUIDialogProgress.h @@ -49,6 +49,13 @@ public: */ bool Wait(int progresstime = 10); + /*! \brief Wait on an event or for the progress dialog to be canceled, while + regularly rendering to allow for pointer movement or progress to be shown. + \param event the CEvent to wait on. + \return true if the event completed, false if cancelled. + */ + bool WaitOnEvent(CEvent& event); + // Implements IProgressCallback void SetProgressMax(int iMax) override; void SetProgressAdvance(int nSteps=1) override; diff --git a/xbmc/filesystem/PluginDirectory.cpp b/xbmc/filesystem/PluginDirectory.cpp index 034d9524ba..872ed4a18b 100644 --- a/xbmc/filesystem/PluginDirectory.cpp +++ b/xbmc/filesystem/PluginDirectory.cpp @@ -28,8 +28,10 @@ #include "addons/PluginSource.h" #include "interfaces/generic/ScriptInvocationManager.h" #include "threads/SingleLock.h" +#include "guilib/GUIComponent.h" #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogBusy.h" +#include "dialogs/GUIDialogProgress.h" #include "settings/Settings.h" #include "FileItem.h" #include "video/VideoInfoTag.h" @@ -509,10 +511,20 @@ bool CPluginDirectory::WaitOnScriptResult(const std::string &scriptPath, int scr if (!m_fetchComplete.WaitMSec(20)) { CScriptObserver scriptObs(scriptId, m_fetchComplete); - if (!CGUIDialogBusy::WaitOnEvent(m_fetchComplete, 200)) + + CGUIDialogProgress* progress = nullptr; + CGUIWindowManager& wm = CServiceBroker::GetGUI()->GetWindowManager(); + if (wm.IsModalDialogTopmost(WINDOW_DIALOG_PROGRESS)) + progress = wm.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS); + + if (progress != nullptr) { - m_cancelled = true; + if (!progress->WaitOnEvent(m_fetchComplete)) + m_cancelled = true; } + else if (!CGUIDialogBusy::WaitOnEvent(m_fetchComplete, 200)) + m_cancelled = true; + scriptObs.Abort(); } } |