QCefWidget icon indicating copy to clipboard operation
QCefWidget copied to clipboard

ExecuteRemoveEventListener删除list的迭代器失效问题

Open potato520hjj opened this issue 3 years ago • 1 comments

` void QCefClient::V8Handler::ExecuteRemoveEventListener( const CefString& function, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception) { bool bRet = false;

if (arguments.size() == 2) { if (arguments[0]->IsString()) { if (arguments[1]->IsFunction()) { CefString eventName = arguments[0]->GetStringValue(); EventListener listener; listener.callback_ = arguments[1]; listener.context_ = CefV8Context::GetCurrentContext();

    auto itListenerList = eventListenerListMap_.find(eventName);
    if (itListenerList != eventListenerListMap_.end()) {
      EventListenerList& eventListenerList = itListenerList->second;
      for (auto itListener = eventListenerList.begin();
            itListener != eventListenerList.end();) {
          if (itListener->callback_->IsSame(listener.callback_)) {
            itListener = eventListenerList.erase(itListener);
          }
          else {
            ++itListener;
          }
      }
    }
  }
  else
    exception = "Invalid parameters; parameter 2 is expecting a function";
}
else
  exception = "Invalid parameters; parameter 1 is expecting a string";

} else exception = "Invalid parameters; expecting 2 parameters";

retval = CefV8Value::CreateBool(bRet); } `

potato520hjj avatar May 08 '22 19:05 potato520hjj

未能明白您需要说明的问题?请补充一下问题描述

winsoft666 avatar May 10 '22 03:05 winsoft666