From 682a9d6a101879d64563fe6ac1b2fcdc0a261075 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sun, 13 May 2018 12:52:50 +0200 Subject: [PATCH] Revert "BusyDialog: ignore gui messages while active" --- xbmc/Application.cpp | 34 ++++++++++++---------------- xbmc/Application.h | 2 +- xbmc/XBApplicationEx.cpp | 2 +- xbmc/dialogs/GUIDialogBusy.cpp | 5 ++-- xbmc/dialogs/GUIDialogProgress.cpp | 2 +- xbmc/guilib/GUIDialog.cpp | 8 +++---- xbmc/guilib/GUIDialog.h | 4 ++-- xbmc/guilib/GUIWindowManager.cpp | 6 ++--- xbmc/guilib/GUIWindowManager.h | 2 +- xbmc/guilib/IWindowManagerCallback.h | 2 +- xbmc/windows/GUIMediaWindow.cpp | 2 +- 11 files changed, 32 insertions(+), 37 deletions(-) diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 0201bafbdf286..e4b0edc080bd2 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -3312,8 +3312,6 @@ void CApplication::OnPlayBackEnded() CGUIMessage msg(GUI_MSG_PLAYBACK_ENDED, 0, 0); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); - - m_playerEvent.Set(); } void CApplication::OnPlayBackStarted(const CFileItem &file) @@ -3432,8 +3430,6 @@ void CApplication::OnPlayBackStopped() CGUIMessage msg(GUI_MSG_PLAYBACK_STOPPED, 0, 0); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); - - m_playerEvent.Set(); } void CApplication::OnPlayBackError() @@ -3521,8 +3517,6 @@ void CApplication::OnAVStarted(const CFileItem &file) param["player"]["speed"] = 1; param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); CAnnouncementManager::GetInstance().Announce(Player, "xbmc", "OnAVStart", m_itemCurrentFile, param); - - m_playerEvent.Set(); } void CApplication::OnAVChange() @@ -4126,6 +4120,7 @@ bool CApplication::OnMessage(CGUIMessage& message) break; case GUI_MSG_PLAYBACK_STOPPED: + m_playerEvent.Set(); m_itemCurrentFile->Reset(); CServiceBroker::GetGUI()->GetInfoManager().ResetCurrentItem(); PlaybackCleanup(); @@ -4135,6 +4130,7 @@ bool CApplication::OnMessage(CGUIMessage& message) return true; case GUI_MSG_PLAYBACK_ENDED: + m_playerEvent.Set(); if (m_stackHelper.IsPlayingRegularStack() && m_stackHelper.HasNextStackPartFileItem()) { // just play the next item in the stack PlayFile(m_stackHelper.SetNextStackPartCurrentFileItem(), "", true); @@ -4159,6 +4155,7 @@ bool CApplication::OnMessage(CGUIMessage& message) return true; case GUI_MSG_PLAYBACK_AVSTARTED: + m_playerEvent.Set(); #ifdef HAS_PYTHON // informs python script currently running playback has started // (does nothing if python is not loaded) @@ -4269,19 +4266,14 @@ void CApplication::ShowAppMigrationMessage() } } -void CApplication::Process(bool processMsgs) +void CApplication::Process() { - if (processMsgs) - { - // dispatch the messages generated by python or other threads to the current window - CServiceBroker::GetGUI()->GetWindowManager().DispatchThreadMessages(); - - // process messages which have to be send to the gui - // (this can only be done after CServiceBroker::GetGUI()->GetWindowManager().Render()) - CApplicationMessenger::GetInstance().ProcessWindowMessages(); + // dispatch the messages generated by python or other threads to the current window + CServiceBroker::GetGUI()->GetWindowManager().DispatchThreadMessages(); - CApplicationMessenger::GetInstance().ProcessMessages(); - } + // process messages which have to be send to the gui + // (this can only be done after CServiceBroker::GetGUI()->GetWindowManager().Render()) + CApplicationMessenger::GetInstance().ProcessWindowMessages(); if (m_autoExecScriptExecuted) { @@ -4296,10 +4288,8 @@ void CApplication::Process(bool processMsgs) CLog::Log(LOGDEBUG, "no profile autoexec.py (%s) found, skipping", strAutoExecPy.c_str()); } - if (m_bStop) - return; - // handle any active scripts + { // Allow processing of script threads to let them shut down properly. CSingleExit ex(CServiceBroker::GetWinSystem()->GetGfxContext()); @@ -4308,6 +4298,10 @@ void CApplication::Process(bool processMsgs) m_frameMoveGuard.lock(); } + // process messages, even if a movie is playing + CApplicationMessenger::GetInstance().ProcessMessages(); + if (m_bStop) return; //we're done, everything has been unloaded + // update sound m_appPlayer.DoAudioWork(); diff --git a/xbmc/Application.h b/xbmc/Application.h index 68642b54842d2..edccb963abb92 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -211,7 +211,7 @@ friend class CAppInboundProtocol; void CloseNetworkShares(); void ShowAppMigrationMessage(); - void Process(bool processMsgs) override; + void Process() override; void ProcessSlow(); void ResetScreenSaver(); float GetVolume(bool percentage = true) const; diff --git a/xbmc/XBApplicationEx.cpp b/xbmc/XBApplicationEx.cpp index 3acf6a500215c..5351252ffd8b1 100644 --- a/xbmc/XBApplicationEx.cpp +++ b/xbmc/XBApplicationEx.cpp @@ -81,7 +81,7 @@ int CXBApplicationEx::Run(const CAppParamParser ¶ms) { #endif lastFrameTime = XbmcThreads::SystemClockMillis(); - Process(true); + Process(); //reset exception count #ifdef XBMC_TRACK_EXCEPTIONS diff --git a/xbmc/dialogs/GUIDialogBusy.cpp b/xbmc/dialogs/GUIDialogBusy.cpp index dd4715e40515b..2882d8ab48e31 100644 --- a/xbmc/dialogs/GUIDialogBusy.cpp +++ b/xbmc/dialogs/GUIDialogBusy.cpp @@ -98,7 +98,7 @@ bool CGUIDialogBusy::WaitOnEvent(CEvent &event, unsigned int displaytime /* = 10 while(!event.WaitMSec(1)) { - dialog->ProcessRenderLoop(false, false); + dialog->ProcessRenderLoop(false); if (allowCancel && dialog->IsCanceled()) { cancelled = true; @@ -132,6 +132,7 @@ void CGUIDialogBusy::Open_Internal(const std::string ¶m /* = "" */) CGUIDialog::Open_Internal(false, param); } + void CGUIDialogBusy::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) { bool visible = CServiceBroker::GetGUI()->GetWindowManager().IsModalDialogTopmost(WINDOW_DIALOG_BUSY); @@ -153,7 +154,7 @@ void CGUIDialogBusy::DoProcess(unsigned int currentTime, CDirtyRegionList &dirty void CGUIDialogBusy::Render() { - if (!m_bLastVisible) + if(!m_bLastVisible) return; CGUIDialog::Render(); } diff --git a/xbmc/dialogs/GUIDialogProgress.cpp b/xbmc/dialogs/GUIDialogProgress.cpp index fde33ef67b937..96a891738d37a 100644 --- a/xbmc/dialogs/GUIDialogProgress.cpp +++ b/xbmc/dialogs/GUIDialogProgress.cpp @@ -82,7 +82,7 @@ void CGUIDialogProgress::Progress() { if (m_active) { - ProcessRenderLoop(false, true); + ProcessRenderLoop(); } } diff --git a/xbmc/guilib/GUIDialog.cpp b/xbmc/guilib/GUIDialog.cpp index 7fef6a8e941c0..d29c96ce54448 100644 --- a/xbmc/guilib/GUIDialog.cpp +++ b/xbmc/guilib/GUIDialog.cpp @@ -178,7 +178,7 @@ void CGUIDialog::Open_Internal(const std::string ¶m /* = "" */) CGUIDialog::Open_Internal(m_modalityType != DialogModalityType::MODELESS, param); } -void CGUIDialog::Open_Internal(bool bProcessRenderLoop, const std::string ¶m) +void CGUIDialog::Open_Internal(bool bProcessRenderLoop, const std::string ¶m /* = "" */) { // Lock graphic context here as it is sometimes called from non rendering threads // maybe we should have a critical section per window instead?? @@ -210,7 +210,7 @@ void CGUIDialog::Open_Internal(bool bProcessRenderLoop, const std::string ¶m while (m_active && !g_application.m_bStop) { - CServiceBroker::GetGUI()->GetWindowManager().ProcessRenderLoop(false, true); + CServiceBroker::GetGUI()->GetWindowManager().ProcessRenderLoop(); } } } @@ -259,7 +259,7 @@ void CGUIDialog::CancelAutoClose(void) m_autoClosing = false; } -void CGUIDialog::ProcessRenderLoop(bool renderOnly, bool processMsgs) +void CGUIDialog::ProcessRenderLoop(bool renderOnly) { - CServiceBroker::GetGUI()->GetWindowManager().ProcessRenderLoop(renderOnly, processMsgs); + CServiceBroker::GetGUI()->GetWindowManager().ProcessRenderLoop(renderOnly); } diff --git a/xbmc/guilib/GUIDialog.h b/xbmc/guilib/GUIDialog.h index 21f0ce210dfcf..864edd1d303bb 100644 --- a/xbmc/guilib/GUIDialog.h +++ b/xbmc/guilib/GUIDialog.h @@ -81,10 +81,10 @@ class CGUIDialog : virtual void UpdateVisibility(); virtual void Open_Internal(const std::string ¶m = ""); - virtual void Open_Internal(bool bProcessRenderLoop, const std::string ¶m); + virtual void Open_Internal(bool bProcessRenderLoop, const std::string ¶m = ""); void OnDeinitWindow(int nextWindowID) override; - void ProcessRenderLoop(bool renderOnly, bool processMsgs); + void ProcessRenderLoop(bool renderOnly = false); bool m_wasRunning; ///< \brief true if we were running during the last DoProcess() bool m_autoClosing; diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index b6c541d8577ff..af1bd3498f3d8 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -1300,13 +1300,13 @@ CGUIWindow* CGUIWindowManager::GetWindow(int id) const return nullptr; } -void CGUIWindowManager::ProcessRenderLoop(bool renderOnly, bool processMsgs) +void CGUIWindowManager::ProcessRenderLoop(bool renderOnly /*= false*/) { if (g_application.IsCurrentThread() && m_pCallback) { m_iNested++; if (!renderOnly) - m_pCallback->Process(processMsgs); + m_pCallback->Process(); m_pCallback->FrameMove(!renderOnly); m_pCallback->Render(); m_iNested--; @@ -1690,7 +1690,7 @@ void CGUIWindowManager::CloseWindowSync(CGUIWindow *window, int nextWindowID /*= window->Close(false, nextWindowID); while (window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) - ProcessRenderLoop(true, false); + ProcessRenderLoop(true); } #ifdef _DEBUG diff --git a/xbmc/guilib/GUIWindowManager.h b/xbmc/guilib/GUIWindowManager.h index c618109818984..a666571660735 100644 --- a/xbmc/guilib/GUIWindowManager.h +++ b/xbmc/guilib/GUIWindowManager.h @@ -257,7 +257,7 @@ class CGUIWindowManager : public KODI::MESSAGING::IMessageTarget */ void ActivateWindow_Internal(int windowID, const std::vector ¶ms, bool swappingWindows, bool force = false); - void ProcessRenderLoop(bool renderOnly, bool processMsgs); + void ProcessRenderLoop(bool renderOnly = false); bool HandleAction(const CAction &action) const; diff --git a/xbmc/guilib/IWindowManagerCallback.h b/xbmc/guilib/IWindowManagerCallback.h index 00f5e3240fc1e..7e879bd417f97 100644 --- a/xbmc/guilib/IWindowManagerCallback.h +++ b/xbmc/guilib/IWindowManagerCallback.h @@ -37,5 +37,5 @@ class IWindowManagerCallback virtual void FrameMove(bool processEvents, bool processGUI = true) = 0; virtual void Render() = 0; - virtual void Process(bool processMsgs) = 0; + virtual void Process() = 0; }; diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index e7e639f397cd9..d79fb5d4aa4c1 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -2159,7 +2159,7 @@ std::string CGUIMediaWindow::RemoveParameterFromPath(const std::string &strDirec void CGUIMediaWindow::ProcessRenderLoop(bool renderOnly) { - CServiceBroker::GetGUI()->GetWindowManager().ProcessRenderLoop(renderOnly, true); + CServiceBroker::GetGUI()->GetWindowManager().ProcessRenderLoop(renderOnly); } bool CGUIMediaWindow::GetDirectoryItems(CURL &url, CFileItemList &items, bool useDir)