Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 focuswriter (1.5.5-2) unstable; urgency=medium
 .
   * merge upstream stable branch fixes
   * enable more hardening
   * remove debian/menu
   * bump debian standards version
   * use more secure protocols for URLs in debian/control
Author: Barak A. Pearlmutter <bap@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- focuswriter-1.5.5.orig/src/find_dialog.cpp
+++ focuswriter-1.5.5/src/find_dialog.cpp
@@ -1,6 +1,6 @@
 /***********************************************************************
  *
- * Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014 Graeme Gott <graeme@gottcode.org>
+ * Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014, 2016 Graeme Gott <graeme@gottcode.org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -288,7 +288,6 @@ void FindDialog::replaceAll()
 			cursor = document->document()->find(text, cursor, flags);
 			if (!cursor.isNull()) {
 				cursor.insertText(m_replace_string->text());
-				document->setTextCursor(cursor);
 			} else {
 				break;
 			}
@@ -300,7 +299,6 @@ void FindDialog::replaceAll()
 				QString match = cursor.selectedText();
 				match.replace(regex, m_replace_string->text());
 				cursor.insertText(match);
-				document->setTextCursor(cursor);
 			} else {
 				break;
 			}
--- focuswriter-1.5.5.orig/src/main.cpp
+++ focuswriter-1.5.5/src/main.cpp
@@ -1,6 +1,6 @@
 /***********************************************************************
  *
- * Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Graeme Gott <graeme@gottcode.org>
+ * Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016 Graeme Gott <graeme@gottcode.org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -210,6 +210,7 @@ int main(int argc, char** argv)
 		settings.remove("Text");
 
 		if (theme.isChanged()) {
+			theme.saveChanges();
 			settings.setValue("ThemeManager/Theme", theme.name());
 		}
 	}
--- focuswriter-1.5.5.orig/src/theme.cpp
+++ focuswriter-1.5.5/src/theme.cpp
@@ -1,6 +1,6 @@
 /***********************************************************************
  *
- * Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Graeme Gott <graeme@gottcode.org>
+ * Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2016 Graeme Gott <graeme@gottcode.org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -116,6 +116,13 @@ Theme::Theme()
 
 //-----------------------------------------------------------------------------
 
+Theme::Theme(const Theme& theme) :
+	d(theme.d)
+{
+}
+
+//-----------------------------------------------------------------------------
+
 Theme::Theme(const QString& id, bool is_default)
 {
 	d = new ThemeData(id, is_default, true);
@@ -126,7 +133,6 @@ Theme::Theme(const QString& id, bool is_
 
 Theme::~Theme()
 {
-	saveChanges();
 }
 
 //-----------------------------------------------------------------------------
@@ -152,6 +158,7 @@ QString Theme::clone(const QString& id,
 		Theme duplicate(id, is_default);
 		duplicate.setValue(duplicate.d->name, new_name);
 		duplicate.setValue(duplicate.d->id, new_id);
+		duplicate.saveChanges();
 	}
 
 	// Copy icon
--- focuswriter-1.5.5.orig/src/theme.h
+++ focuswriter-1.5.5/src/theme.h
@@ -1,6 +1,6 @@
 /***********************************************************************
  *
- * Copyright (C) 2009, 2010, 2012, 2013, 2014 Graeme Gott <graeme@gottcode.org>
+ * Copyright (C) 2009, 2010, 2012, 2013, 2014, 2016 Graeme Gott <graeme@gottcode.org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -79,10 +79,11 @@ class Theme : public SettingsFile
 		RangedInt paragraph_spacing_below;
 		RangedInt tab_width;
 	};
-	QExplicitlySharedDataPointer<ThemeData> d;
+	QSharedDataPointer<ThemeData> d;
 
 public:
 	Theme();
+	Theme(const Theme& theme);
 	Theme(const QString& id, bool is_default);
 	~Theme();
 
--- focuswriter-1.5.5.orig/src/theme_dialog.cpp
+++ focuswriter-1.5.5/src/theme_dialog.cpp
@@ -460,14 +460,6 @@ void ThemeDialog::accept()
 
 //-----------------------------------------------------------------------------
 
-void ThemeDialog::reject()
-{
-	m_theme.forgetChanges();
-	QDialog::reject();
-}
-
-//-----------------------------------------------------------------------------
-
 void ThemeDialog::hideEvent(QHideEvent* event)
 {
 	QSettings().setValue("ThemeDialog/Size", size());
@@ -579,7 +571,6 @@ void ThemeDialog::renderPreview()
 	Theme theme;
 	setValues(theme);
 	theme.setBackgroundImage(m_background_image->image());
-	theme.forgetChanges();
 
 	// Render theme
 	m_theme_renderer->create(theme, QSize(1920, 1080));
--- focuswriter-1.5.5.orig/src/theme_dialog.h
+++ focuswriter-1.5.5/src/theme_dialog.h
@@ -49,7 +49,6 @@ public:
 
 public slots:
 	virtual void accept();
-	virtual void reject();
 
 protected:
 	virtual void hideEvent(QHideEvent* event);
--- focuswriter-1.5.5.orig/src/theme_manager.cpp
+++ focuswriter-1.5.5/src/theme_manager.cpp
@@ -1,6 +1,6 @@
 /***********************************************************************
  *
- * Copyright (C) 2009, 2010, 2012, 2014 Graeme Gott <graeme@gottcode.org>
+ * Copyright (C) 2009, 2010, 2012, 2014, 2016 Graeme Gott <graeme@gottcode.org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -384,6 +384,7 @@ void ThemeManager::importTheme()
 
 		Theme theme(id, false);
 		theme.setBackgroundImage(file.fileName());
+		theme.saveChanges();
 	}
 
 	theme_ini.sync();
