void WFileUpload::onData(::uint64_t current, ::uint64_t total) { dataReceived_.emit(current, total); WebSession::Handler *h = WebSession::Handler::instance(); ::int64_t dataExceeded = h->request()->postDataExceeded(); h->setRequest(0, 0); // so that triggerUpdate() will work if (dataExceeded) { if (flags_.test(BIT_UPLOADING)) { flags_.reset(BIT_UPLOADING); tooLargeSize_ = dataExceeded; handleFileTooLargeImpl(); WApplication *app = WApplication::instance(); app->triggerUpdate(); app->enableUpdates(false); } return; } if (progressBar_ && flags_.test(BIT_UPLOADING)) { progressBar_->setRange(0, (double)total); progressBar_->setValue((double)current); WApplication *app = WApplication::instance(); app->triggerUpdate(); } }
ClientWidget() : WText() { WApplication *app = WApplication::instance(); /* * WObject::bindSafe() is a functor that protects calling the passed * method or function against calling it when the object has already * been deleted. */ server.connect(this, bindSafe(&ClientWidget::updateData)); /* * You can also bindSafe() a lambda, for example: */ // server.connect(this, bindSafe([this]() { updateData(); })); app->enableUpdates(true); updateData(); }