Skip to content

Commit

Permalink
Fixed|UI|Multiplayer: Potential crash when joining an MP game
Browse files Browse the repository at this point in the history
Synchronous signal handling (game unload, MP join) may lead to the
widget being gone when it's time to check if there's a further
action to do.

IssueID #1954
  • Loading branch information
skyjake committed Feb 9, 2015
1 parent e8c0a26 commit d93e3fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions doomsday/client/src/ui/widgets/gameselectionwidget.cpp
Expand Up @@ -460,13 +460,16 @@ void GameSelectionWidget::updateSubsetLayout()
void GameSelectionWidget::select(ui::Item const *item)
{
if(!item) return;


// Should we perform an action afterwards? The signal handling may lead to
// destruction of the widget, so we'll hold a ref to the action.
AutoRef<Action> postAction(d->doAction? makeAction(*item) : nullptr);

// Notify.
emit gameSessionSelected(item);

// Should we also perform the action?
if(d->doAction)

if(bool(postAction))
{
AutoRef<Action> act = makeAction(*item);
act->trigger();
postAction->trigger();
}
}
2 changes: 2 additions & 0 deletions doomsday/libcore/include/de/data/counted.h
Expand Up @@ -237,6 +237,7 @@ template <typename CountedType>
class AutoRef
{
public:
AutoRef() : _ref(nullptr) {}
AutoRef(CountedType *preHeld) : _ref(preHeld) {}
AutoRef(CountedType &ref) : _ref(holdRef(ref)) {}
~AutoRef() { releaseRef(_ref); }
Expand All @@ -248,6 +249,7 @@ class AutoRef
operator CountedType * () { return _ref; }
operator CountedType const & () const { return *_ref; }
operator CountedType & () { return *_ref; }
explicit operator bool () const { return _ref != nullptr; }
private:
CountedType *_ref;
};
Expand Down

0 comments on commit d93e3fe

Please sign in to comment.