comparison main/main.cpp @ 82:d82e332cb178

* Fix #1491849 strange behaviour on Cancel during query on new file load
author Chris Cannam
date Fri, 05 Jan 2007 12:59:51 +0000
parents c1318aac18d2
children 0d2fb43b5ee5
comparison
equal deleted inserted replaced
81:911c0bd745cd 82:d82e332cb178
148 bool haveSession = false; 148 bool haveSession = false;
149 bool haveMainModel = false; 149 bool haveMainModel = false;
150 150
151 for (QStringList::iterator i = args.begin(); i != args.end(); ++i) { 151 for (QStringList::iterator i = args.begin(); i != args.end(); ++i) {
152 152
153 bool success = false; 153 MainWindow::FileOpenStatus status = MainWindow::FileOpenSucceeded;
154 154
155 if (i == args.begin()) continue; 155 if (i == args.begin()) continue;
156 if (i->startsWith('-')) continue; 156 if (i->startsWith('-')) continue;
157 157
158 QString path = *i; 158 QString path = *i;
159 159
160 if (path.endsWith("sv")) { 160 if (path.endsWith("sv")) {
161 if (!haveSession) { 161 if (!haveSession) {
162 success = gui.openSessionFile(path); 162 status = gui.openSessionFile(path);
163 if (success) { 163 if (status == MainWindow::FileOpenSucceeded) {
164 haveSession = true; 164 haveSession = true;
165 haveMainModel = true; 165 haveMainModel = true;
166 } 166 }
167 } else { 167 } else {
168 std::cerr << "WARNING: Ignoring additional session file argument \"" << path.toStdString() << "\"" << std::endl; 168 std::cerr << "WARNING: Ignoring additional session file argument \"" << path.toStdString() << "\"" << std::endl;
169 success = true; 169 status = MainWindow::FileOpenSucceeded;
170 } 170 }
171 } 171 }
172 if (!success) { 172 if (status != MainWindow::FileOpenSucceeded) {
173 if (!haveMainModel) { 173 if (!haveMainModel) {
174 success = gui.openSomeFile(path, MainWindow::ReplaceMainModel); 174 status = gui.openSomeFile(path, MainWindow::ReplaceMainModel);
175 if (success) haveMainModel = true; 175 if (status == MainWindow::FileOpenSucceeded) haveMainModel = true;
176 } else { 176 } else {
177 success = gui.openSomeFile(path, MainWindow::CreateAdditionalModel); 177 status = gui.openSomeFile(path, MainWindow::CreateAdditionalModel);
178 } 178 }
179 } 179 }
180 if (!success) { 180 if (status == MainWindow::FileOpenFailed) {
181 QMessageBox::critical 181 QMessageBox::critical
182 (&gui, QMessageBox::tr("Failed to open file"), 182 (&gui, QMessageBox::tr("Failed to open file"),
183 QMessageBox::tr("File \"%1\" could not be opened").arg(path)); 183 QMessageBox::tr("File \"%1\" could not be opened").arg(path));
184 } 184 }
185 } 185 }