From c1250a665ab8a5a567728cd96013a8de0219fede Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Sat, 20 Feb 2010 18:06:30 +0000 Subject: [PATCH] Fix a problem with the new MythSignalingTimer consuming all memory and causing both MythFrontend and MythWelcome to become unresponsive and eventually to be killed by the OOM killer. The problem is triggered when the main UI thread is stopped waiting for another external process to finish, e.g. when using an external player or when starting the FE from MythWelcome. Because the timer is run in its own thread it continues to emit the timeout signals which just get queued up waiting to be handled. This patch just start/stops the timer when SetDrawEnabled(true/false) is called and changes myth_system() to disable drawing when an external process is running and re-enables it when it finishes. git-svn-id: http://svn.mythtv.org/svn/trunk@23575 7dbf422c-18fa-0310-86e9-fd20926502f2 --- mythtv/libs/libmythui/mythmainwindow.cpp | 5 +++++ mythtv/libs/libmythui/mythsystem.cpp | 27 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/mythtv/libs/libmythui/mythmainwindow.cpp b/mythtv/libs/libmythui/mythmainwindow.cpp index fd7a2842875..0ceee0636ee 100644 --- a/mythtv/libs/libmythui/mythmainwindow.cpp +++ b/mythtv/libs/libmythui/mythmainwindow.cpp @@ -1058,6 +1058,11 @@ void MythMainWindow::SetDrawEnabled(bool enable) setUpdatesEnabled(enable); d->m_drawEnabled = enable; + if (enable) + d->drawTimer->start(1000 / 70); + else + d->drawTimer->stop(); + // TODO FIXME // Sleep 50 ms to give any in progress draw a chance to finish. // This should be replaced with something sane after MythTV 0.22 diff --git a/mythtv/libs/libmythui/mythsystem.cpp b/mythtv/libs/libmythui/mythsystem.cpp index 91a5f3b86be..2189e3bdbbd 100644 --- a/mythtv/libs/libmythui/mythsystem.cpp +++ b/mythtv/libs/libmythui/mythsystem.cpp @@ -58,6 +58,9 @@ uint myth_system(const QString &command, int flags) bool ready_to_lock = HasMythMainWindow(); (void)ready_to_lock; /* Kill warning */ + + uint result = GENERIC_EXIT_NOT_OK; + #ifdef USE_LIRC bool lirc_lock_flag = !(flags & MYTH_SYSTEM_DONT_BLOCK_LIRC); LircEventLock lirc_lock(lirc_lock_flag && ready_to_lock); @@ -75,6 +78,9 @@ uint myth_system(const QString &command, int flags) flags |= MYTH_SYSTEM_DONT_BLOCK_PARENT; #endif + if (ready_to_lock && !(flags & MYTH_SYSTEM_DONT_BLOCK_PARENT)) + GetMythMainWindow()->SetDrawEnabled(false); + QString LOC_ERR = QString("myth_system('%1'): Error: ").arg(command); #ifndef USING_MINGW @@ -85,7 +91,7 @@ uint myth_system(const QString &command, int flags) /* Fork failed */ VERBOSE(VB_IMPORTANT, (LOC_ERR + "fork() failed because %1") .arg(strerror(errno))); - return GENERIC_EXIT_NOT_OK; + result = GENERIC_EXIT_NOT_OK; } else if (child == 0) { @@ -141,14 +147,18 @@ uint myth_system(const QString &command, int flags) VERBOSE(VB_IMPORTANT, (LOC_ERR + "waitpid() failed because %1") .arg(strerror(errno))); - return GENERIC_EXIT_NOT_OK; + result = GENERIC_EXIT_NOT_OK; + break; } qApp->processEvents(); if (res > 0) - return WEXITSTATUS(status); + { + result = WEXITSTATUS(status); + break; + } usleep(100000); } @@ -159,9 +169,10 @@ uint myth_system(const QString &command, int flags) { VERBOSE(VB_IMPORTANT, (LOC_ERR + "waitpid() failed because %1") .arg(strerror(errno))); - return GENERIC_EXIT_NOT_OK; + result = GENERIC_EXIT_NOT_OK; } - return WEXITSTATUS(status); + else + result = WEXITSTATUS(status); } } @@ -196,6 +207,10 @@ uint myth_system(const QString &command, int flags) return exitcode; } #endif - return GENERIC_EXIT_NOT_OK; + + if (ready_to_lock && !(flags & MYTH_SYSTEM_DONT_BLOCK_PARENT)) + GetMythMainWindow()->SetDrawEnabled(true); + + return result; }