void CUndoRedoStack::undo() { QUndoCommand* topCmd = d->undoStack.count() ? d->undoStack.pop() : 0; if(!topCmd) return; QString cmdText = topCmd->text(); topCmd->undo(); d->redoStack.push(topCmd); qWarning("Undo: %s", qPrintable(cmdText)); // emit change notifications. emit undone(cmdText); emit canUndoChanged(d->undoStack.count()); emit canRedoChanged(d->redoStack.count()); }
void HTTPClient_t::reset() { if (respCode == HTTP_OK && request) { evhttp_request_free(request); } else { // if (conn) evhttp_connection_free(conn); // if (uri) evhttp_uri_free(uri); } uri = NULL; conn = NULL; request = NULL; status = HTTPClient_t::STATUS_UNCHECK; type = IHttpRequest::Type::NONE; respCode = 0; undone(); }
bool UndoCommand::internalUndo(const vector<UndoCommand*>& childCommands, bool executeThis, bool isAborting) { m_bAborted = false; vector<UndoCommand*> executed; switch(m_eUndoChildExecutionPolicy) { case e_ChildExecutionPolicy_BackwardAfterParent: { if(executeThis) undo(); if(m_bAborted) { o_error(!isAborting, "Failed on aborting"); return false; } size_t i = childCommands.size(); while(i--) { if(!childCommands[i]->internalUndo(isAborting)) { o_error(!isAborting, "Failed on aborting"); std::reverse(executed.begin(), executed.end()); internalRedo(executed, true, true); return false; } executed.push_back(childCommands[i]); } } break; case e_ChildExecutionPolicy_BackwardBeforeParent: { size_t i = childCommands.size(); while(i--) { if(!childCommands[i]->internalUndo(isAborting)) { o_error(!isAborting, "Failed on aborting"); std::reverse(executed.begin(), executed.end()); internalRedo(executed, false, true); return false; } executed.push_back(childCommands[i]); } if(executeThis) undo(); if(m_bAborted) { o_error(!isAborting, "Failed on aborting"); std::reverse(executed.begin(), executed.end()); internalRedo(executed, false, true); return false; } } break; case e_ChildExecutionPolicy_ForwardAfterParent: { if(executeThis) undo(); if(m_bAborted) { o_error(!isAborting, "Failed on aborting"); return false; } for(size_t i = 0; i<childCommands.size(); ++i) { if(!childCommands[i]->internalUndo(isAborting)) { o_error(!isAborting, "Failed on aborting"); internalRedo(executed, true, true); return false; } executed.push_back(childCommands[i]); } } break; case e_ChildExecutionPolicy_ForwardBeforeParent: { for(size_t i = 0; i<childCommands.size(); ++i) { if(!childCommands[i]->internalUndo(isAborting)) { o_error(!isAborting, "Failed on aborting"); internalRedo(executed, false, true); return false; } executed.push_back(childCommands[i]); } if(executeThis) undo(); if(m_bAborted) { o_error(!isAborting, "Failed on aborting"); internalRedo(executed, false, true); return false; } } break; } o_emit undone(); return true; }
MemoryHint::MemoryHint() { undone(); }