diff --git a/src/core/UBDocumentManager.cpp b/src/core/UBDocumentManager.cpp index 17c2c9f5..cedc1bef 100644 --- a/src/core/UBDocumentManager.cpp +++ b/src/core/UBDocumentManager.cpp @@ -150,7 +150,7 @@ UBDocumentProxy* UBDocumentManager::importFile(const QFile& pFile, const QString // Document import procedure..... QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); - document = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); + document = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName,false); QUuid uuid = QUuid::createUuid(); QString filepath = pFile.fileName(); diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index ab267208..a97cc87e 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -264,7 +264,10 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, doc->setMetaData(UBSettings::documentUpdatedAt,currentDate); doc->setMetaData(UBSettings::documentDate,currentDate); - if (withEmptyPage) createDocumentSceneAt(doc, 0); + if (withEmptyPage) + createDocumentSceneAt(doc, 0); + else + generatePathIfNeeded(doc); documentProxies.insert(0, QPointer(doc)); @@ -887,16 +890,13 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy, if (data == NULL && !fi.exists()) return false; - qDebug() << fi.suffix(); - QString fileName = subdir + "/" + objectUuid.toString() + "." + fi.suffix(); - destinationPath = pDocumentProxy->persistencePath() + "/" + fileName; if (!QFile::exists(destinationPath)) { QDir dir; - dir.mkdir(pDocumentProxy->persistencePath() + "/" + subdir); + dir.mkpath(pDocumentProxy->persistencePath() + "/" + subdir); if (!QFile::exists(pDocumentProxy->persistencePath() + "/" + subdir)) return false; diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index a0fe8304..01b8d8ab 100644 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -1052,7 +1052,6 @@ bool UBDocumentController::addFileToDocument(UBDocumentProxy* document) if (filePath.length() > 0) { QApplication::processEvents(); // NOTE: We performed this just a few lines before. Is it really necessary to do it again here?? - QFile selectedFile(filePath); showMessage(tr("Importing file %1...").arg(fileInfo.baseName()), true); diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 4f489ad6..c586d37f 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -101,7 +101,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) { //claudio This is a very bad hack and shows a architectural problem // source->selectedDocument()->pageCount() != source->pageCount() - if(i>=source->pageCount()) + if(i>=source->pageCount() || source->pageAt(i)->isNull()) source->insertThumbPage(i); const QPixmap* pix = source->pageAt(i);