Skip to content

Commit

Permalink
Revert "BusyDialog: ignore gui messages while active"
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored May 13, 2018
1 parent f472214 commit 682a9d6
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 37 deletions.
34 changes: 14 additions & 20 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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());
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion xbmc/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/XBApplicationEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int CXBApplicationEx::Run(const CAppParamParser &params)
{
#endif
lastFrameTime = XbmcThreads::SystemClockMillis();
Process(true);
Process();
//reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS

Expand Down
5 changes: 3 additions & 2 deletions xbmc/dialogs/GUIDialogBusy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -132,6 +132,7 @@ void CGUIDialogBusy::Open_Internal(const std::string &param /* = "" */)
CGUIDialog::Open_Internal(false, param);
}


void CGUIDialogBusy::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
bool visible = CServiceBroker::GetGUI()->GetWindowManager().IsModalDialogTopmost(WINDOW_DIALOG_BUSY);
Expand All @@ -153,7 +154,7 @@ void CGUIDialogBusy::DoProcess(unsigned int currentTime, CDirtyRegionList &dirty

void CGUIDialogBusy::Render()
{
if (!m_bLastVisible)
if(!m_bLastVisible)
return;
CGUIDialog::Render();
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/dialogs/GUIDialogProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void CGUIDialogProgress::Progress()
{
if (m_active)
{
ProcessRenderLoop(false, true);
ProcessRenderLoop();
}
}

Expand Down
8 changes: 4 additions & 4 deletions xbmc/guilib/GUIDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void CGUIDialog::Open_Internal(const std::string &param /* = "" */)
CGUIDialog::Open_Internal(m_modalityType != DialogModalityType::MODELESS, param);
}

void CGUIDialog::Open_Internal(bool bProcessRenderLoop, const std::string &param)
void CGUIDialog::Open_Internal(bool bProcessRenderLoop, const std::string &param /* = "" */)
{
// Lock graphic context here as it is sometimes called from non rendering threads
// maybe we should have a critical section per window instead??
Expand Down Expand Up @@ -210,7 +210,7 @@ void CGUIDialog::Open_Internal(bool bProcessRenderLoop, const std::string &param

while (m_active && !g_application.m_bStop)
{
CServiceBroker::GetGUI()->GetWindowManager().ProcessRenderLoop(false, true);
CServiceBroker::GetGUI()->GetWindowManager().ProcessRenderLoop();
}
}
}
Expand Down Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions xbmc/guilib/GUIDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class CGUIDialog :
virtual void UpdateVisibility();

virtual void Open_Internal(const std::string &param = "");
virtual void Open_Internal(bool bProcessRenderLoop, const std::string &param);
virtual void Open_Internal(bool bProcessRenderLoop, const std::string &param = "");
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;
Expand Down
6 changes: 3 additions & 3 deletions xbmc/guilib/GUIWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/GUIWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class CGUIWindowManager : public KODI::MESSAGING::IMessageTarget
*/
void ActivateWindow_Internal(int windowID, const std::vector<std::string> &params, bool swappingWindows, bool force = false);

void ProcessRenderLoop(bool renderOnly, bool processMsgs);
void ProcessRenderLoop(bool renderOnly = false);

bool HandleAction(const CAction &action) const;

Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/IWindowManagerCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
2 changes: 1 addition & 1 deletion xbmc/windows/GUIMediaWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 682a9d6

Please sign in to comment.