Skip to content

Commit

Permalink
fix segfault b/c QList is now used instead of QHash
Browse files Browse the repository at this point in the history
  • Loading branch information
panzi committed Apr 2, 2016
1 parent 8308138 commit 2ec41e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/joypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ bool JoyPad::readConfig( QTextStream &stream ) {
errorBox(tr("Layout file error"), tr("Expected ':', found '%1'.").arg(ch));
return false;
}
if (buttons[num-1] == 0) {
buttons.insert(num-1,new Button(num-1,this));
for (int i = buttons.size(); i < num; ++ i) {
buttons.append(new Button(i, this));
}
if (!buttons[num-1]->read( stream )) {
errorBox(tr("Layout file error"), tr("Error reading Button %1").arg(num));
Expand All @@ -172,8 +172,8 @@ bool JoyPad::readConfig( QTextStream &stream ) {
errorBox(tr("Layout file error"), tr("Expected ':', found '%1'.").arg(ch));
return false;
}
if (axes[num-1] == 0) {
axes.insert(num-1,new Axis(num-1,this));
for (int i = axes.size(); i < num; ++ i) {
axes.append(new Axis(i, this));
}
if (!axes[num-1]->read(stream)) {
errorBox(tr("Layout file error"), tr("Error reading Axis %1").arg(num));
Expand Down
25 changes: 13 additions & 12 deletions src/quickset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ void QuickSet::jsevent(const js_event &msg ) {
unsigned int type = msg.type & ~JS_EVENT_INIT;
if (type == JS_EVENT_BUTTON) {
//capture that button.
Button* button = joypad->buttons[msg.number];

if (button) {
if (msg.number < joypad->buttons.size()) {
Button* button = joypad->buttons[msg.number];
//go into setting mode and request a key/mousebutton
setting = true;
bool isMouse = false;
Expand All @@ -44,17 +43,19 @@ void QuickSet::jsevent(const js_event &msg ) {
if (abs(msg.value) < 5000) return;

//capture the axis that moved
Axis* axis = joypad->axes[msg.number];
if (msg.number < joypad->axes.size()) {
Axis* axis = joypad->axes[msg.number];

//grab a keycode for that axis and that direction
setting = true;
bool isMouse = false;
int code = KeyDialog::getKey((msg.value >= 0 ? tr("%1, positive") : tr("%1, negative")).arg(axis->getName()), true, &isMouse, this);
setting = false;
//grab a keycode for that axis and that direction
setting = true;
bool isMouse = false;
int code = KeyDialog::getKey((msg.value >= 0 ? tr("%1, positive") : tr("%1, negative")).arg(axis->getName()), true, &isMouse, this);
setting = false;

//assign the key to the axis.
if (code >= 0) {
axis->setKey(isMouse, (msg.value > 0), code);
//assign the key to the axis.
if (code >= 0) {
axis->setKey(isMouse, (msg.value > 0), code);
}
}
}
}

0 comments on commit 2ec41e6

Please sign in to comment.