View Issue Details

IDProjectCategoryView StatusLast Update
0012134ScribusGeneralpublic2026-10-29 21:17
Reporterchristoph_s Assigned Tocbradney  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSOpenSUSE 64 BitOS Version13.1
Product Version1.5.0svn 
Target VersionFuture Release - Nice to haveFixed in Version1.7.5.svn 
Summary0012134: Opening the Master Page dialog is recorded as a document change
DescriptionIf one opens a file and then opens the Master Page dialog but does nothing, this is recorded as a document change.
Steps To Reproduce1) Open a document.

2) Edit > Master Pages.

3) Leave MP mode.

4) Close the document.

--> Scribus asks whether the changes should be saved.
Tags#please_test, dirty
PatchNo

Relationships

related to 0013511 closedcbradney copying an item should not make the document dirty 
related to 0011619 closedjghali Column jump is recorded as document modification 
related to 0003455 acknowledged Undoing all changes should reset document status to "unchanged" 
related to 0012811 new "Changed" indicator confused with inline text editing 

Activities

Kunda

2014-06-23 11:31

updater   ~0032258

reproduced on r19270 (OSX 10.8.5 w/ Homebrew built qt5)

cbradney

2014-06-23 21:02

administrator   ~0032268

This is because when leaving master page edit mode, all master pages are reapplied to the normal pages. We'd need to track the changes page by page and then only apply those changes to avoid this.

Kunda

2014-07-23 21:23

updater   ~0032933

Based on 0012134:0032268 how do we proceed ?

Kunda

2015-08-30 17:47

updater   ~0036125

Assigning to 'future release' so this doesn't get lost in the bugtracker.

buttar

2026-08-21 08:12

reporter   ~0054261

This patch, created with ai, fixed it for me. Check the pdf report to know it's approach.
masterpage-false-modified-fix-v1.0.patch (6,176 bytes)   
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(revision 27773)
+++ scribus/scribusdoc.h	(working copy)
@@ -33,6 +33,7 @@
 #include <QHash>
 #include <QList>
 #include <QMap>
+#include <QSet>
 #include <QObject>
 #include <QPixmap>
 #include <QRectF>
@@ -1097,6 +1098,29 @@
 		 */
 		void updateSectionPageNumbersToPages();
 		/**
+		 * @brief Call when entering master-page editing (once per session).
+		 * Snapshots the current set of master-page names and clears the
+		 * touched-master tracking, both used by
+		 * pageNeedsMasterPageReapply() to let the exit sequence skip pages
+		 * whose master was never actually edited during this session.
+		 */
+		void startMasterPageEditSession();
+		/**
+		 * @brief Call once the exit sequence has finished consulting
+		 * pageNeedsMasterPageReapply() for every page, so a later, unrelated
+		 * change doesn't get evaluated against stale session data.
+		 */
+		void endMasterPageEditSession();
+		/**
+		 * @brief Whether pageIndex's assigned master page needs to be
+		 * reapplied at the end of a master-page editing session - true if
+		 * that specific master was genuinely edited during the session, or
+		 * if any master was added/removed/renamed (a structural change,
+		 * safest to reapply everything rather than track it precisely).
+		 * Always true if startMasterPageEditSession() was never called.
+		 */
+		bool pageNeedsMasterPageReapply(uint pageIndex) const;
+		/**
 		 * @param otherPageIndex
 		 * @param location
 		 * @param count
@@ -1410,6 +1434,17 @@
 		QList<ScPage*> TempPages;
 		/** \brief Mapping Master Page Name to Master Page numbers */
 		QMap<QString,int> MasterNames;
+		// Master-page names present when the current master-page editing
+		// session began (see startMasterPageEditSession()). Empty when no
+		// session is active or none has ever started.
+		QSet<QString> m_masterNamesAtSessionStart;
+		// Master-page names actually edited (had a real change fire while
+		// masterPageMode() was true) during the current session.
+		QSet<QString> m_touchedMasterPagesThisSession;
+		// True once startMasterPageEditSession() has been called for the
+		// current session, so pageNeedsMasterPageReapply() can safely
+		// default to "yes, reapply" if no session was ever started.
+		bool m_masterPageEditSessionActive {false};
 		/** \brief List of Objects */
 		//! Items is a pointer to the lists of items that exist in a document. In Normal mode, it points to DocItems. In Master Page mode it points to MasterItems. See ScribusDoc::assignPageModeLists()
 		QList<PageItem*>* Items {nullptr};
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 27773)
+++ scribus/scribusdoc.cpp	(working copy)
@@ -4847,6 +4847,42 @@
 	return m_docUnitRatio;
 }
 
+void ScribusDoc::startMasterPageEditSession()
+{
+	m_masterNamesAtSessionStart.clear();
+	for (auto it = MasterNames.cbegin(); it != MasterNames.cend(); ++it)
+		m_masterNamesAtSessionStart.insert(it.key());
+	m_touchedMasterPagesThisSession.clear();
+	m_masterPageEditSessionActive = true;
+}
+
+void ScribusDoc::endMasterPageEditSession()
+{
+	m_masterPageEditSessionActive = false;
+	m_masterNamesAtSessionStart.clear();
+	m_touchedMasterPagesThisSession.clear();
+}
+
+bool ScribusDoc::pageNeedsMasterPageReapply(uint pageIndex) const
+{
+	if (!m_masterPageEditSessionActive)
+		return true;
+	if (pageIndex >= static_cast<uint>(DocPages.count()))
+		return true;
+
+	// If any master was added, removed, or renamed during the session, the
+	// name sets won't match - safest to reapply every page rather than try
+	// to reason precisely about what a rename or deletion affects.
+	QSet<QString> currentMasterNames;
+	for (auto it = MasterNames.cbegin(); it != MasterNames.cend(); ++it)
+		currentMasterNames.insert(it.key());
+	if (currentMasterNames != m_masterNamesAtSessionStart)
+		return true;
+
+	QString masterName = DocPages.at(static_cast<int>(pageIndex))->masterPageName();
+	return m_touchedMasterPagesThisSession.contains(masterName);
+}
+
 bool ScribusDoc::applyMasterPage(const QString& pageName, int pageNumber)
 {
 	if (!MasterNames.contains(pageName))
@@ -13949,6 +13985,8 @@
 
 void ScribusDoc::changed()
 {
+	if (m_masterPageEditSessionActive && m_masterPageMode && m_currentPage)
+		m_touchedMasterPagesThisSession.insert(m_currentPage->pageName());
 	setModified(true);
 	// Do not emit docChanged signal() unnecessarily
 	// Processing of that signal is slowwwwwww and
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 27773)
+++ scribus/scribus.cpp	(working copy)
@@ -7758,7 +7758,11 @@
 	appModeHelper->setMasterPageEditMode(false, doc);
 	int pageCount = doc->DocPages.count();
 	for (int i = 0; i < pageCount; ++i)
-		Apply_MasterPage(doc->DocPages.at(i)->masterPageName(), i, false);
+	{
+		if (doc->pageNeedsMasterPageReapply(i))
+			Apply_MasterPage(doc->DocPages.at(i)->masterPageName(), i, false);
+	}
+	doc->endMasterPageEditSession();
 
 	pagePalette->endMasterPageMode();
 	if (m_pagePaletteWasClosed && pagePalette->isFloating())
Index: scribus/ui/pagepalette.cpp
===================================================================
--- scribus/ui/pagepalette.cpp	(revision 27773)
+++ scribus/ui/pagepalette.cpp	(working copy)
@@ -174,10 +174,16 @@
 void PagePalette::startMasterPageMode(const QString& masterPage)
 {
 	ScribusDoc* doc = m_view->m_doc;
-	
+
 	bool mustDeselect = false;
 	mustDeselect |= (!doc->masterPageMode());
 	mustDeselect |= (doc->masterPageMode() && doc->currentPage()->pageName() != masterPage);
+	// Only a genuine transition from normal mode into master-page mode
+	// starts a new tracking session - jumping directly to a different
+	// specific master while already in master-page mode (the second half
+	// of mustDeselect above) must not reset tracking mid-session.
+	if (!doc->masterPageMode())
+		doc->startMasterPageEditSession();
 	if (mustDeselect)
 	{
 		// We must avoid deselecting directly if doc is in an edit mode,

buttar

2026-08-21 08:13

reporter   ~0054262

Here are the TEMPORARY diagnostic patch, and its report.
masterpage-changed-diagnostic-TEMPORARY-v1.0.patch (3,318 bytes)   
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 27773)
+++ scribus/scribusdoc.cpp	(working copy)
@@ -13949,6 +13949,9 @@
 
 void ScribusDoc::changed()
 {
+	qDebug() << "[MPDIAG] changed() called - masterPageMode=" << m_masterPageMode
+		<< "currentPage=" << (m_currentPage ? m_currentPage->pageName() : QString("<null>"))
+		<< "wasModified=" << m_modified;
 	setModified(true);
 	// Do not emit docChanged signal() unnecessarily
 	// Processing of that signal is slowwwwwww and
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 27773)
+++ scribus/scribus.cpp	(working copy)
@@ -7748,6 +7748,7 @@
 
 void ScribusMainWindow::editMasterPagesEnd()
 {
+	qDebug() << "[MPDIAG] ===== EXIT master-page mode START, doc->isModified()=" << doc->isModified() << "=====";
 	view->hideMasterPage();
 	if (m_WasAutoSave)
 	{
@@ -7757,8 +7758,10 @@
 	slotSelect();
 	appModeHelper->setMasterPageEditMode(false, doc);
 	int pageCount = doc->DocPages.count();
+	qDebug() << "[MPDIAG] reapply loop starting, pageCount=" << pageCount << "doc->isModified()=" << doc->isModified();
 	for (int i = 0; i < pageCount; ++i)
 		Apply_MasterPage(doc->DocPages.at(i)->masterPageName(), i, false);
+	qDebug() << "[MPDIAG] reapply loop finished, doc->isModified()=" << doc->isModified();
 
 	pagePalette->endMasterPageMode();
 	if (m_pagePaletteWasClosed && pagePalette->isFloating())
Index: scribus/ui/pagepalette.cpp
===================================================================
--- scribus/ui/pagepalette.cpp	(revision 27773)
+++ scribus/ui/pagepalette.cpp	(working copy)
@@ -7,6 +7,7 @@
 
 
 #include <QApplication>
+#include <QDebug>
 #include <QEvent>
 #include <QList>
 #include <QPainter>
@@ -173,6 +174,7 @@
 
 void PagePalette::startMasterPageMode(const QString& masterPage)
 {
+	qDebug() << "[MPDIAG] ===== ENTER master-page mode, masterPage=" << masterPage << "=====";
 	ScribusDoc* doc = m_view->m_doc;
 	
 	bool mustDeselect = false;
@@ -217,6 +219,7 @@
 
 void PagePalette::endMasterPageMode()
 {
+	qDebug() << "[MPDIAG] ----- endMasterPageMode() UI cleanup (reapply loop already ran) -----";
 	if (this->stackedWidget()->currentIndex() > 0)
 	{
 		// Set focus to page palette or focus may be set to wrong document window
Index: scribus/ui/pagepalette_masterpages.cpp
===================================================================
--- scribus/ui/pagepalette_masterpages.cpp	(revision 27773)
+++ scribus/ui/pagepalette_masterpages.cpp	(working copy)
@@ -9,6 +9,7 @@
 #include <QApplication>
 #include <QCloseEvent>
 #include <QCursor>
+#include <QDebug>
 #include <QHBoxLayout>
 #include <QInputDialog>
 #include <QListWidget>
@@ -400,7 +401,9 @@
 		m_view->requestMode(submodeEndNodeEdit);
 	else if (m_doc->appMode == modeEdit || m_doc->appMode == modeEditGradientVectors)
 		m_view->requestMode(modeNormal);
+	qDebug() << "[MPDIAG] user selected master page in list:" << m_currentPage << "doc->isModified() before showMasterPage=" << m_doc->isModified();
 	m_view->showMasterPage(m_doc->MasterNames[m_currentPage]);
+	qDebug() << "[MPDIAG] after showMasterPage, doc->isModified()=" << m_doc->isModified();
 
 	this->setEnabled(true);
 }

buttar

2026-10-18 10:46

reporter   ~0054552

NEWER, BETTER, SMALLER.

Changes from v1.0 to v1.01

- Replaced per-master change tracking with simpler session-level tracking.
- Removed master-name set comparisons and associated edge cases.
- Skip master reapplication entirely when no edits are recorded.
- Preserve existing full reapplication when master-page changes occur.
- Keep tracking intact when switching between masters during a session.
- Moved session initialisation to the master-page entry path.
- Removed unnecessary `QSet` handling and Page Palette modifications.
- Reduced the patch from four files to three, with simpler code and comments.
- Rebases cleanly on pristine r27899; fully replaces v1.0.
masterpage-false-modified-fix-v1.01.patch (3,071 bytes)   
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(revision 27899)
+++ scribus/scribusdoc.h	(working copy)
@@ -1042,6 +1042,12 @@
 		void setMasterPageMode(bool);
 		void assignPageModeLists();
 
+		// Track changes during a master-page editing session so that leaving
+		// without edits does not reapply masters to every document page.
+		void beginMasterPageEditSession();
+		void endMasterPageEditSession();
+		bool masterPagesNeedReapplication() const;
+
 		/*** Is the document in master page mode? */
 		bool masterPageMode() const { return m_masterPageMode; }
 		/**
@@ -1367,6 +1373,8 @@
 		AnchorPoint m_rotMode {AnchorPoint::TopLeft};
 		bool m_automaticTextFrames; // Flag for automatic Textframes
 		bool m_masterPageMode {false};
+		bool m_masterPageEditSessionActive {false};
+		bool m_masterPageEditSessionChanged {false};
 		bool m_symbolEditMode {false};
 		bool m_inlineEditMode {false};
 		int  m_storedLayerID {0};
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 27899)
+++ scribus/scribusdoc.cpp	(working copy)
@@ -6815,6 +6815,24 @@
 }
 
 
+void ScribusDoc::beginMasterPageEditSession()
+{
+	m_masterPageEditSessionActive = true;
+	m_masterPageEditSessionChanged = false;
+}
+
+void ScribusDoc::endMasterPageEditSession()
+{
+	m_masterPageEditSessionActive = false;
+	m_masterPageEditSessionChanged = false;
+}
+
+bool ScribusDoc::masterPagesNeedReapplication() const
+{
+	// Keep the original behaviour if no editing session was started.
+	return !m_masterPageEditSessionActive || m_masterPageEditSessionChanged;
+}
+
 void ScribusDoc::setMasterPageMode(bool changeToMasterPageMode)
 {
 	if (changeToMasterPageMode == m_masterPageMode)
@@ -13960,6 +13978,8 @@
 
 void ScribusDoc::changed()
 {
+	if (m_masterPageEditSessionActive && m_masterPageMode)
+		m_masterPageEditSessionChanged = true;
 	setModified(true);
 	// Do not emit docChanged signal() unnecessarily
 	// Processing of that signal is slowwwwwww and
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 27899)
+++ scribus/scribus.cpp	(working copy)
@@ -7782,6 +7782,8 @@
 		return;
 	}
 
+	// Switching between masters in an open session must not reset the flag.
+	doc->beginMasterPageEditSession();
 	view->saveViewState();
 
 	pagePalette->startMasterPageMode(mpName);
@@ -7805,9 +7807,13 @@
 	}
 	slotSelect();
 	appModeHelper->setMasterPageEditMode(false, doc);
-	int pageCount = doc->DocPages.count();
-	for (int i = 0; i < pageCount; ++i)
-		Apply_MasterPage(doc->DocPages.at(i)->masterPageName(), i, false);
+	if (doc->masterPagesNeedReapplication())
+	{
+		int pageCount = doc->DocPages.count();
+		for (int i = 0; i < pageCount; ++i)
+			Apply_MasterPage(doc->DocPages.at(i)->masterPageName(), i, false);
+	}
+	doc->endMasterPageEditSession();
 
 	pagePalette->endMasterPageMode();
 	if (m_pagePaletteWasClosed && pagePalette->isFloating())

Issue History

Date Modified Username Field Change
2014-03-09 23:31 christoph_s New Issue
2014-03-10 06:18 jghali Target Version 1.5.0 =>
2014-06-23 11:31 Kunda Note Added: 0032258
2014-06-23 21:02 cbradney Note Added: 0032268
2014-07-23 21:23 Kunda Note Added: 0032933
2014-07-23 21:23 Kunda Status new => feedback
2015-08-30 17:47 Kunda Patch => No
2015-08-30 17:47 Kunda Note Added: 0036125
2015-08-30 17:47 Kunda Target Version => Future Release - Nice to have
2015-10-10 23:12 Kunda Relationship added related to 0003455
2016-05-12 17:15 Kunda Relationship added related to 0012811
2016-05-12 17:17 Kunda Relationship added related to 0013511
2016-05-12 17:18 Kunda Relationship added related to 0011619
2016-05-24 13:42 Kunda Tag Attached: dirty
2016-11-11 13:05 Kunda Status feedback => confirmed
2026-08-21 08:12 buttar Note Added: 0054261
2026-08-21 08:12 buttar File Added: masterpage-false-modified-fix-v1.0-report.pdf
2026-08-21 08:12 buttar File Added: masterpage-false-modified-fix-v1.0.patch
2026-08-21 08:13 buttar Note Added: 0054262
2026-08-21 08:13 buttar File Added: masterpage-changed-diagnostic-report.pdf
2026-08-21 08:13 buttar File Added: masterpage-changed-diagnostic-TEMPORARY-v1.0.patch
2026-08-21 08:17 buttar Tag Attached: #please_test
2026-10-18 10:46 buttar Note Added: 0054552
2026-10-18 10:46 buttar File Added: masterpage-false-modified-fix-v1.01.patch
2026-10-29 21:17 cbradney Assigned To => cbradney
2026-10-29 21:17 cbradney Status confirmed => resolved
2026-10-29 21:17 cbradney Resolution open => fixed
2026-10-29 21:17 cbradney Fixed in Version => 1.7.5.svn