![]() |
#46 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,602
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
If it is the latter, then clearly the non-native dialog has some sort of extra guardrails that the native dialogs lacks to prevent bad data from being passed on. Last edited by DiapDealer; 06-07-2025 at 06:24 AM. |
|
![]() |
![]() |
![]() |
#47 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,602
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I'm a little mistaken on those above details. Give me some time to debug properly.
|
![]() |
![]() |
![]() |
#48 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,602
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
OK. The getOpenFileNames dialog is not crashing on Windows. It's returning a value for the rest of BookBrowser::AddExisting() to continue processing. There merely seems to be some sort of built-in guardrail in the non-native dialog (and the native one on linux) that returns an empty value when an url is detected.
Quote:
Code:
Resource *resource = m_Book->GetFolderKeeper()->AddContentFileToFolder(filepath); Code:
Debug: Returned from getOpenFileNames QList("https://www.adfg.alaska.gov/static/fishing/images/sport/galleries/Sport_Fish.1.jpg") Debug: Last folder open = "C:/Program Files/Sigil/https:/www.adfg.alaska.gov/static/fishing/images/sport/galleries" Debug: File name portion = "Sport_Fish.1.jpg" Debug: Preparing to add new resource for: "https://www.adfg.alaska.gov/static/fishing/images/sport/galleries/Sport_Fish.1.jpg" Warning: Qt has caught an exception thrown from an event handler. Throwing exceptions from an event handler is not supported in Qt. You must not let any exception whatsoever propagate through Qt code. Warning: Release of profile requested but WebEnginePage still not deleted. Expect troubles ! Warning: Release of profile requested but WebEnginePage still not deleted. Expect troubles ! Warning: Release of profile requested but WebEnginePage still not deleted. Expect troubles ! Last edited by DiapDealer; 06-07-2025 at 09:04 AM. |
|
![]() |
![]() |
![]() |
#49 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,602
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Why ARE we being given a field to paste a value into on this dialog in the first place? Is there ever going to be a time when a user has an entire valid file path on the clipboard to paste in here and save time browsing to images (or other files) they want to add to the epub?
I've already checked and there doesn't seem to be an option to hide such a field, so my question is pretty pointless, but still... Line 798 of BookBrowser.cpp is producing a wildly invalid file path that might be an obvious spot to head things off: Code:
m_LastFolderOpen = QFileInfo(filepaths.first()).absolutePath(); Code:
C:/Program Files/Sigil/https:/www.adfg.alaska.gov/static/fishing/images/sport/galleries Last edited by DiapDealer; 06-07-2025 at 09:10 AM. |
![]() |
![]() |
![]() |
#50 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,803
Karma: 6000000
Join Date: Nov 2009
Device: many
|
That is interesting ... great detective work! So the more correct approach is probably to detect urls being returned on all platforms. Given a colon is not an allowed in a file path in MacOS it would be easy to screen it out on MacOS. But given Windows filepaths use colons after drive letters, and custom url schemes are legal (calibre, sigil, http, https, ftp, file, etc, etc, then a simple screen would probably not be easy. Maybe as BeckyEbook suggested we use Utility::IsFileReadable and see if that returns without crashing, but it may use QFileInfo too.
Which way do you want to go? |
![]() |
![]() |
![]() |
#51 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,602
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I would think there's never going to be a network protocol in the middle of a valid local file path on any platform is there? http:/|https:/|ftp:/, etc...
C:/Program Files/Sigil/https:/www.adfg.alaska.gov/static/fishing/images/sport/galleries Wouldn't some sort of if path exists suffice? Let me dig a little deeper into where the crash is happening in Book.cpp m_Book->GetFolderKeeper()->AddContentFileToFolder(filepath) Last edited by DiapDealer; 06-07-2025 at 09:28 AM. |
![]() |
![]() |
![]() |
#52 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,803
Karma: 6000000
Join Date: Nov 2009
Device: many
|
I do think we do want to screen it immediately after the getOpenFileNames call returns and set it to be a null string if any type of url is returned just like the non-native ones do now.
That prevents any rippling effects downstream. |
![]() |
![]() |
![]() |
#53 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,602
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
That makes sense to me. Let me ask this: is there ever going to be any circumstance where a path manually entered (either by pasting or typing) into that getOpenFileNames dialog (Add Existing files to epub) might make use of any url whatsoever?
I'm asking in case simply trying to define the returned QString (or in this case loop through all QStrings in the returned QList) as a QUrl and then using QUrl::isValid() to test might be enough? |
![]() |
![]() |
![]() |
#54 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,803
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Well the KDE Plasma file dialog only ruled out non-file scheme urls so it might let a file: url pass through.
Sigil code was generally not designed to accept a url from open file dialogs. It wants file paths or in this case a list of paths not a list of urls. So I say we just check if url of any type (but be careful of relative urls) and punt if so. So maybe a simple file existance or is readable test here is the safest approach. Last edited by KevinH; 06-07-2025 at 10:12 AM. |
![]() |
![]() |
![]() |
#55 |
Connoisseur
![]() Posts: 71
Karma: 46
Join Date: Mar 2017
Device: None
|
Deleted
Last edited by mrprobert; 06-09-2025 at 05:08 PM. |
![]() |
![]() |
![]() |
#56 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,602
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
I can easily warn the user with a utility dialog warning about not entering urls, but I'd like to try and find out what is happening that takes so much processing time before the url-checking routine even takes over. Very weird. Last edited by DiapDealer; 06-07-2025 at 10:49 AM. |
|
![]() |
![]() |
![]() |
#57 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,803
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Yes sounds like a plan. But either way we may be safer if a non-native file dialog box is used. But I would still add in a isFileReadable check for all platforms to be even safer
Last edited by KevinH; 06-07-2025 at 12:46 PM. |
![]() |
![]() |
![]() |
#58 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,803
Karma: 6000000
Join Date: Nov 2009
Device: many
|
What is really strange is that QFileDialog getOpenFileName() and getOpenFileNames() should never return a url as there exists getOpenFileUrl() and getOpenFileUrls() in that same QFileDialog class.
My guess is much of the code is shared but that the Name and Names should actively screen out Urls! So as far as I can tell, this is a Qt bug. We will just have to guard against it. Last edited by KevinH; 06-07-2025 at 01:43 PM. |
![]() |
![]() |
![]() |
#59 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,602
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Yes. I think the non-native dialog just handles this situation better on Windows. It works quicker, and automatically notifies the user that there's a problem. And an isFileReadable check for all platforms for safety makes sense.
|
![]() |
![]() |
![]() |
#60 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,803
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Quote:
Either way, we have time as we merged in new strings, so after your change I will update base.ts and we can let the translators get started on them while we wait in case other bugs are reported. And no need to rush out a 2.5.3 since this is not a usual crash, but requires copying and pasting in a url by the user when asked for a file path. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
error from Sigil when loading particular epub file | JohnNC | Sigil | 15 | 08-08-2017 04:52 AM |
Sigil crashes when trying to add existing file | holdit | Sigil | 18 | 07-16-2013 06:59 AM |
Sigil Crashes on Win7 v0.6.2 When loading image | lissie | Sigil | 7 | 01-24-2013 05:05 AM |
Sigil file crashes Sony software | Quiss | Sigil | 12 | 08-14-2012 08:04 PM |