Bug 79874 - Compilation of Qt5 frontend fails with MinGW
Summary: Compilation of Qt5 frontend fails with MinGW
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: qt frontend (show other bugs)
Version: unspecified
Hardware: Other other
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
: 80251 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-06-10 10:40 UTC by Aki Koskinen
Modified: 2014-07-10 22:31 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Proposed patch for the problem (489 bytes, patch)
2014-06-10 10:40 UTC, Aki Koskinen
Details | Splinter Review
Proposed patch for the problem, no copying anymore (757 bytes, patch)
2014-06-18 07:13 UTC, Aki Koskinen
Details | Splinter Review

Description Aki Koskinen 2014-06-10 10:40:17 UTC
Created attachment 100797 [details] [review]
Proposed patch for the problem

When trying to cross-compile Poppler with MinGW the compilation fails because of an error in the Qt5 frontend. The error is:

qt5/src/poppler-private.h:91:21: error: 'std::wstring' has no member named '_Copy_s'
   int length = wstr._Copy_s(fileName, filePath.length(), filePath.length());

That's caused because of usage of Microsoft specific API.

A proposed patch is attached.
Comment 1 Albert Astals Cid 2014-06-12 22:04:40 UTC
hmmmm, i'm unconvinced by the patch, can poppler compiled that way still open files with non-ascii characters?
Comment 2 Aki Koskinen 2014-06-13 06:44:28 UTC
(In reply to comment #1)
> hmmmm, i'm unconvinced by the patch, can poppler compiled that way still
> open files with non-ascii characters?

I'm not sure. It's completely OK to discard the proposed patch.

Another way (possibly better) would be to replace the non-standard _Copy_s with something standard, like copy. The additional bounds checking provided by _Copy_s doesn't seem to bring any benefit since we already know that fileName is large enough (since we just constructed it).

Or then not copy at all - I don't quite get why the copying is needed in the first place. Would something like this do the job (note: untested code):

doc = new PDFDoc((const wchar_t *)filePath.utf16(), filePath.length(), ownerPassword, userPassword);
Comment 3 Albert Astals Cid 2014-06-13 06:56:17 UTC
You are the one with a windows machine, not me, so you tell me :)
Comment 4 Aki Koskinen 2014-06-13 08:17:19 UTC
(In reply to comment #3)
> You are the one with a windows machine, not me, so you tell me :)

Actually I'm not, I'm compiling for Windows using MinGW on Linux :)

But I do have access to a Windows machine, so I'll try it.
Comment 5 Aki Koskinen 2014-06-18 07:12:04 UTC
All right, got access to that Windows machine. I tried the last idea I presented, not making any copy at all. I renamed a .pdf file to contain some non-ascii characters and tried if it can still be rendered. Seemed to work fine.

I'll attach a new proposed patch that shows the version of the code I used.
Comment 6 Aki Koskinen 2014-06-18 07:13:49 UTC
Created attachment 101282 [details] [review]
Proposed patch for the problem, no copying anymore

New proposed fix. No copy of the string is made any more.
Comment 7 Hib Eris 2014-06-19 20:48:26 UTC
Comment on attachment 101282 [details] [review]
Proposed patch for the problem, no copying anymore

Review of attachment 101282 [details] [review]:
-----------------------------------------------------------------

::: qt5/src/poppler-private.h
@@ +86,4 @@
>  		m_filePath = filePath;	
>  
>  #ifdef _WIN32
> +		doc = new PDFDoc((wchar_t *)filePath.utf16(), filePath.length(), ownerPassword, userPassword);

I think that filePath.length() might not match the number of wchar's in filePath.utf16().
Comment 8 Hib Eris 2014-06-19 20:51:38 UTC
For reference, an alternative patch is in bug 80251
Comment 9 Hib Eris 2014-06-20 21:42:25 UTC
(In reply to comment #7)

> >  #ifdef _WIN32
> > +		doc = new PDFDoc((wchar_t *)filePath.utf16(), filePath.length(), ownerPassword, userPassword);
> 
> I think that filePath.length() might not match the number of wchar's in
> filePath.utf16().

Hmm, on second thought, I was wrong in this remark; using QString.length() will work fine to get the number of wchar_t returned by QString.utf16().

Thus the proposed patch looks good to me.
Comment 10 Aki Koskinen 2014-06-30 14:22:46 UTC
Any info if this will get fixed any time soon? There's some patches already proposed that AFAIK could just be applied as is. If I'm mistaken then please tell me what I could do next.
Comment 11 Albert Astals Cid 2014-06-30 21:18:47 UTC
People is busy and on holidays.
Comment 12 Aki Koskinen 2014-07-01 06:58:21 UTC
That's good. Have good holidays :)
Comment 13 Albert Astals Cid 2014-07-10 22:29:21 UTC
*** Bug 80251 has been marked as a duplicate of this bug. ***
Comment 14 Albert Astals Cid 2014-07-10 22:31:34 UTC
Pushed, thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.