Fix deadlock on quickly repeated call of KGraphViewerPart::openFile()
ClosedPublic

Authored by kossebau on Aug 15 2017, 3:00 PM.

Details

Summary

If layoutmethod was set to InternalLibrary, then
KGraphViewerPart::openFile() called the async loading method
DotGraphView::loadLibrary(), which defers loading to a LoadAGraphThread.
This one is guarded with a QSemaphore, which is acquired on starting
the thread and only released via the connected-by-event-queue
finished signal of the thread.
So calling KGraphViewerPart::openFile() again while the thread is
still running or the finished signal not yet delivered will result
in a deadlock.

Also does KParts expect reimplementations of ReadOnlyPart::openFile()
to do the loading synchronously and to report the success of completed
loading via the return value, which was not fulfilled by
KGraphViewerPart::openFile().

This patch solves this in a first step by a new method
DotGraphView::loadLibrarySync() and KGraphViewerPart::openFile() using
this one instead. The deadlock issue is only noted with a FIXME,
needs some bigger refactoring possibly.

Test Plan

KGraphViewer app still works as before.
Software using kgraphviewerpart and sometimes issuing unsquashed
calls to load another file do no longer freeze.

Diff Detail

Repository
R491 KGraphViewer
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Aug 15 2017, 3:00 PM
kleag accepted this revision.Aug 22 2017, 1:13 PM

Ship it!

This revision is now accepted and ready to land.Aug 22 2017, 1:13 PM
This revision was automatically updated to reflect the committed changes.