From 45c6d651358e9a288326a06a0b51c37bca9b1392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Mon, 16 Dec 2019 20:56:37 +0100 Subject: [PATCH] Fix crash on creating new file if project is not open. This resolves issue #4. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko (cherry picked from commit 6fa6e46d9d7becae27a8e1534ec5da8833ff7c17) --- lib/util/filetemplate.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/util/filetemplate.cpp b/lib/util/filetemplate.cpp index c2454580..bb2cb7c6 100644 --- a/lib/util/filetemplate.cpp +++ b/lib/util/filetemplate.cpp @@ -52,13 +52,17 @@ TQString FileTemplate::read(KDevPlugin *part, const TQString &name, Policy p) TQString FileTemplate::readFile(KDevPlugin *part, const TQString &fileName) { - TQDomDocument &dom = *part->projectDom(); + TQDomDocument dom; TQFile f(fileName); if (!f.open(IO_ReadOnly)) return TQString(); TQTextStream stream(&f); TQString str = stream.read(); + if (part->projectDom()) + { + dom = *part->projectDom(); + } return makeSubstitutions( dom, str ); }