Skip to content

Commit

Permalink
Fix a problem with the new MythSignalingTimer consuming all memory an…
Browse files Browse the repository at this point in the history
…d 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
  • Loading branch information
Paul Harrison committed Feb 20, 2010
1 parent 4f8eb42 commit c1250a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
5 changes: 5 additions & 0 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -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
Expand Down
27 changes: 21 additions & 6 deletions mythtv/libs/libmythui/mythsystem.cpp
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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;
}

0 comments on commit c1250a6

Please sign in to comment.