]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/linux/gamecontroller.cpp
Don't leak memory if JsDevice constructor throws
[libs/gui.git] / source / input / linux / gamecontroller.cpp
index 8a4e8d43c2dbb3f06c9af66dd347dad721281f46..2fc624e7b83db87e677c0c2bbe5fdda0fb0ccd53 100644 (file)
@@ -12,10 +12,12 @@ namespace Msp {
 namespace Input {
 
 GameController::GameController(unsigned index):
-       priv(new Private),
        event_disp(0)
 {
-       priv->dev = new JsDevice(format("/dev/input/js%d", index));
+       JsDevice *device = new JsDevice(format("/dev/input/js%d", index));
+
+       priv = new Private;
+       priv->dev = device;
        priv->dev->signal_data_available.connect(sigc::mem_fun(this, static_cast<void (GameController::*)()>(&GameController::tick)));
        name = priv->dev->get_name();
        tick(Time::zero);