diff --git a/libs/main/KoApplication.cpp b/libs/main/KoApplication.cpp --- a/libs/main/KoApplication.cpp +++ b/libs/main/KoApplication.cpp @@ -581,7 +581,9 @@ return true; // only load one document! } else if (print) { - mainWindow->slotFilePrint(); + connect( + mainWindow, SIGNAL(loadCompleted()), + mainWindow, SLOT(slotFilePrint())); // delete mainWindow; done by ~KoDocument nPrinted++; } else if (exportAsPdf) { diff --git a/libs/main/KoMainWindow.cpp b/libs/main/KoMainWindow.cpp --- a/libs/main/KoMainWindow.cpp +++ b/libs/main/KoMainWindow.cpp @@ -774,31 +774,33 @@ if (!file.isWritable()) { setReadWrite(false); } + return true; } // Separate from openDocument to handle async loading (remote URLs) void KoMainWindow::slotLoadCompleted() { debugMain << "KoMainWindow::slotLoadCompleted"; KoDocument *newdoc = qobject_cast(sender()); - KoPart *newpart = newdoc->documentPart(); - + KoPart *newpart = newdoc->documentPart(); + if (d->rootDocument && d->rootDocument->isEmpty()) { // Replace current empty document setRootDocument(newdoc); } else if (d->rootDocument && !d->rootDocument->isEmpty()) { // Open in a new main window // (Note : could create the main window first and the doc next for this // particular case, that would give a better user feedback...) KoMainWindow *s = newpart->createMainWindow(); - s->show(); + s->show(); newpart->removeMainWindow(this); s->setRootDocument(newdoc, newpart); } else { // We had no document, set the new one setRootDocument(newdoc); } + slotProgress(-1); disconnect(newdoc, SIGNAL(sigProgress(int)), this, SLOT(slotProgress(int))); disconnect(newdoc, SIGNAL(completed()), this, SLOT(slotLoadCompleted())); @@ -1397,9 +1399,9 @@ void KoMainWindow::slotFilePrint() { - if (!rootView()) - return; - KoPrintJob *printJob = rootView()->createPrintJob(); + if (!rootView()) + return; + KoPrintJob *printJob = rootView()->createPrintJob(); if (printJob == 0) return; d->applyDefaultSettings(printJob->printer());