void ButtonModel::goMacroRemoved(const QByteArray& macroName)
{
    GroupVector groupVector = spaceballButtonGroup()->GetGroups();
    for (GroupVector::iterator it = groupVector.begin(); it != groupVector.end(); ++it)
        if (std::string(macroName.data()) == (*it)->GetASCII("Command"))
            (*it)->SetASCII("Command", "");
}
Exemplo n.º 2
0
/**
 * Clean up the service.
 *
 * Called during shutdown. Idempotent.
 */
void
nsPerformanceStatsService::Dispose()
{
  // Make sure that we do not accidentally destroy `this` while we are
  // cleaning up back references.
  RefPtr<nsPerformanceStatsService> kungFuDeathGrip(this);

  // Disconnect from nsIObserverService.
  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
  if (obs) {
    obs->RemoveObserver(this, "profile-before-change");
    obs->RemoveObserver(this, "quit-application");
    obs->RemoveObserver(this, "quit-application-granted");
    obs->RemoveObserver(this, "content-child-shutdown");
  }

  // Clear up and disconnect from JSAPI.
  js::DisposePerformanceMonitoring(mRuntime);

  mozilla::unused << js::SetStopwatchIsMonitoringCPOW(mRuntime, false);
  mozilla::unused << js::SetStopwatchIsMonitoringJank(mRuntime, false);

  mozilla::unused << js::SetStopwatchStartCallback(mRuntime, nullptr, nullptr);
  mozilla::unused << js::SetStopwatchCommitCallback(mRuntime, nullptr, nullptr);
  mozilla::unused << js::SetGetPerformanceGroupsCallback(mRuntime, nullptr, nullptr);

  // At this stage, the JS VM may still be holding references to
  // instances of PerformanceGroup on the stack. To let the service be
  // collected, we need to break the references from these groups to
  // `this`.
  mTopGroup->Dispose();

  // Copy references to the groups to a vector to ensure that we do
  // not modify the hashtable while iterating it.
  GroupVector groups;
  for (auto iter = mGroups.Iter(); !iter.Done(); iter.Next()) {
    groups.append(iter.Get()->GetKey());
  }
  for (auto iter = groups.begin(); iter < groups.end(); iter++) {
    RefPtr<nsPerformanceGroup> group = *iter;
    group->Dispose();
  }

  // Any remaining references to PerformanceGroup will be released as
  // the VM unrolls the stack. If there are any nested event loops,
  // this may take time.
}
QVariant ButtonModel::data (const QModelIndex &index, int role) const
{
    GroupVector groupVector = spaceballButtonGroup()->GetGroups();
    if (index.row() >= (int)groupVector.size())
    {
        Base::Console().Log("index error in ButtonModel::data\n");
        return QVariant();
    }
    if (role == Qt::DisplayRole)
        return QVariant(getLabel(index.row()));
    if (role == Qt::DecorationRole)
    {
        static QPixmap icon(BitmapFactory().pixmap("spaceball_button").scaled
                            (32, 32, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
        return QVariant(icon);
    }
    if (role == Qt::UserRole)
        return QVariant(QString::fromStdString(groupVector.at(index.row())->GetASCII("Command")));
    if (role == Qt::SizeHintRole)
        return QVariant(QSize(32, 32));
    return QVariant();
}
void ButtonModel::setCommand(int row, QString command)
{
    GroupVector groupVector = spaceballButtonGroup()->GetGroups();
    groupVector.at(row)->SetASCII("Command", command.toLatin1());
}