Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » Memory Mapping LineEdit Data
Memory Mapping LineEdit Data [message #58180] Wed, 09 March 2022 05:13 Go to next message
syntax_ is currently offline  syntax_
Messages: 3
Registered: March 2022
Junior Member
Hello UppWorld! Noob here.

I have a simple parent control that manages a LineEdit, MemStream, and my own class MemoryMappedFile (I didn't find FileMapping until later since it is not under Documentation tab, and anyway it appears to be readonly?).
When I load a file I can successfully MemStream::Create, init my MemoryMappedFile, and LineEdit::Load(myMemStream), and there is a successful display of the file's contents.
My problems are:
A) External edits to the file are not displayed in the LineEdit, even with a forced Refresh(), unless I destroy\reopen the file. I'm guessing I could look at the file descriptor's modify times and do this through user interaction notifications, but feels wrong.
B) Edits to the LineEdit control do not appear "linked" in any way to the actual mmapped data, i.e. when I msync (successfully according to checked return code) no data is written to the file.

Is there a better way to go about this? I am mmaping with PROT_READ|PROT_WRITE and MAP_SHARED, I just can't seem to sync up the control to the data..

Thank you.
Re: Memory Mapping LineEdit Data [message #58193 is a reply to message #58180] Fri, 18 March 2022 18:37 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
syntax_ wrote on Wed, 09 March 2022 05:13
Hello UppWorld! Noob here.

I have a simple parent control that manages a LineEdit, MemStream, and my own class MemoryMappedFile (I didn't find FileMapping until later since it is not under Documentation tab, and anyway it appears to be readonly?).
When I load a file I can successfully MemStream::Create, init my MemoryMappedFile, and LineEdit::Load(myMemStream), and there is a successful display of the file's contents.
My problems are:
A) External edits to the file are not displayed in the LineEdit, even with a forced Refresh(), unless I destroy\reopen the file. I'm guessing I could look at the file descriptor's modify times and do this through user interaction notifications, but feels wrong.
B) Edits to the LineEdit control do not appear "linked" in any way to the actual mmapped data, i.e. when I msync (successfully according to checked return code) no data is written to the file.

Is there a better way to go about this? I am mmaping with PROT_READ|PROT_WRITE and MAP_SHARED, I just can't seem to sync up the control to the data..

Thank you.


I think that is misunderstading. Load really loads file content into MemoryMappedFile into "internal data" of LineEdit. If you want these data to stored, Save can save them to the Stream.

AFAIK it is practically impossible to directly edit files on disk. The problem is that the moment you insert something, you would need to copy all the physical data in the stream and that would be too slow. And it would wear out SSD disks pretty fast.
Previous Topic: DropDate Crash
Next Topic: issue with right to left languages (Arabic & Hebrew)
Goto Forum:
  


Current Time: Fri Apr 19 09:42:32 CEST 2024

Total time taken to generate the page: 0.02472 seconds