Undo Redo Fix: Double Lock...

git-svn-id: https://xournal.svn.sourceforge.net/svnroot/xournal/trunk/xournalpp@150 9fe2bcd3-a095-4d8b-a836-9b85dc8d7627
presentation
andreasb123 15 years ago
parent d4a8caa052
commit d8bd69e7d6
  1. 17
      src/model/Document.cpp
  2. 100
      src/undo/PageBackgroundChangedUndoAction.cpp

@ -41,17 +41,22 @@ void Document::lock() {
g_mutex_lock(this->documentLock);
// if(tryLock()) {
// Stacktrace::printStracktrace();
// fprintf(stderr, "\n\n\n\n");
// } else {
// g_mutex_lock(this->documentLock);
// }
// if(tryLock()) {
// fprintf(stderr, "Locked by\n");
// Stacktrace::printStracktrace();
// fprintf(stderr, "\n\n\n\n");
// } else {
// g_mutex_lock(this->documentLock);
// }
}
void Document::unlock() {
XOJ_CHECK_TYPE(Document);
g_mutex_unlock(this->documentLock);
// fprintf(stderr, "Unlocked by\n");
// Stacktrace::printStracktrace();
// fprintf(stderr, "\n\n\n\n");
}
bool Document::tryLock() {

@ -21,37 +21,31 @@ PageBackgroundChangedUndoAction::~PageBackgroundChangedUndoAction() {
bool PageBackgroundChangedUndoAction::undo(Control * control) {
XOJ_CHECK_TYPE(PageBackgroundChangedUndoAction);
// TODO: CRASH!!
// this->newType = this->page.getBackgroundType();
// this->newPdfPage = this->page.getPdfPageNr();
// this->newBackgroundImage = this->page.getBackgroundImage();
// this->newW = this->page.getWidth();
// this->newH = this->page.getHeight();
//
// Document * doc = control->getDocument();
// doc->lock();
//
// int pageNr = doc->indexOf(this->page);
// if (pageNr == -1) {
// doc->unlock();
// return false;
// }
//
// if (this->newW != this->origW || this->newH != this->origH) {
// this->page.setSize(this->origW, this->origH);
// control->firePageSizeChanged(pageNr);
// }
//
// this->page.setBackgroundType(this->origType);
// if (this->origType == BACKGROUND_TYPE_PDF) {
// this->page.setBackgroundPdfPageNr(this->origPdfPage);
// } else if (this->origType == BACKGROUND_TYPE_IMAGE) {
// this->page.setBackgroundImage(this->origBackgroundImage);
// }
//
// doc->unlock();
// control->firePageChanged(pageNr);
this->newType = this->page.getBackgroundType();
this->newPdfPage = this->page.getPdfPageNr();
this->newBackgroundImage = this->page.getBackgroundImage();
this->newW = this->page.getWidth();
this->newH = this->page.getHeight();
Document * doc = control->getDocument();
int pageNr = doc->indexOf(this->page);
if (pageNr == -1) {
return false;
}
if (this->newW != this->origW || this->newH != this->origH) {
this->page.setSize(this->origW, this->origH);
control->firePageSizeChanged(pageNr);
}
this->page.setBackgroundType(this->origType);
if (this->origType == BACKGROUND_TYPE_PDF) {
this->page.setBackgroundPdfPageNr(this->origPdfPage);
} else if (this->origType == BACKGROUND_TYPE_IMAGE) {
this->page.setBackgroundImage(this->origBackgroundImage);
}
control->firePageChanged(pageNr);
return true;
}
@ -59,29 +53,27 @@ bool PageBackgroundChangedUndoAction::undo(Control * control) {
bool PageBackgroundChangedUndoAction::redo(Control * control) {
XOJ_CHECK_TYPE(PageBackgroundChangedUndoAction);
// Document * doc = control->getDocument();
//
// doc->lock();
// int pageNr = doc->indexOf(this->page);
// doc->unlock();
//
// if (pageNr == -1) {
// return false;
// }
//
// if (this->newW != this->origW || this->newH != this->origH) {
// this->page.setSize(this->newW, this->newH);
// control->firePageSizeChanged(pageNr);
// }
//
// this->page.setBackgroundType(this->newType);
// if (this->newType == BACKGROUND_TYPE_PDF) {
// this->page.setBackgroundPdfPageNr(this->newPdfPage);
// } else if (this->newType == BACKGROUND_TYPE_IMAGE) {
// this->page.setBackgroundImage(this->newBackgroundImage);
// }
//
// control->firePageChanged(pageNr);
Document * doc = control->getDocument();
int pageNr = doc->indexOf(this->page);
if (pageNr == -1) {
return false;
}
if (this->newW != this->origW || this->newH != this->origH) {
this->page.setSize(this->newW, this->newH);
control->firePageSizeChanged(pageNr);
}
this->page.setBackgroundType(this->newType);
if (this->newType == BACKGROUND_TYPE_PDF) {
this->page.setBackgroundPdfPageNr(this->newPdfPage);
} else if (this->newType == BACKGROUND_TYPE_IMAGE) {
this->page.setBackgroundImage(this->newBackgroundImage);
}
control->firePageChanged(pageNr);
return true;

Loading…
Cancel
Save