修正 KchmViewer 4 的两个 Bug

{撰文/john}

index 显示不全 bug 的解决

KchmViewer 4 有一个 bug ,就是看一些 chm 文档时,index 会显示不全(有 Python 的 chm 格式文档的可以试一下,python261.chm 的 index 在 KchmViewer 4 下大概能显示到字母 n 的样子)。昨天调试了一下,改正了这个 bug 。修改方法为:

下载源代码(官网上下),在 lib/libchmfile 目录下,找到 libchmfile.cpp 文件,修改函数 bool LCHMFile::parseIndex( QVector< LCHMParsedEntry > * indexes ) const,将其从:

return m_impl->parseBinaryIndex( indexes )
   || m_impl->parseFileAndFillArray( m_impl->m_indexFile, indexes, true );

改为:

return m_impl->parseFileAndFillArray( m_impl->m_indexFile, indexes, true )
||m_impl->parseBinaryIndex( indexes );

然后编译,这样得到的程序就能正确的显示 index 了。具体原因的分析,请查看我写的日志:http://www.douban.com/note/34281029/

中文路径 bug 的解决

解决方法是:

在源码目录下找到 kchmmainwindow.cpp 下找到 parseCmdLineArgs() 函数,找到如下行:

filename = args->arg(0); (在文件的520行)

filename = qApp->argv()[i];  (在文件的547行)

分别改为:

filename = QString::fromLocal8Bit(args->arg(0));

filename = QString::fromLocal8Bit(qApp->argv()[i]);

然后保存编译,大功告成!

具体分析见我的日志 http://www.douban.com/note/34321296/

Read More:

5 Comments

  1. 1 shuge.lee Commented @ 2009-05-24 19:54Reply to this comment

    okluar (kde) chmsee (gnome) 都不错,都可以读chm

    目前,对中文支持最的,应该是chmsee

  2. 2 nihui Commented @ 2009-05-24 19:59Reply to this comment

    推到上游修复掉吧~

  3. 3 luyaotang Commented @ 2009-05-24 20:57Reply to this comment

    虽然不用,不过还是要支持一下。

  4. 4 dybnu Commented @ 2009-05-24 21:05Reply to this comment

    okluar 看chm卡的很厉害,貌似是整个读进来的

  5. 5 DBJCK Commented @ 2009-05-24 22:00Reply to this comment

    感觉还是chmsee好用!