mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-04-10 09:40:41 +02:00
Fix: #159 Handle corrupted files
This commit is contained in:
@@ -753,7 +753,7 @@ void MainWindow::renameMappingItem()
|
||||
contentTab->setCurrentWidget(mappingSplitter);
|
||||
}
|
||||
|
||||
void MainWindow::renameMapping(uid mappingId, QString name)
|
||||
void MainWindow::renameMapping(uid mappingId, const QString &name)
|
||||
{
|
||||
Mapping::ptr mapping = mappingManager->getMappingById(mappingId);
|
||||
if (!mapping.isNull()) {
|
||||
@@ -791,7 +791,7 @@ void MainWindow::renamePaintItem()
|
||||
contentTab->setCurrentWidget(paintSplitter);
|
||||
}
|
||||
|
||||
void MainWindow::renamePaint(uid paintId, QString name)
|
||||
void MainWindow::renamePaint(uid paintId, const QString &name)
|
||||
{
|
||||
Paint::ptr paint = mappingManager->getPaintById(paintId);
|
||||
if (!paint.isNull()) {
|
||||
@@ -2045,6 +2045,9 @@ bool MainWindow::importMediaFile(const QString &fileName, bool isImage)
|
||||
QFile file(fileName);
|
||||
QDir currentDir;
|
||||
|
||||
if (!fileSupported(fileName, isImage))
|
||||
return false;
|
||||
|
||||
bool live = false;
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
if (file.isSequential())
|
||||
@@ -2357,7 +2360,7 @@ void MainWindow::clearWindow()
|
||||
clearProject();
|
||||
}
|
||||
|
||||
bool MainWindow::fileExists(const QString file)
|
||||
bool MainWindow::fileExists(const QString &file)
|
||||
{
|
||||
QFileInfo checkFile(file);
|
||||
|
||||
@@ -2367,6 +2370,25 @@ bool MainWindow::fileExists(const QString file)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainWindow::fileSupported(const QString &file, bool isImage)
|
||||
{
|
||||
QFileInfo fileInfo(file);
|
||||
QString fileExtension = fileInfo.suffix();
|
||||
|
||||
if (isImage) {
|
||||
if (MM::IMAGE_FILES_FILTER.contains(fileExtension, Qt::CaseInsensitive))
|
||||
return true;
|
||||
} else {
|
||||
if (MM::VIDEO_FILES_FILTER.contains(fileExtension, Qt::CaseInsensitive))
|
||||
return true;
|
||||
}
|
||||
|
||||
QMessageBox::warning(this, tr("Warning"),
|
||||
tr("The following file is not supported: %1")
|
||||
.arg(fileInfo.fileName()));
|
||||
return false;
|
||||
}
|
||||
|
||||
QString MainWindow::locateMediaFile(const QString &uri, bool isImage)
|
||||
{
|
||||
// Get more info about url
|
||||
|
||||
Reference in New Issue
Block a user