View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0018013 | Scribus | Undo/Redo | public | 2026-10-14 16:11 | 2026-10-17 20:07 |
| Reporter | buttar | Assigned To | cbradney | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Platform | Linux | OS | Fedora Workstation | OS Version | 44 |
| Product Version | 1.7.4.svn | ||||
| Fixed in Version | 1.7.4.svn | ||||
| Summary | 0018013: [patch] Fix master-page import undo/redo grouping | ||||
| Description | - Importing a master page with objects generates multiple independent Action History entries. - Undo progressively removes individual objects/properties instead of reversing the complete import. Patch fix: - Baseline: Pristine r27881. - Wrap the complete master-page import in a single `UndoTransaction`. - Group master creation, objects and properties into one Undo/Redo action. - Support multiple selected masters within the same transaction. - Guard empty selections and retain undoable history on partial import failure. | ||||
| Steps To Reproduce | 1. Create a source document with a master page containing several objects. 2. Import that master through the Master Pages palette. 3. Observe multiple Create/Change actions in Action History. 4. Undo once; only part of the import is reversed. | ||||
| Tags | #please_test | ||||
| Attached Files | miu1-master-page-import-undo-grouping-v1.01.patch (2,951 bytes)
Index: scribus/ui/pagepalette_masterpages.cpp
===================================================================
--- scribus/ui/pagepalette_masterpages.cpp (revision 27881)
+++ scribus/ui/pagepalette_masterpages.cpp (working copy)
@@ -9,6 +9,7 @@
#include <QApplication>
#include <QCloseEvent>
#include <QCursor>
+#include <QEventLoop>
#include <QHBoxLayout>
#include <QInputDialog>
#include <QListWidget>
@@ -39,6 +40,8 @@
#include "selection.h"
#include "util.h"
#include "util_os.h"
+#include "undomanager.h"
+#include "undotransaction.h"
PagePalette_MasterPages::PagePalette_MasterPages( QWidget* parent, ScribusView *pCurrentView, const QString& masterPageName) : QWidget(parent)
@@ -356,34 +359,54 @@
if (!dia->exec())
return;
+ const QStringList selectedNames = dia->getMasterPageNames();
+ const QList<int> selectedIndexes = dia->getMasterPageIndexes();
+ if (selectedNames.isEmpty() || selectedNames.size() != selectedIndexes.size())
+ return;
+
if (m_doc->appMode == modeEditClip)
m_view->requestMode(submodeEndNodeEdit);
+ UndoTransaction importTransaction;
+ if (UndoManager::undoEnabled())
+ importTransaction = UndoManager::instance()->beginTransaction(m_doc->getUName(), Um::IDocument,
+ Um::ImportMasterPage, QString(), Um::ICreate);
+
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ const QString sourceFile = dia->getFromDoc();
int nr = m_doc->Pages->count();
-
- auto indexes = dia->getMasterPageIndexes();
QString lastName;
- for (auto name: dia->getMasterPageNames())
- {
- name = getUniqueName(name, m_doc->MasterNames);
+ bool loadFailed = false;
+ for (int i = 0; i < selectedNames.size(); ++i)
+ {
+ const QString name = getUniqueName(selectedNames.at(i), m_doc->MasterNames);
m_doc->setCurrentPage(m_doc->addMasterPage(nr, name));
- nr++;
- qApp->processEvents();
+ ++nr;
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
//CB TODO: If we are loading to a new name, we rely on doc->onpage in
//FileLoader::PasteItem as this call doesn't pass in the new destination page
- m_doc->scMW()->loadPage(dia->getFromDoc(), indexes.first(), true, name);
- qApp->processEvents();
-
- indexes.removeFirst();
+ const bool loaded = m_doc->scMW()->loadPage(sourceFile, selectedIndexes.at(i), true, name);
+ qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+
lastName = name;
- }
-
+ if (!loaded)
+ {
+ loadFailed = true;
+ break;
+ }
+ }
+
+ if (importTransaction)
+ importTransaction.commit();
updateMasterPageList(lastName);
m_view->showMasterPage(m_doc->MasterNames[lastName]);
qApp->restoreOverrideCursor();
+
+ if (loadFailed)
+ QMessageBox::warning(this, CommonStrings::trWarning,
+ tr("Could not complete the master page import. Some master pages may be incomplete."));
}
void PagePalette_MasterPages::selectMasterPage(QListWidgetItem *item)
| ||||
| Patch | Yes | ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-10-14 16:11 | buttar | New Issue | |
| 2026-10-14 16:11 | buttar | Tag Attached: #pending | |
| 2026-10-14 16:11 | buttar | File Added: master-page-import-undo-action-history.png | |
| 2026-10-14 16:11 | buttar | File Added: miu1-master-page-import-undo-grouping-v1.01.patch | |
| 2026-10-14 16:12 | buttar | Tag Detached: #pending | |
| 2026-10-14 16:12 | buttar | Tag Attached: #please_test | |
| 2026-10-17 19:41 | cbradney | Assigned To | => cbradney |
| 2026-10-17 19:41 | cbradney | Status | new => resolved |
| 2026-10-17 19:41 | cbradney | Resolution | open => fixed |
| 2026-10-17 19:41 | cbradney | Fixed in Version | => 1.7.4.svn |
| 2026-10-17 20:07 | cbradney | Status | resolved => closed |