Header refactoring patches

Yuriy Skalko yuriy.skalko at gmail.com
Sun Oct 25 07:09:00 UTC 2020


-------------- next part --------------
From eeacba8e112b8af7e5c924ad2cacb1457dc816dd Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Sun, 25 Oct 2020 00:47:13 +0300
Subject: [PATCH 1/2] Move include of own header to the top. Fix dependencies

---
 src/BiblioInfo.cpp                     | 3 ++-
 src/FontInfo.cpp                       | 3 ++-
 src/LaTeX.cpp                          | 3 ++-
 src/MetricsInfo.cpp                    | 3 ++-
 src/RowPainter.cpp                     | 3 +--
 src/TexRow.cpp                         | 3 ++-
 src/frontends/Clipboard.h              | 1 +
 src/frontends/qt/GuiClipboard.cpp      | 7 +++----
 src/frontends/qt/GuiCompareHistory.cpp | 5 +++--
 src/frontends/qt/GuiFontLoader.cpp     | 6 +++---
 src/frontends/qt/GuiKeySymbol.cpp      | 2 ++
 src/frontends/qt/GuiKeySymbol.h        | 3 ++-
 src/frontends/qt/GuiSearch.cpp         | 3 ++-
 src/frontends/qt/GuiViewSource.cpp     | 3 ++-
 src/frontends/qt/LengthCombo.cpp       | 4 ++--
 src/insets/InsetCommandParams.cpp      | 6 +++---
 src/insets/InsetFloat.cpp              | 3 ++-
 src/insets/InsetHyperlink.cpp          | 6 +++---
 src/mathed/MacroTable.cpp              | 3 ++-
 src/mathed/MathAutoCorrect.cpp         | 3 ++-
 src/output_docbook.cpp                 | 3 ++-
 src/support/Length.cpp                 | 3 ++-
 src/support/Timeout.cpp                | 3 ++-
 src/support/debug.cpp                  | 3 ++-
 src/support/filetools.cpp              | 4 ++--
 src/support/os_win32.cpp               | 3 ++-
 26 files changed, 55 insertions(+), 37 deletions(-)

diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp
index cefee85ba9..7d67e0849c 100644
--- a/src/BiblioInfo.cpp
+++ b/src/BiblioInfo.cpp
@@ -15,14 +15,15 @@
 #include <config.h>
 
 #include "BiblioInfo.h"
+
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "Citation.h"
 #include "Encoding.h"
 #include "Language.h"
-#include "xml.h"
 #include "TextClass.h"
 #include "TocBackend.h"
+#include "xml.h"
 
 #include "support/convert.h"
 #include "support/debug.h"
diff --git a/src/FontInfo.cpp b/src/FontInfo.cpp
index 397f7271f0..02a9e70e1e 100644
--- a/src/FontInfo.cpp
+++ b/src/FontInfo.cpp
@@ -14,8 +14,9 @@
 
 #include <config.h>
 
-#include "ColorSet.h"
 #include "FontInfo.h"
+
+#include "ColorSet.h"
 #include "Lexer.h"
 #include "LyXRC.h"
 
diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp
index b74b13254d..e9544705ab 100644
--- a/src/LaTeX.cpp
+++ b/src/LaTeX.cpp
@@ -15,10 +15,11 @@
 
 #include <config.h>
 
+#include "LaTeX.h"
+
 #include "Buffer.h"
 #include "BufferList.h"
 #include "BufferParams.h"
-#include "LaTeX.h"
 #include "LyXRC.h"
 #include "LyX.h"
 #include "DepTable.h"
diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp
index 15e772ea71..5aeb9a2980 100644
--- a/src/MetricsInfo.cpp
+++ b/src/MetricsInfo.cpp
@@ -10,9 +10,10 @@
 
 #include <config.h>
 
-#include "LyXRC.h"
 #include "MetricsInfo.h"
 
+#include "LyXRC.h"
+
 #include "insets/Inset.h"
 
 #include "mathed/MathSupport.h"
diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index c8b9157f3c..e378f433e8 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -11,8 +11,6 @@
 
 #include <config.h>
 
-#include <algorithm>
-
 #include "RowPainter.h"
 
 #include "Buffer.h"
@@ -39,6 +37,7 @@
 #include "support/gettext.h"
 #include "support/lassert.h"
 
+#include <algorithm>
 
 using namespace std;
 
diff --git a/src/TexRow.cpp b/src/TexRow.cpp
index 460a141600..968245bb68 100644
--- a/src/TexRow.cpp
+++ b/src/TexRow.cpp
@@ -13,11 +13,12 @@
 
 #include <config.h>
 
+#include "TexRow.h"
+
 #include "Buffer.h"
 #include "Cursor.h"
 #include "FuncRequest.h"
 #include "Paragraph.h"
-#include "TexRow.h"
 
 #include "mathed/InsetMath.h"
 
diff --git a/src/frontends/Clipboard.h b/src/frontends/Clipboard.h
index ce85ab6a07..21fd58227e 100644
--- a/src/frontends/Clipboard.h
+++ b/src/frontends/Clipboard.h
@@ -14,6 +14,7 @@
 #ifndef BASE_CLIPBOARD_H
 #define BASE_CLIPBOARD_H
 
+#include "support/FileName.h"
 #include "support/strfwd.h"
 
 namespace lyx {
diff --git a/src/frontends/qt/GuiClipboard.cpp b/src/frontends/qt/GuiClipboard.cpp
index 7922187644..422315a03e 100644
--- a/src/frontends/qt/GuiClipboard.cpp
+++ b/src/frontends/qt/GuiClipboard.cpp
@@ -12,19 +12,18 @@
 
 #include <config.h>
 
-#include "FileDialog.h"
-
-#include "support/FileName.h"
 #include "GuiClipboard.h"
-#include "qt_helpers.h"
 
 #include "Buffer.h"
 #include "BufferView.h"
 #include "Cursor.h"
+#include "FileDialog.h"
+#include "qt_helpers.h"
 
 #include "support/lassert.h"
 #include "support/convert.h"
 #include "support/debug.h"
+#include "support/FileName.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
diff --git a/src/frontends/qt/GuiCompareHistory.cpp b/src/frontends/qt/GuiCompareHistory.cpp
index b4228a5f53..4586eabad9 100644
--- a/src/frontends/qt/GuiCompareHistory.cpp
+++ b/src/frontends/qt/GuiCompareHistory.cpp
@@ -9,8 +9,6 @@
  */
 
 #include <config.h>
-#include <support/debug.h>
-#include <limits>
 
 #include "GuiCompareHistory.h"
 
@@ -21,11 +19,14 @@
 #include "LyXVC.h"
 
 #include "support/convert.h"
+#include "support/debug.h"
 #include "support/lstrings.h"
 
 #include <QDialogButtonBox>
 #include <QPushButton>
 
+#include <limits>
+
 using namespace std;
 using namespace lyx::support;
 
diff --git a/src/frontends/qt/GuiFontLoader.cpp b/src/frontends/qt/GuiFontLoader.cpp
index afbf03777a..80d45f6afc 100644
--- a/src/frontends/qt/GuiFontLoader.cpp
+++ b/src/frontends/qt/GuiFontLoader.cpp
@@ -11,8 +11,9 @@
 
 #include <config.h>
 
-#include "FontLoader.h"
+#include "GuiFontLoader.h"
 
+#include "FontLoader.h"
 #include "FontInfo.h"
 #include "GuiFontMetrics.h"
 #include "qt_helpers.h"
@@ -22,6 +23,7 @@
 #include "support/debug.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/Systemcall.h"
 #include "support/Package.h"
@@ -30,8 +32,6 @@
 #include <QFontInfo>
 #include <QFontDatabase>
 
-#include "support/lassert.h"
-
 using namespace std;
 using namespace lyx::support;
 
diff --git a/src/frontends/qt/GuiKeySymbol.cpp b/src/frontends/qt/GuiKeySymbol.cpp
index 851a1d3630..947e06d858 100644
--- a/src/frontends/qt/GuiKeySymbol.cpp
+++ b/src/frontends/qt/GuiKeySymbol.cpp
@@ -10,6 +10,8 @@
 
 #include <config.h>
 
+#include "GuiKeySymbol.h"
+
 #include "KeySymbol.h"
 #include "GuiApplication.h"
 
diff --git a/src/frontends/qt/GuiKeySymbol.h b/src/frontends/qt/GuiKeySymbol.h
index e4a59b7f5e..a3293d7c2f 100644
--- a/src/frontends/qt/GuiKeySymbol.h
+++ b/src/frontends/qt/GuiKeySymbol.h
@@ -13,7 +13,8 @@
 #ifndef GUIKEYSYM_H
 #define GUIKEYSYM_H
 
-class QKeyEvent;
+#include "KeySymbol.h"
+#include <QKeyEvent>
 
 namespace lyx {
 
diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp
index 3fffb6ea2b..1d209a24d0 100644
--- a/src/frontends/qt/GuiSearch.cpp
+++ b/src/frontends/qt/GuiSearch.cpp
@@ -12,13 +12,14 @@
 
 #include <config.h>
 
+#include "GuiSearch.h"
+
 #include "lyxfind.h"
 #include "qt_helpers.h"
 #include "FuncRequest.h"
 #include "BufferView.h"
 #include "Buffer.h"
 #include "Cursor.h"
-#include "GuiSearch.h"
 #include "GuiView.h"
 
 #include "support/gettext.h"
diff --git a/src/frontends/qt/GuiViewSource.cpp b/src/frontends/qt/GuiViewSource.cpp
index 58560f519e..40752cde14 100644
--- a/src/frontends/qt/GuiViewSource.cpp
+++ b/src/frontends/qt/GuiViewSource.cpp
@@ -12,8 +12,9 @@
 
 #include <config.h>
 
-#include "GuiApplication.h"
 #include "GuiViewSource.h"
+
+#include "GuiApplication.h"
 #include "LaTeXHighlighter.h"
 #include "qt_helpers.h"
 
diff --git a/src/frontends/qt/LengthCombo.cpp b/src/frontends/qt/LengthCombo.cpp
index 6eacfbfb36..1ab6d7df24 100644
--- a/src/frontends/qt/LengthCombo.cpp
+++ b/src/frontends/qt/LengthCombo.cpp
@@ -12,10 +12,10 @@
 
 #include <config.h>
 
-#include "support/qstring_helpers.h"
-
 #include "LengthCombo.h"
 
+#include "support/qstring_helpers.h"
+
 #include "qt_helpers.h"
 
 #include <string>
diff --git a/src/insets/InsetCommandParams.cpp b/src/insets/InsetCommandParams.cpp
index 69671c222b..2ee1934e06 100644
--- a/src/insets/InsetCommandParams.cpp
+++ b/src/insets/InsetCommandParams.cpp
@@ -11,9 +11,6 @@
  */
 
 #include <config.h>
-#include <algorithm>
-#include <functional>
-
 
 #include "InsetCommandParams.h"
 
@@ -46,6 +43,9 @@
 
 #include "support/lassert.h"
 
+#include <algorithm>
+#include <functional>
+
 using namespace std;
 using namespace lyx::support;
 
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 92397dd7a4..92d3ad0457 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -12,9 +12,10 @@
 
 #include <config.h>
 
+#include "InsetFloat.h"
+
 #include "InsetBox.h"
 #include "InsetCaption.h"
-#include "InsetFloat.h"
 #include "InsetGraphics.h"
 #include "InsetLabel.h"
 
diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp
index bfa478d2f1..8894794186 100644
--- a/src/insets/InsetHyperlink.cpp
+++ b/src/insets/InsetHyperlink.cpp
@@ -12,9 +12,6 @@
 #include <config.h>
 #include "InsetHyperlink.h"
 
-#include <QtGui/QDesktopServices>
-#include <QUrl>
-
 #include "Buffer.h"
 #include "DispatchResult.h"
 #include "Encoding.h"
@@ -37,6 +34,9 @@
 
 #include "frontends/alert.h"
 
+#include <QtGui/QDesktopServices>
+#include <QUrl>
+
 using namespace std;
 using namespace lyx::support;
 
diff --git a/src/mathed/MacroTable.cpp b/src/mathed/MacroTable.cpp
index 19d45d2069..c1a4c49312 100644
--- a/src/mathed/MacroTable.cpp
+++ b/src/mathed/MacroTable.cpp
@@ -10,8 +10,9 @@
 
 #include <config.h>
 
-#include "InsetMathSqrt.h"
 #include "MacroTable.h"
+
+#include "InsetMathSqrt.h"
 #include "InsetMathMacroTemplate.h"
 #include "InsetMathMacroArgument.h"
 #include "MathParser.h"
diff --git a/src/mathed/MathAutoCorrect.cpp b/src/mathed/MathAutoCorrect.cpp
index 77e5fefbd4..5d5a7d098c 100644
--- a/src/mathed/MathAutoCorrect.cpp
+++ b/src/mathed/MathAutoCorrect.cpp
@@ -10,8 +10,9 @@
 
 #include <config.h>
 
-#include "Cursor.h"
 #include "MathAutoCorrect.h"
+
+#include "Cursor.h"
 #include "MathData.h"
 #include "InsetMath.h"
 #include "MathSupport.h"
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 0c06b87723..63cae8a58b 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -11,12 +11,13 @@
 
 #include <config.h>
 
+#include "output_docbook.h"
+
 #include "Buffer.h"
 #include "buffer_funcs.h"
 #include "BufferParams.h"
 #include "Font.h"
 #include "InsetList.h"
-#include "output_docbook.h"
 #include "Paragraph.h"
 #include "ParagraphList.h"
 #include "ParagraphParameters.h"
diff --git a/src/support/Length.cpp b/src/support/Length.cpp
index d23ea9bf98..d3aa434892 100644
--- a/src/support/Length.cpp
+++ b/src/support/Length.cpp
@@ -15,11 +15,12 @@
 
 #include <config.h>
 
+#include "support/Length.h"
+
 #include "LyXRC.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
-#include "support/Length.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 
diff --git a/src/support/Timeout.cpp b/src/support/Timeout.cpp
index 3c3502e412..e42fabc9f1 100644
--- a/src/support/Timeout.cpp
+++ b/src/support/Timeout.cpp
@@ -10,8 +10,9 @@
 
 #include <config.h>
 
-#include "support/lassert.h"
 #include "support/Timeout.h"
+
+#include "support/lassert.h"
 #include "support/debug.h"
 
 #include <QObject>
diff --git a/src/support/debug.cpp b/src/support/debug.cpp
index ada2577eae..6ec52a069c 100644
--- a/src/support/debug.cpp
+++ b/src/support/debug.cpp
@@ -12,8 +12,9 @@
 
 #include <config.h>
 
-#include "support/convert.h"
 #include "support/debug.h"
+
+#include "support/convert.h"
 #include "support/FileName.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp
index 178d1f1dd4..6d6674dce9 100644
--- a/src/support/filetools.cpp
+++ b/src/support/filetools.cpp
@@ -21,11 +21,11 @@
 
 #include <config.h>
 
+#include "support/filetools.h"
+
 #include "LyX.h"
 #include "LyXRC.h"
 
-#include "support/filetools.h"
-
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/environment.h"
diff --git a/src/support/os_win32.cpp b/src/support/os_win32.cpp
index 536d2a6446..1d40e56742 100644
--- a/src/support/os_win32.cpp
+++ b/src/support/os_win32.cpp
@@ -15,10 +15,11 @@
 
 #include <config.h>
 
+#include "support/os_win32.h"
+
 #include "LyXRC.h"
 
 #include "support/os.h"
-#include "support/os_win32.h"
 
 #include "support/debug.h"
 #include "support/environment.h"
-- 
2.28.0.windows.1

-------------- next part --------------
From 6afd632f0db16e79f0057d8258967b65387be2a6 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.skalko at gmail.com>
Date: Sun, 25 Oct 2020 08:54:27 +0200
Subject: [PATCH 2/2] Move Windows-specific stuff into os_win32.h

---
 src/frontends/qt/GuiBox.cpp      | 4 ----
 src/frontends/qt/GuiDocument.cpp | 4 ----
 src/support/os_win32.h           | 3 +++
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/frontends/qt/GuiBox.cpp b/src/frontends/qt/GuiBox.cpp
index 298009da1b..0d22aa7963 100644
--- a/src/frontends/qt/GuiBox.cpp
+++ b/src/frontends/qt/GuiBox.cpp
@@ -32,10 +32,6 @@
 #include <QLineEdit>
 #include <QPushButton>
 
-#ifdef IN
-#undef IN
-#endif
-
 using namespace std;
 
 
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index 7e1ec248b1..0244bfdfe8 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -85,10 +85,6 @@
 #include <sstream>
 #include <vector>
 
-#ifdef IN
-#undef IN
-#endif
-
 
 // a style sheet for buttons
 // this is for example used for the background color setting button
diff --git a/src/support/os_win32.h b/src/support/os_win32.h
index 3f278c3bd0..a656f6f182 100644
--- a/src/support/os_win32.h
+++ b/src/support/os_win32.h
@@ -49,6 +49,9 @@
 #include <tchar.h>
 #include <psapi.h>
 
+#ifdef IN
+#undef IN // used in Length::UNIT enum
+#endif
 
 namespace lyx {
 namespace support {
-- 
2.28.0.windows.1



More information about the lyx-devel mailing list