summaryrefslogtreecommitdiffstats
path: root/lib/util/filetemplate.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-12-16 20:56:37 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-12-16 20:56:37 +0100
commit6fa6e46d9d7becae27a8e1534ec5da8833ff7c17 (patch)
tree43f4855af2c9416c98ccbf25def348907edf9506 /lib/util/filetemplate.cpp
parentc5e1fe9eb336c338462ed23682a51b9557084ec2 (diff)
downloadtdevelop-6fa6e46d9d7becae27a8e1534ec5da8833ff7c17.tar.gz
tdevelop-6fa6e46d9d7becae27a8e1534ec5da8833ff7c17.zip
Fix crash on creating new file if project is not open.
This resolves issue #4. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'lib/util/filetemplate.cpp')
-rw-r--r--lib/util/filetemplate.cpp6
1 files changed, 5 insertions, 1 deletions
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 );
}