Bug 59041

Summary: Regression: Reloading files doesn't work correctly in 3.1.2
Product: [Unmaintained] kghostview Reporter: gerein
Component: generalAssignee: Wilco Greven <greven>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description gerein 2003-05-27 16:56:56 UTC
Version:            (using KDE 3.1.2)
Installed from:     (testing/unstable)
Compiler:          gcc version 3.3 (Debian)
OS:          Linux (i686) release 2.4.21-rc1

From version 3.1.1 to 3.1.2 the following patch was introduced:

--- kghostview/kgv_view.cpp     2003-05-27 16:24:08.000000000 +0200
+++ kghostview.3.1.2/kgv_view.cpp       2003-05-27 16:32:54.000000000 +0200
@@ -525,6 +526,8 @@
 {
     if( _isFileDirty )
     {
+       slotOrientation( _selectOrientation->currentItem() );
+       slotMedia( _selectMedia->currentItem() );
        _docManager->goToPage( _currentPage );
        _docManager->redisplay();
        _isFileDirty = false;

This fixes the bug that reloading a file would kill the selected orientation and media choice.

Unfortunately, now the reloading (watching) of long documents does not work correctly anymore. I get different behaviors, for example upon automatic reload, I still see the old page, but when moving a page up, I'm at the last page of the document. Sometimes the document is only loaded half, sometimes gs seems to hang...

My guess is that it's a timing problem, because slotOrientation, slotMedia, goToPage, and redisplay all call KGVMiniWidget::showPage( int pagenumber ) the first two possibly with a different page than the other two. Don't know what's causing the problems exactly, but I'm pretty sure that setting the orientation, media, and page variables prior to a single call to showPage would fix it.
Comment 1 gerein 2003-05-27 17:17:22 UTC
I just tried that with a quick hack. Declaring the variables 
_overrideOrientation, _overridePageMedia, and _currentPage public in 
KGVMiniWidget and setting them directly instead of calling slotOrientation, 
slotMedia, and goToPage fixes all problems! 
 
GS doesn't seem to like four sequential calls to showPage()...? Anyway, the 
multiple calls of showPage() are redundant anyway and should go away. Not sure 
how to do this more elegant, though... 
 
Comment 2 Luís Pedro Coelho 2003-05-27 18:49:51 UTC
Ok, i see this and it is mostly my fault. I just applied a different fix to BRANCH: 
Changing the order in which things are done (since calling showPage in miniwidget 
results in resetting the _currentPage variable). 
 
In HEAD, this code has changed and it is all done with one function call so the 
problem is inexistent. 
 
Thanks for the report. 
luis