Commit 8150619d authored by Michael Winkelmann's avatar Michael Winkelmann

Error output when there is no item

parent 4d9ddcfb
......@@ -56,13 +56,21 @@ int main(int ac, char *av[]) {
view->engine()->addImportPath(path);
view->setSource(QUrl::fromLocalFile(inputQml));
view->setGeometry(0,0, view->rootObject()->width(), view->rootObject()->height());
auto item = view->rootObject();
if (!item) {
qInfo() << QObject::tr("No item in QML, no PDF output was produced!");
return EXIT_SUCCESS;
}
view->setGeometry(0,0, int(item->width()), int(item->height()));
QTimer::singleShot(delay,[=]() {
QmlPrinter printer;
qInfo() << QObject::tr("Writing PDF to %1").arg(outputPdfDir.absolutePath());
if (!printer.printPdf(outputPdfDir.absolutePath(), view->rootObject())) {
if (!printer.printPdf(outputPdfDir.absolutePath(), item)) {
qInfo() << QObject::tr("No PDF output was produced!");
}
qGuiApp->quit();
......@@ -70,6 +78,5 @@ int main(int ac, char *av[]) {
QDesktopServices::openUrl(QUrl::fromLocalFile(outputPdfDir.absolutePath()));
});
return app.exec();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment