Changeset View
Changeset View
Standalone View
Standalone View
src/part/loadagraphthread.cpp
Show All 19 Lines | |||||
20 | #include "loadagraphthread.h" | 20 | #include "loadagraphthread.h" | ||
21 | #include "kgraphviewerlib_debug.h" | 21 | #include "kgraphviewerlib_debug.h" | ||
22 | 22 | | |||
23 | #include <QDebug> | 23 | #include <QDebug> | ||
24 | 24 | | |||
25 | void LoadAGraphThread::run() | 25 | void LoadAGraphThread::run() | ||
26 | { | 26 | { | ||
27 | qCDebug(KGRAPHVIEWERLIB_LOG) << m_dotFileName; | 27 | qCDebug(KGRAPHVIEWERLIB_LOG) << m_dotFileName; | ||
28 | FILE* fp = fopen(m_dotFileName.toUtf8().data(), "r"); | 28 | FILE *fp = fopen(m_dotFileName.toUtf8().data(), "r"); | ||
29 | if (!fp) | 29 | if (!fp) { | ||
30 | { | | |||
31 | qCWarning(KGRAPHVIEWERLIB_LOG) << "Failed to open file " << m_dotFileName; | 30 | qCWarning(KGRAPHVIEWERLIB_LOG) << "Failed to open file " << m_dotFileName; | ||
32 | return; | 31 | return; | ||
33 | } | 32 | } | ||
34 | m_g = agread(fp, nullptr); | 33 | m_g = agread(fp, nullptr); | ||
35 | if (!m_g) | 34 | if (!m_g) { | ||
36 | { | | |||
37 | qCWarning(KGRAPHVIEWERLIB_LOG) << "Failed to read file, retrying to work around graphviz bug(?)"; | 35 | qCWarning(KGRAPHVIEWERLIB_LOG) << "Failed to read file, retrying to work around graphviz bug(?)"; | ||
38 | rewind(fp); | 36 | rewind(fp); | ||
39 | m_g = agread(fp, nullptr); | 37 | m_g = agread(fp, nullptr); | ||
40 | } | 38 | } | ||
41 | if (m_g == nullptr) | 39 | if (m_g == nullptr) { | ||
42 | { | | |||
43 | qCWarning(KGRAPHVIEWERLIB_LOG) << "Failed to read file " << m_dotFileName; | 40 | qCWarning(KGRAPHVIEWERLIB_LOG) << "Failed to read file " << m_dotFileName; | ||
44 | } | 41 | } | ||
45 | fclose(fp); | 42 | fclose(fp); | ||
46 | } | 43 | } | ||
47 | 44 | | |||
48 | void LoadAGraphThread::loadFile(const QString& dotFileName) | 45 | void LoadAGraphThread::loadFile(const QString &dotFileName) | ||
49 | { | 46 | { | ||
50 | // FIXME: deadlock possible | 47 | // FIXME: deadlock possible | ||
51 | // if thread is still running or queued finished signal of the thread has not | 48 | // if thread is still running or queued finished signal of the thread has not | ||
52 | // yet been delivered so its handler who would release the semaphore, | 49 | // yet been delivered so its handler who would release the semaphore, | ||
53 | // then the semaphore can not be acquired and this will block the (main) thread | 50 | // then the semaphore can not be acquired and this will block the (main) thread | ||
54 | // which called LoadAGraphThread::loadFile(). | 51 | // which called LoadAGraphThread::loadFile(). | ||
55 | // That one though very much might have also been the one which before invoked this | 52 | // That one though very much might have also been the one which before invoked this | ||
56 | // method and thus the still running thread or yet-to-be delivered finished signal. | 53 | // method and thus the still running thread or yet-to-be delivered finished signal. | ||
Show All 9 Lines |