View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0017508 | Scribus | Build System | public | 2025-04-28 06:44 | 2025-05-12 15:52 |
Reporter | landry | Assigned To | jghali | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 1.7.0 | ||||
Fixed in Version | 1.7.1.svn | ||||
Summary | 0017508: building on OpenBSD/i386/32-bits fails because "call to 'toPdf' is ambiguous" | ||||
Description | cf https://github.com/scribusproject/scribus/issues/196 the patch just ensures the right `toPdf` variant exists on OpenBSD: -#if !defined(Q_OS_WIN) && (Q_PROCESSOR_WORDSIZE != 4) +#if (!defined(Q_OS_WIN) && (Q_PROCESSOR_WORDSIZE != 4)) || defined(__OpenBSD__) | ||||
Additional Information | currently rebuilding with the attached patch, my initial patch dropped the #if and works on amd64 and i386 | ||||
Tags | No tags attached. | ||||
Patch | Yes | ||||
|
patch-scribus_pdfwriter_h (402 bytes)
fix build on i386 https://github.com/scribusproject/scribus/issues/196 Index: scribus/pdfwriter.h --- scribus/pdfwriter.h.orig +++ scribus/pdfwriter.h @@ -83,7 +83,7 @@ namespace Pdf /** Cf. PDF32000-2008, 7.3.3 */ -#if !defined(Q_OS_WIN) && (Q_PROCESSOR_WORDSIZE != 4) +#if (!defined(Q_OS_WIN) && (Q_PROCESSOR_WORDSIZE != 4)) || defined(__OpenBSD__) QByteArray toPdf(size_t v); #endif |
|
are you sure that openbsd cannot be 64 bits? |
|
OpenBSD/amd64 is 64 bits, OpenBSD/i386 is 32 bits. The initial patch i tested/commited to our portstree in https://github.com/openbsd/ports/commit/abce6c2658f35d2049375a3b6543072997b18cdc is just removing completely the #if/#endif, so defining QByteArray toPdf(size_t v) in all cases, that fixed the build on OpenBSD/i386, and still built on OpenBSD/amd64. and now that i've said that and relooked at my commit, i realize that the same change needs to be applied to scribus/pdfwriter.cpp and scribus/scxmlstreamwriter.h |
|
@landry, I think I have another solution based on C++ templates which remove the ifdefs for all platform. Could you try the attached patch and see if that works for you ? 17508_building_openbsd_fails.patch (4,813 bytes)
Index: scribus/pdfwriter.cpp =================================================================== --- scribus/pdfwriter.cpp (révision 26852) +++ scribus/pdfwriter.cpp (copie de travail) @@ -304,49 +304,11 @@ return result; } - QByteArray toPdf(bool v) - { - return v? "true" : "false"; - } - - QByteArray toPdf(int v) - { - return QByteArray::number(v); - } - - QByteArray toPdf(uint v) - { - return QByteArray::number(v); - } - - QByteArray toPdf(qlonglong v) - { - return QByteArray::number(v); - } - - QByteArray toPdf(qulonglong v) - { - return QByteArray::number(v); - } - -#if !defined(Q_OS_WIN) && (Q_PROCESSOR_WORDSIZE != 4) - QByteArray toPdf(size_t v) - { - return QByteArray::number(v); - } -#endif - - QByteArray toPdf(double v) - { - return QByteArray::number(v, 'f'); - } - QByteArray toObjRef(PdfId id) { return toPdf(id) + " 0 R"; } - QByteArray toLiteralString(const QString& s) { return toLiteralString(toPdfDocEncoding(s)); Index: scribus/pdfwriter.h =================================================================== --- scribus/pdfwriter.h (révision 26852) +++ scribus/pdfwriter.h (copie de travail) @@ -9,6 +9,8 @@ #ifndef Scribus_pdfwriter_h #define Scribus_pdfwriter_h +#include <type_traits> + #include <QByteArray> #include <QDataStream> #include <QFile> @@ -58,43 +60,33 @@ /** Cf. PDF32000-2008, 7.3.2 */ - QByteArray toPdf(bool v); - - /** - Cf. PDF32000-2008, 7.3.3 - */ - QByteArray toPdf(int v); - - /** - Cf. PDF32000-2008, 7.3.3 - */ - QByteArray toPdf(uint v); + template <typename T, std::enable_if_t<std::is_integral_v<T> || std::is_enum_v<T>, bool> = true> + inline QByteArray toPdf(T v) + { + return QByteArray::number(v); + } /** Cf. PDF32000-2008, 7.3.3 */ - QByteArray toPdf(qlonglong v); + template <typename T, std::enable_if_t< std::is_floating_point_v<T>, bool> = true> + inline QByteArray toPdf(T v) + { + return QByteArray::number(v, 'f'); + } /** - Cf. PDF32000-2008, 7.3.3 + Cf. PDF32000-2008, 7.3.2 */ - QByteArray toPdf(qulonglong v); + template <> + inline QByteArray toPdf<bool>(bool v) + { + return v ? "true" : "false"; + } /** Cf. PDF32000-2008, 7.3.3 */ -#if !defined(Q_OS_WIN) && (Q_PROCESSOR_WORDSIZE != 4) - QByteArray toPdf(size_t v); -#endif - - /** - Cf. PDF32000-2008, 7.3.3 - */ - QByteArray toPdf(double v); - - /** - Cf. PDF32000-2008, 7.3.3 - */ QByteArray toObjRef(PdfId id); /** Index: scribus/scxmlstreamwriter.h =================================================================== --- scribus/scxmlstreamwriter.h (révision 26852) +++ scribus/scxmlstreamwriter.h (copie de travail) @@ -7,12 +7,15 @@ #ifndef SCXMLSTREAMWRITER_H #define SCXMLSTREAMWRITER_H -#include "scribusapi.h" +#include <type_traits> #include <QByteArray> #include <QString> #include <QXmlStreamWriter> +#include "pdfversion.h" +#include "scribusapi.h" + class SCRIBUS_API ScXmlStreamWriter : public QXmlStreamWriter { public: @@ -21,15 +24,14 @@ ScXmlStreamWriter(QIODevice* device) : QXmlStreamWriter(device) {} ScXmlStreamWriter(QString* string) : QXmlStreamWriter(string) {} - void writeAttribute(const QString & name, const QString & value) { QXmlStreamWriter::writeAttribute(name, value); } - void writeAttribute(const QString & name, int value) { QXmlStreamWriter::writeAttribute(name, QString::number(value)); } - void writeAttribute(const QString & name, qint64 value) { QXmlStreamWriter::writeAttribute(name, QString::number(value)); } - void writeAttribute(const QString & name, uint value) { QXmlStreamWriter::writeAttribute(name, QString::number(value)); } - void writeAttribute(const QString & name, quint64 value) { QXmlStreamWriter::writeAttribute(name, QString::number(value)); } -#if !defined(Q_OS_WIN) && (Q_PROCESSOR_WORDSIZE != 4) - void writeAttribute(const QString & name, size_t value) { QXmlStreamWriter::writeAttribute(name, QString::number(value)); } -#endif - void writeAttribute(const QString & name, double value) { QXmlStreamWriter::writeAttribute(name, QString::number(value, 'g', 15)); } + void writeAttribute(const QString& name, const QString& value) { QXmlStreamWriter::writeAttribute(name, value); } + void writeAttribute(const QString& name, const PDFVersion& value) { QXmlStreamWriter::writeAttribute(name, QString::number(value)); } + + template<typename T, std::enable_if_t<std::is_integral_v<T> || std::is_enum_v<T>, bool> = true> + void writeAttribute(const QString & name, T value) { QXmlStreamWriter::writeAttribute(name, QString::number(value)); } + + template<typename T, std::enable_if_t< std::is_floating_point_v<T>, bool> = true> + void writeAttribute(const QString & name, T value) { QXmlStreamWriter::writeAttribute(name, QString::number(value, 'g', 15)); } }; #endif |
|
@jghali, sorry it seems i didnt get a notification from mantis for your last comment last week, only got one yesterday when the issue has been marked resolved, but i can confirm that your patch builds fine here, both on i386 & amd64. i havent been able to figure out where that got commited, nor in https://github.com/scribusproject/scribus/commits/master or the various subprojects on sourceforge, nor in https://wiki.scribus.net/canvas/Checking_out_SVN so that i could properly link to the right upstream svn commit in the patch im going to 'fix' in our ports-tree. But maybe the svn-to-github conversion script only runs every some days. anyway, thanks for looking into it and coming with a better/proper fix ! |
|
hi landry i've updated the github mirror: https://github.com/scribusproject/scribus/commit/d54ec09f5599693dae5bbd6a5213703f7b8ad7b9 just be advised, that it's not an official source for scribus. if you need the number of the official commit, you will need to checkout the svn repository you see linked in the wiki. (from the information I see in the git "mirror", it should be 26861) |
Date Modified | Username | Field | Change |
---|---|---|---|
2025-04-28 06:44 | landry | New Issue | |
2025-04-28 06:44 | landry | File Added: patch-scribus_pdfwriter_h | |
2025-04-28 16:03 | ale | Note Added: 0052482 | |
2025-04-29 06:39 | landry | Note Added: 0052484 | |
2025-05-03 13:51 | jghali | Note Added: 0052491 | |
2025-05-03 13:51 | jghali | File Added: 17508_building_openbsd_fails.patch | |
2025-05-11 12:52 | jghali | Assigned To | => jghali |
2025-05-11 12:52 | jghali | Status | new => resolved |
2025-05-11 12:52 | jghali | Resolution | open => fixed |
2025-05-11 12:52 | jghali | Fixed in Version | => 1.7.1.svn |
2025-05-12 06:22 | landry | Note Added: 0052512 | |
2025-05-12 15:52 | ale | Note Added: 0052513 |