Coder Social home page Coder Social logo

Comments (7)

tsujan avatar tsujan commented on July 18, 2024

Confirmed:

#0  0x00007fecfa738dbe in QImage::QImage(QImage const&) () at /usr/lib/libQt5Gui.so.5
#1  0x000000000041b921 in  ()
#2  0x00007fecfa1bae72 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#3  0x00007fecfaef7473 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#4  0x00007fecfafe8b7b in QMainWindow::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#5  0x00007fecfaeb646c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/lib/libQt5Widgets.so.5
#6  0x00007fecfaebdcf4 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#7  0x00007fecfa18bb98 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    at /usr/lib/libQt5Core.so.5
#8  0x00007fecfa18e02d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
    at /usr/lib/libQt5Core.so.5
#9  0x00007fecfa1e3a63 in  () at /usr/lib/libQt5Core.so.5
#10 0x00007fecfb5fba47 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#11 0x00007fecfb5fbc78 in  () at /usr/lib/libglib-2.0.so.0
#12 0x00007fecfb5fbd0c in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#13 0x00007fecfa1e3e7f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/libQt5Core.so.5
#14 0x00007fecfa18a21a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/libQt5Core.so.5
#15 0x00007fecfa192a74 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#16 0x0000000000412761 in  ()
#17 0x00007fecfd2ad43a in __libc_start_main () at /usr/lib/libc.so.6
#18 0x0000000000412c7a in _start ()

At first, I though it might be related to Qt 5.9 but the Qt image viewer I've made for my personal use doesn't show this symptom.

from lximage-qt.

fulalas avatar fulalas commented on July 18, 2024

You're right, it's not a Qt 5.9.0 bug since I can reproduce this on Qt 5.8.0 too. Can be a Qt 5.x.x bug though :D

from lximage-qt.

tsujan avatar tsujan commented on July 18, 2024

Can be a Qt 5.x.x bug though

No, the bug is lximage-qt. I'll look into it whenever I find some free time.

from lximage-qt.

npmiller avatar npmiller commented on July 18, 2024

This is a race condition accessing the loadJob_ member of MainWindow, between loadImage (main thread) and onImageLoaded (job thread). The crash is because the when the job emits finished at a point after the main thread set loadJob_ to nullptr.

Disconnecting the finished signal from the job before cancelling it makes the issue a bit harder to hit but it's not a proper fix:

diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 16191d9..f6e7c6f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -583,7 +584,9 @@ void MainWindow::updateUI() {
 void MainWindow::loadImage(const Fm::FilePath & filePath, QModelIndex index) {
   // cancel loading of current image
   if(loadJob_) {
+    disconnect(loadJob_, &Fm::Job::finished, this, &MainWindow::onImageLoaded);
     loadJob_->cancel(); // the job object will be freed automatically later
     loadJob_ = nullptr;
   }
   if(imageModified_) {

Maybe loadJob_ could be guarded by a mutex, but maybe there's a nicer way to do it, before, onImageLoaded took a pointer to the job thus avoiding that issue, using QObject::sender could do the trick.

from lximage-qt.

palinek avatar palinek commented on July 18, 2024

@npmiller Great analysis... in #95 I've made something rather similar as your suggestion.

from lximage-qt.

fulalas avatar fulalas commented on July 18, 2024

I can confirm that the new patch fixed it. I'm closing this issue.

Thanks, @npmiller and @palinek!

from lximage-qt.

palinek avatar palinek commented on July 18, 2024

reopening... as the solution wasn't approved and merged into master yet

from lximage-qt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.