forked from scantailor/scantailor
-
Notifications
You must be signed in to change notification settings - Fork 8
Avoid segfault on loading images #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hurzl
wants to merge
1
commit into
Tulon:experimental
Choose a base branch
from
hurzl:experimental
base: experimental
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where exactly does it crash?
It shouldn't be crashing in dynamic_cast, as dynamic_cast()ing a null pointer is legal:
http://stackoverflow.com/questions/5155820/portably-safe-to-pass-null-zero-to-dynamic-cast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I know is that it crashed in this line (after opening a directory for loading images) and my fix fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it's when I close the project data dialog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, as with my "fix" the dynamic_cast is called only if m_pThumb is NOT NULL
.. I mean when it IS NULL .. I'm completely confused ..
It crashes when m_pThumb is NOT NULL
If I just "return !m_pThumb;" it seems to work, too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if Qt was built with a different compiler or with flags that change vtable format.
Is Scan Tailor from ports affected? If not, check what kind of flags or patches they are applying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, you could just let FreeBSD scantailor maintainer deal with this problem, given that it's a FreeBSD-specific one. The code in question didn't change for a long time.
I would be extremely surprised if the problem turns out to be related to the use of std::auto_ptr. You are free to pursue this course, but it looks like you need to read some articles on auto_ptr and unique_ptr first. I don't really have time to explain every detail, while you can easily find this information on the web.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found out, but seems to work when I cast piecewise like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. So it doesn't crash anymore but is it working correctly? Does it ever return true?
BTW, incomplete thumbnails are those with question marks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it returns 0s and 1s and runs correctly, yes
Hmm now in the master branch I get the next dynamic_cast problem in PixmapRenderer.cpp:70
(this code is gone with the Qt5 version)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like something is broken with FreeBSD. Maybe a better idea would be creating a small example reproducing the problem and let FreeBSD developers deal with it.
As for double-casting to IncompleteThumbnail, I would prefer a cleaner solution:
Make ThumbnailFactory return ThumbnailBase rather than QGraphicsItem and add a virtual isIncomplete() method to ThumbnailBase and IncompleteThumbnail.