r18804 by jghali - #12038: Undo crashes Scribus after changing the page arrangement
scribus-commit
scribus-commit at lists.scribus.net
Sat Feb 8 22:08:02 UTC 2014
Author: jghali
Date: Sat Feb 8 22:08:02 2014
New Revision: 18804
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18804
Log:
#12038: Undo crashes Scribus after changing the page arrangement
Modified:
branches/Version14x/Scribus/scribus/scribus.cpp
branches/Version14x/Scribus/scribus/scribusdoc.cpp
Modified: branches/Version14x/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18804&path=/branches/Version14x/Scribus/scribus/scribus.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribus.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribus.cpp Sat Feb 8 22:08:02 2014
@@ -43,6 +43,7 @@
#include <QMouseEvent>
#include <QPixmap>
#include <QRegExp>
+#include <QScopedPointer>
#include <QStyleFactory>
#include <QTableWidget>
#include <QTextCodec>
@@ -6918,20 +6919,21 @@
{
if (HaveDoc && doc->appMode == modeEditClip)
view->requestMode(submodeEndNodeEdit);
- MovePages *dia = new MovePages(this, doc->currentPage()->pageNr()+1, doc->Pages->count(), true);
+ int currentPage = doc->currentPage()->pageNr();
+ QScopedPointer<MovePages> dia(new MovePages(this, currentPage + 1, doc->Pages->count(), true));
if (dia->exec())
{
int from = dia->getFromPage();
int to = dia->getToPage();
int wie = dia->getWhere();
int wo = dia->getWherePage();
- if (from != wo || (wie == 2 && to != signed(doc->Pages->count()) ) )
- {
- doc->movePage(from-1, to, wo-1, wie);
- updateGUIAfterPagesChanged();
- }
- }
- delete dia;
+ if ((wie < 2) && (from <= wo) && (wo <= to))
+ return;
+ if (wie == 2 && to == signed(doc->Pages->count()))
+ return;
+ doc->movePage(from-1, to, wo-1, wie);
+ updateGUIAfterPagesChanged();
+ }
}
void ScribusMainWindow::copyPage()
Modified: branches/Version14x/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18804&path=/branches/Version14x/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribusdoc.cpp Sat Feb 8 22:08:02 2014
@@ -2018,24 +2018,26 @@
if (isUndo)
{
- int newPageDest=fromPage;
- int newPageFrom=0;
- int newPageTo =0;
- int newPosition=0;
- int pagesMoved=toPage-fromPage;
+ int newPageDest = fromPage;
+ int newPageFrom = 0;
+ int newPageTo = 0;
+ int newPosition = 0;
+ int pagesMoved = toPage - fromPage;
switch (position)
{
case 0: //Before Page
- newPageFrom=dest-pagesMoved;
+ newPageDest = (toPage <= dest) ? fromPage : toPage;
+ newPageFrom = (toPage <= dest) ? (dest - pagesMoved) : dest;
break;
case 1: //After Page
- newPageFrom=dest-pagesMoved+1;
+ newPageDest = (toPage <= dest) ? fromPage : toPage;
+ newPageFrom = (toPage <= dest) ? (dest-pagesMoved + 1) : (dest + 1);
break;
case 2: //To End
- newPageFrom=Pages->count()-pagesMoved;
+ newPageFrom = Pages->count() - pagesMoved;
break;
}
- newPageTo=newPageFrom+pagesMoved;
+ newPageTo = newPageFrom + pagesMoved;
movePage(newPageFrom, newPageTo, newPageDest, newPosition);
}
else
More information about the scribus-commit
mailing list