diff --git a/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp b/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp index 5efecea..6f958ce 100644 --- a/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp +++ b/toonz/sources/image/ffmpeg/tiio_ffmpeg.cpp @@ -189,6 +189,9 @@ QString Ffmpeg::runFfprobe(QStringList args) { results += ffmpeg.readAllStandardOutput(); int exitCode = ffmpeg.exitCode(); ffmpeg.close(); + // If the url cannot be opened or recognized as a multimedia file, ffprobe + // returns a positive exit code. + if (exitCode > 0) throw TImageException(m_path, "error reading info."); std::string strResults = results.toStdString(); return results; } @@ -408,7 +411,7 @@ void Ffmpeg::getFramesFromMovie(int frame) { QString Ffmpeg::cleanPathSymbols() { return m_path.getQString().remove(QRegExp( - QString::fromUtf8("[-`~!@#$%^&*()_�+=|:;<>��,.?/{}\'\"\\[\\]\\\\]"))); + QString::fromUtf8("[-`~!@#$%^&*()_—+=|:;<>«»,.?/{}\'\"\\[\\]\\\\]"))); } int Ffmpeg::getGifFrameCount() { diff --git a/toonz/sources/toonz/dvdirtreeview.cpp b/toonz/sources/toonz/dvdirtreeview.cpp index 60ca55e..6e38772 100644 --- a/toonz/sources/toonz/dvdirtreeview.cpp +++ b/toonz/sources/toonz/dvdirtreeview.cpp @@ -63,17 +63,17 @@ MyFileSystemWatcher::MyFileSystemWatcher() { void MyFileSystemWatcher::addPaths(const QStringList &paths, bool onlyNewPath) { if (paths.isEmpty()) return; - if (onlyNewPath) { - for (int p = 0; p < paths.size(); p++) { - QString path = paths.at(p); - if (!m_watchedPath.contains(path)) { - m_watchedPath.append(path); - m_watcher->addPath(path); - } + for (int p = 0; p < paths.size(); p++) { + QString path = paths.at(p); + // if the path is not watched yet, try to start watching it + if (!m_watchedPath.contains(path)) { + // symlink path will not be watched + if (m_watcher->addPath(path)) m_watchedPath.append(path); + } + // or just add path to the list + else if (!onlyNewPath) { + m_watchedPath.append(path); } - } else { - m_watchedPath.append(paths); - m_watcher->addPaths(paths); } } @@ -81,9 +81,9 @@ void MyFileSystemWatcher::removePaths(const QStringList &paths) { if (m_watchedPath.isEmpty() || paths.isEmpty()) return; for (int p = 0; p < paths.size(); p++) { QString path = paths.at(p); - bool ret = m_watchedPath.removeOne(path); - assert(ret); - if (!m_watchedPath.contains(path)) m_watcher->removePath(path); + // removeOne will return false for symlink paths + bool ret = m_watchedPath.removeOne(path); + if (ret && !m_watchedPath.contains(path)) m_watcher->removePath(path); } } @@ -1631,8 +1631,11 @@ void DvDirTreeView::getExpandedPathsRecursive(const QModelIndex &index, void DvDirTreeView::onExpanded(const QModelIndex &index) { QStringList paths; - getExpandedPathsRecursive(index, paths); - if (paths.size()) paths.removeFirst(); + int count = DvDirModel::instance()->rowCount(index); + for (int r = 0; r < count; r++) { + QModelIndex child = DvDirModel::instance()->index(r, 0, index); + getExpandedPathsRecursive(child, paths); + } MyFileSystemWatcher::instance()->addPaths(paths); } diff --git a/toonz/sources/toonz/filebrowser.cpp b/toonz/sources/toonz/filebrowser.cpp index 0fafddf..a14fe8a 100644 --- a/toonz/sources/toonz/filebrowser.cpp +++ b/toonz/sources/toonz/filebrowser.cpp @@ -689,7 +689,8 @@ void FileBrowser::setFolder(const TFilePath &fp, bool expandNode, refreshCurrentFolderItems(); - m_folderTreeView->setCurrentNode(fp, expandNode); + if (!TFileStatus(fp).isLink()) + m_folderTreeView->setCurrentNode(fp, expandNode); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/filebrowserpopup.cpp b/toonz/sources/toonz/filebrowserpopup.cpp index 737a02f..0b3b5b5 100644 --- a/toonz/sources/toonz/filebrowserpopup.cpp +++ b/toonz/sources/toonz/filebrowserpopup.cpp @@ -964,38 +964,42 @@ void LoadLevelPopup::updatePosTo() { // loading another type of level such as tlv else { if (fp.isEmpty()) return; - - TLevelReaderP lr(fp); - TLevelP level; - if (lr) level = lr->loadInfo(); - if (!level.getPointer()) return; - - if (m_stepCombo->currentIndex() == 0) // Step = Auto - { - TLevel::Iterator it; - int firstFrame = 0; - int lastFrame = 0; - for (it = level->begin(); it != level->end(); it++) { - if (xFrom <= it->first.getNumber()) { - firstFrame = it->first.getNumber(); - break; + try { + TLevelReaderP lr(fp); + TLevelP level; + if (lr) level = lr->loadInfo(); + if (!level.getPointer()) return; + + if (m_stepCombo->currentIndex() == 0) // Step = Auto + { + TLevel::Iterator it; + int firstFrame = 0; + int lastFrame = 0; + for (it = level->begin(); it != level->end(); it++) { + if (xFrom <= it->first.getNumber()) { + firstFrame = it->first.getNumber(); + break; + } } - } - for (it = level->begin(); it != level->end(); it++) { - if (it->first.getNumber() <= xTo) { - lastFrame = it->first.getNumber(); + for (it = level->begin(); it != level->end(); it++) { + if (it->first.getNumber() <= xTo) { + lastFrame = it->first.getNumber(); + } } + frameLength = lastFrame - firstFrame + 1; + } else // Step != Auto + { + TLevel::Iterator it; + int loopAmount = 0; + for (it = level->begin(); it != level->end(); it++) { + if (xFrom <= it->first.getNumber() && + it->first.getNumber() <= xTo) + loopAmount++; + } + frameLength = loopAmount * m_stepCombo->currentIndex(); } - frameLength = lastFrame - firstFrame + 1; - } else // Step != Auto - { - TLevel::Iterator it; - int loopAmount = 0; - for (it = level->begin(); it != level->end(); it++) { - if (xFrom <= it->first.getNumber() && it->first.getNumber() <= xTo) - loopAmount++; - } - frameLength = loopAmount * m_stepCombo->currentIndex(); + } catch (...) { + return; } } } @@ -1090,14 +1094,18 @@ bool LoadLevelPopup::execute() { } // another case such as loading tlv else { - TLevelReaderP lr(fp); - TLevelP level; - if (lr) level = lr->loadInfo(); - if (!level.getPointer()) return false; - - firstFrame = level->begin()->first; - lastFrame = (--level->end())->first; - lr = TLevelReaderP(); + try { + TLevelReaderP lr(fp); + TLevelP level; + if (lr) level = lr->loadInfo(); + if (!level.getPointer()) return false; + + firstFrame = level->begin()->first; + lastFrame = (--level->end())->first; + lr = TLevelReaderP(); + } catch (...) { + return false; + } } int firstFrameNumber = m_fromFrame->text().toInt(); int lastFrameNumber = m_toFrame->text().toInt(); @@ -1270,13 +1278,26 @@ void LoadLevelPopup::updateBottomGUI() { firstFrame = fIds[0]; lastFrame = fIds[fIds.size() - 1]; } else { - TLevelReaderP lr(fp); - TLevelP level; - if (lr) level = lr->loadInfo(); - if (!level.getPointer() || level->getTable()->size() == 0) return; + try { + TLevelReaderP lr(fp); + TLevelP level; + if (lr) level = lr->loadInfo(); + if (!level.getPointer() || level->getTable()->size() == 0) return; - firstFrame = level->begin()->first; - lastFrame = (--level->end())->first; + firstFrame = level->begin()->first; + lastFrame = (--level->end())->first; + } catch (...) { + m_fromFrame->setText(""); + m_toFrame->setText(""); + m_subsequenceFrame->setEnabled(false); + + m_xFrom->setText(""); + m_xTo->setText(""); + m_levelName->setText(""); + m_posTo->setText(""); + m_arrangementFrame->setEnabled(false); + return; + } } m_fromFrame->setText(QString().number(firstFrame.getNumber())); @@ -1779,14 +1800,17 @@ void LoadColorModelPopup::onFilePathsSelected( if (paths.size() == 1) { // Initialize the line with the level's starting frame const TFilePath &fp = *paths.begin(); + try { + TLevelReaderP lr(fp); + TLevelP level; + if (lr) level = lr->loadInfo(); - TLevelReaderP lr(fp); - TLevelP level; - if (lr) level = lr->loadInfo(); - - if (level.getPointer() && level->begin() != level->end()) { - int firstFrame = level->begin()->first.getNumber(); - if (firstFrame > 0) m_paletteFrame->setText(QString::number(firstFrame)); + if (level.getPointer() && level->begin() != level->end()) { + int firstFrame = level->begin()->first.getNumber(); + if (firstFrame > 0) + m_paletteFrame->setText(QString::number(firstFrame)); + } + } catch (...) { } } }