[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: File not read completely when opening?
From:       Andras Mantia <amantia () virtualartisans ! com>
Date:       2003-02-09 10:22:41
[Download RAW message or body]

Hi,

 I saw that Hamish patched his local Kate, but what would be the best if we 
would have a signal which can be used also when the selected editor is other 
than Kate. In Quanta's case it's very important to know when is the loading 
finished, otherwise I cannot parse the document correctly. I saw that there 
is a completed() signal in ReadOnlyPart, which according to the docs 
"Emit this when you have completed loading data. Hosting apps will want to 
know when the process of loading the data is finished, so that they can 
access the data when everything is loaded. "

But even if I connect a slot to this signal, it gets called before the 
complete file is loaded. From the logs we I can see:

Kate (Document): servicetype:
Kate (Document): myEncoding: iso 8859-1
Quanta: New parser (539 lines): 62 ms
Quanta: StructTreeView building: 39 ms
Kate (Document): Loading finished.

According to the ReadOnlyPart code the signal is emited when the openFile() 
returns. So if openFile() wait until the whole file is read, then 
everything's fine. But in case we don't even need the completed(), as we can 
just wait for openURL() to return. 

But Kate loads the file in block, and the openURL returns before the loading 
is completed. I can imagine that it is done this way because loading of huge 
files can take a lot of time and the UI will be not responsive until the 
openURL() returns, but according to the docs and the code, this is not the 
right way of doing. openURL is designed to be synchronous. In case that we 
want an asynchronous way of opening a file, I think there are three choices:

1. add a new signal to ReadOnlyPart which gets emited after the whole data is 
read by the part

2. add this new signal to the KTextEditor::Document interface.

3. Change the Kate part, so it will return from openFile only after the whole 
file is loaded. 

The current way of working is bad, and I simply cannot fix Quanta due to it. 
The only fix may be to delay the parsing with some ms, but you know that this 
is inaccurate and you never known how fast is a file loaded.

Andras



-- 
Quanta Plus developer - http://quanta.sourceforge.net
K Desktop Environment - http://www.kde.org

_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic