MCPcopy Create free account
hub / github.com/BambooTracker/BambooTracker / openModule

Method openModule

BambooTracker/gui/mainwindow.cpp:2182–2248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2180}
2181
2182void MainWindow::openModule(const QString& file)
2183{
2184 try {
2185 freezeViews();
2186 if (tickTimerForRealChip_) tickTimerForRealChip_->stop();
2187 else {
2188 try {
2189 stream_->stop();
2190 }
2191 catch (std::exception& e) {
2192 showStreamFailedDialog(e.what());
2193 }
2194 }
2195
2196 QFile fp(file);
2197 if (fp.open(QIODevice::ReadOnly)) {
2198 io::BinaryContainer container;
2199 {
2200 QByteArray&& array = fp.readAll();
2201 fp.close();
2202 std::move(array.begin(), array.end(), std::back_inserter(container));
2203 }
2204
2205 bt_->loadModule(container);
2206 bt_->setModulePath(file.toStdString());
2207
2208 loadModule();
2209
2210 config_.lock()->setWorkingDirectory(QFileInfo(file).dir().path().toStdString());
2211 changeFileHistory(file);
2212
2213 goto AFTER_MOD_LOADING; // Skip error handling section
2214 }
2215 else {
2216 FileIOErrorMessageBox::openError(file, true, io::FileType::Mod, this);
2217 }
2218 }
2219 catch (std::exception& e) {
2220 if (auto ef = dynamic_cast<io::FileIOError*>(&e)) {
2221 FileIOErrorMessageBox(file, true, *ef, this).exec();
2222 }
2223 else {
2224 FileIOErrorMessageBox(file, true, io::FileType::Mod, QString(e.what()), this).exec();
2225 }
2226 }
2227
2228 // Init module as a plain when something is wrong
2229 freezeViews();
2230 bt_->makeNewModule();
2231 loadModule();
2232
2233AFTER_MOD_LOADING: // Post process of module loading
2234 isModifiedForNotCommand_ = false;
2235 setWindowModified(false);
2236 if (tickTimerForRealChip_) tickTimerForRealChip_->start();
2237 else {
2238 try {
2239 stream_->start();

Callers

nothing calls this directly

Calls 10

setModulePathMethod · 0.80
setWorkingDirectoryMethod · 0.80
execMethod · 0.80
makeNewModuleMethod · 0.80
stopMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
loadModuleMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected