Summary: | [PATCH] kghostview behaves erratically after opening a file -- sometimes shows blank pages | ||
---|---|---|---|
Product: | [Applications] okular | Reporter: | Andy Neitzke <neitzke> |
Component: | general | Assignee: | Okular developers <okular-devel> |
Status: | RESOLVED WORKSFORME | ||
Severity: | normal | CC: | adrian |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
test PS file which reliably exhibits this bug
workaround for problem with main viewer |
Description
Andy Neitzke
2004-01-18 00:27:56 UTC
Created attachment 4221 [details]
test PS file which reliably exhibits this bug
I plunged into the code today. The problem with the main viewer turned out to be caused by the following. KPSWidget::gs_input(), which controls the parceling-out of data to GhostScript, is supposed to be called only when the KProcess _process is ready to accept some more data. The way this is enforced is that the KProcess emits a signal when it is ready, and that signal is connected to gs_input(), which then sends the data to the KProcess pointed to by the member variable _process. However, sometimes a stale KProcess can emit this signal although _process has been changed. On receipt of this signal gs_input() tries to send data to _process, which isn't yet ready to accept it, and the data gets lost. A workaround for this problem is to modify KPSWidget::gs_input() to KPSWidget::gs_input(KProcess *), which can then keep track of which KProcess sent the signal, and just do nothing if it was a KProcess other than _process. On my system this workaround fixes the problems with the main viewer, although I still very occasionally have problems with the thumbnails. A patch implementing this workaround will be attached. Created attachment 4233 [details]
workaround for problem with main viewer
Subject: kdegraphics/kghostview CVS commit by luis_pedro: Fixes bug 72864 by correctly identifying if it's our KProcess which is ready. Patch by Andy Neitzke. Thanks a lot. CCMAIL:72864-close@bugs.kde.org M +10 -4 kpswidget.cpp 1.138 M +1 -1 kpswidget.h 1.76 --- kdegraphics/kghostview/kpswidget.cpp #1.137:1.138 @@ -180,5 +180,5 @@ bool KPSWidget::sendPS( FILE* fp, unsign // Start processing the queue. if( _stdinReady ) - gs_input(); + gs_input(_process); return true; @@ -371,5 +371,5 @@ bool KPSWidget::startInterpreter() this, SLOT( gs_output( KProcess*, char*, int ) ) ); connect( _process, SIGNAL( wroteStdin( KProcess*) ), - this, SLOT( gs_input() ) ); + this, SLOT( gs_input( KProcess* ) ) ); kapp->flushX(); @@ -449,8 +449,14 @@ void KPSWidget::gs_output( KProcess*, ch } -void KPSWidget::gs_input() +void KPSWidget::gs_input( KProcess* process ) { kdDebug(4500) << "KPSWidget: gs_input" << endl; + if (process != _process) + { + kdDebug(4500) << "KPSWidget::gs_input(): process != _process" << endl; + return; + } + _stdinReady = true; const unsigned bufferSize = 8192; @@ -483,5 +489,5 @@ void KPSWidget::gs_input() _currentRecord->begin += bytesRead; _currentRecord->len -= bytesRead; - if( _process && _process->writeStdin( _inputBuffer, bytesRead ) ) + if( process && process->writeStdin( _inputBuffer, bytesRead ) ) _stdinReady = false; else --- kdegraphics/kghostview/kpswidget.h #1.75:1.76 @@ -197,5 +197,5 @@ protected: protected slots: - void gs_input(); + void gs_input( KProcess* ); void gs_output( KProcess*, char* buffer, int len ); void interpreterFailed(); This has been working for me since the patch was applied, but I just tried out 3.3 Beta 1 from the Onebase LiveCD and the misbehavior seems to be back -- I tried downloading a bunch of postscript/PDF files from arxiv.org, and every time, the first page appeared blank. In fact, the first page remained blank even after I went to the second page and back to the first. The thumbnails also appeared all blank, except for the thumbnail corresponding to the first page, which showed a thumbnail of the last page. This behavior seems similar to what was observed a while ago in this bug report, and it seems like it might have a similar origin, so I'm reopening this bug, but I could open a new one if that's preferable. This is not the case in Okular. |