| 858 | } |
| 859 | |
| 860 | bool TextDocument::loadAsyncFromFile( const std::string& path, std::shared_ptr<ThreadPool> pool, |
| 861 | std::function<void( TextDocument*, bool )> onLoaded ) { |
| 862 | mLoading = true; |
| 863 | mLoadingAsync = true; |
| 864 | { |
| 865 | Lock l( mLoadingFilePathMutex ); |
| 866 | mLoadingFilePath = path; |
| 867 | mLoadingFileURI = URI( "file://" + mLoadingFilePath ); |
| 868 | } |
| 869 | pool->run( [this, path, onLoaded] { |
| 870 | auto loaded = loadFromFile( path ); |
| 871 | if ( loaded != LoadStatus::Interrupted && onLoaded ) { |
| 872 | onLoaded( this, loaded == LoadStatus::Loaded ); |
| 873 | } |
| 874 | { |
| 875 | Lock l( mLoadingFilePathMutex ); |
| 876 | mLoadingFilePath.clear(); |
| 877 | mLoadingFileURI = URI(); |
| 878 | } |
| 879 | notifyDocumentLoaded(); |
| 880 | mLoadingAsync = false; |
| 881 | } ); |
| 882 | return true; |
| 883 | } |
| 884 | |
| 885 | TextDocument::LoadStatus TextDocument::loadFromMemory( const Uint8* data, const Uint32& size ) { |
| 886 | IOStreamMemory stream( (const char*)data, size ); |
no test coverage detected