Line 0
Link Here
|
|
|
1 |
# Origin: https://github.com/gottcode/focuswriter/commit/e7311fb017782a0bbf017d0055f6f01b36233b89 |
2 |
# Subject: FIXED: Possible delay on start when creating non-native printer. |
3 |
# Origin: https://github.com/gottcode/focuswriter/commit/1423754c4eae874857ce34613bddead8224ee887 |
4 |
# Subject: FIXED: Memory leak from creating multiple printers. |
5 |
|
6 |
--- src/stack.cpp.orig 2016-10-13 09:37:59 UTC |
7 |
+++ src/stack.cpp |
8 |
@@ -55,6 +55,7 @@ |
9 |
Stack::Stack(QWidget* parent) : |
10 |
QWidget(parent), |
11 |
m_symbols_dialog(0), |
12 |
+ m_printer(0), |
13 |
m_current_document(0), |
14 |
m_footer_margin(0), |
15 |
m_header_margin(0), |
16 |
@@ -78,17 +79,6 @@ Stack::Stack(QWidget* parent) : |
17 |
m_find_dialog = new FindDialog(this); |
18 |
connect(m_find_dialog, SIGNAL(findNextAvailable(bool)), this, SIGNAL(findNextAvailable(bool))); |
19 |
|
20 |
- m_printer = new QPrinter(QPrinter::HighResolution); |
21 |
-#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0)) |
22 |
- m_printer->setPageSize(QPageSize(QPageSize::Letter)); |
23 |
- m_printer->setPageOrientation(QPageLayout::Portrait); |
24 |
- m_printer->setPageMargins(QMarginsF(1.0, 1.0, 1.0, 1.0), QPageLayout::Inch); |
25 |
-#else |
26 |
- m_printer->setPageSize(QPrinter::Letter); |
27 |
- m_printer->setOrientation(QPrinter::Portrait); |
28 |
- m_printer->setPageMargins(1.0, 1.0, 1.0, 1.0, QPrinter::Inch); |
29 |
-#endif |
30 |
- |
31 |
connect(ActionManager::instance(), SIGNAL(insertText(QString)), this, SLOT(insertSymbol(QString))); |
32 |
|
33 |
m_layout = new QGridLayout(this); |
34 |
@@ -397,6 +387,7 @@ void Stack::pasteUnformatted() |
35 |
|
36 |
void Stack::pageSetup() |
37 |
{ |
38 |
+ initPrinter(); |
39 |
QPageSetupDialog dialog(m_printer, this); |
40 |
dialog.exec(); |
41 |
} |
42 |
@@ -405,6 +396,7 @@ void Stack::pageSetup() |
43 |
|
44 |
void Stack::print() |
45 |
{ |
46 |
+ initPrinter(); |
47 |
m_current_document->print(m_printer); |
48 |
} |
49 |
|
50 |
@@ -835,3 +827,23 @@ void Stack::updateMenuIndexes() |
51 |
} |
52 |
|
53 |
//----------------------------------------------------------------------------- |
54 |
+ |
55 |
+void Stack::initPrinter() |
56 |
+{ |
57 |
+ if (m_printer) { |
58 |
+ return; |
59 |
+ } |
60 |
+ |
61 |
+ m_printer = new QPrinter(QPrinter::HighResolution); |
62 |
+#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0)) |
63 |
+ m_printer->setPageSize(QPageSize(QPageSize::Letter)); |
64 |
+ m_printer->setPageOrientation(QPageLayout::Portrait); |
65 |
+ m_printer->setPageMargins(QMarginsF(1.0, 1.0, 1.0, 1.0), QPageLayout::Inch); |
66 |
+#else |
67 |
+ m_printer->setPageSize(QPrinter::Letter); |
68 |
+ m_printer->setOrientation(QPrinter::Portrait); |
69 |
+ m_printer->setPageMargins(1.0, 1.0, 1.0, 1.0, QPrinter::Inch); |
70 |
+#endif |
71 |
+} |
72 |
+ |
73 |
+//----------------------------------------------------------------------------- |
74 |
--- src/stack.h.orig 2016-10-13 09:37:59 UTC |
75 |
+++ src/stack.h |
76 |
@@ -140,6 +140,7 @@ private: |
77 |
#if (QT_VERSION < QT_VERSION_CHECK(5,6,0)) |
78 |
qreal devicePixelRatioF() const { return devicePixelRatio(); } |
79 |
#endif |
80 |
+ void initPrinter(); |
81 |
|
82 |
private: |
83 |
AlertLayer* m_alerts; |