Browse Source

Fix input command mapping issue

slotWithArgs is a char*, and it's source, a QByteArray, is a temporary
object that gets destroyed after the auto statement. This left behind a
dangling pointer, which most likely was responsible for the issues we've
experienced.

Commit 0fb21d indeed did nothing.
Vincent Lang 9 years ago
parent
commit
9e6adf9163
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/input/InputComponent.cpp

+ 4 - 4
src/input/InputComponent.cpp

@@ -142,14 +142,14 @@ void InputComponent::registerHostCommand(const QString& command, QObject* receiv
 
   m_hostCommands.insert(command, recvSlot);
 
-  auto slotWithArgs = QString("%1(QString)").arg(QString::fromLatin1(recvSlot->slot)).toLatin1().data();
-  auto slotWithoutArgs = QString("%1()").arg(QString::fromLatin1(recvSlot->slot)).toLatin1().data();
-  if (recvSlot->receiver->metaObject()->indexOfMethod(slotWithArgs) != -1)
+  auto slotWithArgs = QString("%1(QString)").arg(QString::fromLatin1(recvSlot->slot)).toLatin1();
+  auto slotWithoutArgs = QString("%1()").arg(QString::fromLatin1(recvSlot->slot)).toLatin1();
+  if (recvSlot->receiver->metaObject()->indexOfMethod(slotWithArgs.data()) != -1)
   {
     QLOG_DEBUG() << "Host command maps to method with an argument.";
     recvSlot->hasArguments = true;
   }
-  else if (recvSlot->receiver->metaObject()->indexOfMethod(slotWithoutArgs) != -1)
+  else if (recvSlot->receiver->metaObject()->indexOfMethod(slotWithoutArgs.data()) != -1)
   {
     QLOG_DEBUG() << "Host command maps to method without arguments.";
   }