Qt-jambi-interest Archive, November 2006
QtJambi crashes when QFileSystemWatcher.fileChanged is sent
Message 1 in thread
I am currently trying to write a simple "tail" application that shows
changes in log files. I am using a QTextEdit to display the log file and
would like to update it whenever the log file changes. Currently I am doing
the following:
public class Application extends QMainWindow {
...
QFileSystemWatcher watch;
public Application() {
...
watch = new QFileSystemWatcher();
}
public void loadFile(String fileName) {
QFile file = new QFile(fileName);
if (!file.open(new QFile.OpenMode(QFile.OpenModeFlag.ReadOnly,
QFile.OpenModeFlag.Text))) {
QMessageBox.warning(this, "Application", "Cannot read
"+fileName);
return;
}
QTextStream in = new QTextStream(file);
QApplication.setOverrideCursor(new QCursor(Qt.CursorShape.WaitCursor
));
textEdit.setPlainText(in.readAll());
QApplication.restoreOverrideCursor();
setCurrentFile(fileName);
statusBar().showMessage("File loaded",2000);
watch.addPath(fileName);
watch.fileChanged.connect(this,"fileChanged(String)");
}
public void fileChanged(String name) {
System.err.println(name+" changed");
}
}
The application crashes as soon as I modify the file and save it.
Some crash information:
AppName: javaw.exe
AppVer: 5.0.70.3
ModName: com_trolltech_qt_core.dll
I am running the application in debug mode from Eclipse, using JDK 1.5.7
Is this a known issue, am I doing something wrong when connecting the
signal?
Thanks,
Tilman
Message 2 in thread
Tilman Schlenker wrote:
> I am currently trying to write a simple "tail" application that shows
> changes in log files. I am using a QTextEdit to display the log file
> and would like to update it whenever the log file changes. Currently I
> am doing the following:
[...]
>
> The application crashes as soon as I modify the file and save it.
Hi, Tilman.
I've been able to reproduce this bug, thank you very much for reporting it.
The problem is the handling of the file system watcher thread when it
tries to access the class path file engine (Qt Jambi's resource system.)
It will of course be fixed in the next release of Qt Jambi, but, in the
meantime, there is unfortunately no convenient work-around for this.
We do have the following little hack which will fix the problem, but
which will also disable the class path file engine (so any accesses to
the resource system will fail until a proper patch is released.) I'm
posting it in case it is acceptable for you to live without a resource
system until the next release of Qt Jambi.
First you will have to unpack the qtjambi.jar-file and use the files on
your disk as your class path instead of the .jar-file. Then delete the
file com/trolltech/qt/QClassPathFileEngineHandler.class. Finally create
the following class, compile it and replace the recently deleted class
file with your hacked class file:
--
[ signature omitted ]