summaryrefslogtreecommitdiff
path: root/src/mainwin.cc
diff options
context:
space:
mode:
authorkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-02-23 20:47:54 (GMT)
committerkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-02-23 20:47:54 (GMT)
commitf3d16e23b959be4eb05c50e09a880b1e642f3432 (patch)
tree9e27ce8f230fa3c8645c363a3823d82649839261 /src/mainwin.cc
parent64c3be3fd7734f94f1057825ad66ba4ac2393134 (diff)
Multiple non-MDI assumptions were made, setting CWD and assuming it didn't change. Fix required to pass more context to nodes (functions). It's not totally clean, but it's a start. Fixes bugs: opening multiple files simultaneously only loaded the first file, refreshing an scad file referencing an external file failed if another scad file was opened in the meantime.
git-svn-id: http://svn.clifford.at/openscad/trunk@451 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'src/mainwin.cc')
-rw-r--r--src/mainwin.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 296cdb5..0767a05 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -117,7 +117,7 @@ static char copyrighttext[] =
QPointer<MainWindow> MainWindow::current_win = NULL;
-MainWindow::MainWindow(const char *filename)
+MainWindow::MainWindow(const QString &filename)
{
setupUi(this);
@@ -299,7 +299,7 @@ MainWindow::MainWindow(const char *filename)
PRINT(copyrighttext);
PRINT("");
- if (filename) {
+ if (!filename.isEmpty()) {
openFile(filename);
} else {
setFileName("");
@@ -387,7 +387,7 @@ static void report_func(const class AbstractNode*, void *vp, int mark)
#ifdef ENABLE_MDI
void MainWindow::requestOpenFile(const QString &filename)
{
- new MainWindow(filename.toUtf8());
+ new MainWindow(filename);
}
#else
void MainWindow::requestOpenFile(const QString &)
@@ -400,7 +400,7 @@ MainWindow::openFile(const QString &new_filename)
{
#ifdef ENABLE_MDI
if (!editor->toPlainText().isEmpty()) {
- new MainWindow(new_filename.toUtf8());
+ new MainWindow(new_filename);
current_win = NULL;
return;
}
@@ -415,6 +415,7 @@ MainWindow::setFileName(const QString &filename)
{
if (filename.isEmpty()) {
this->fileName.clear();
+ this->root_ctx.document_path = currentdir;
setWindowTitle("OpenSCAD - New Document[*]");
}
else {
@@ -437,6 +438,7 @@ MainWindow::setFileName(const QString &filename)
this->fileName = fileinfo.fileName();
}
+ this->root_ctx.document_path = fileinfo.dir().absolutePath();
QDir::setCurrent(fileinfo.dir().absolutePath());
}
@@ -773,7 +775,7 @@ void MainWindow::compileCSG(bool procevents)
void MainWindow::actionNew()
{
#ifdef ENABLE_MDI
- new MainWindow;
+ new MainWindow(QString());
#else
setFileName("");
editor->setPlainText("");
contact: Jan Huwald // Impressum