This commit is contained in:
Martín Lucas Golini
2024-09-16 20:36:04 -03:00
parent 4082ce517e
commit 39c9adff2f
3 changed files with 30 additions and 16 deletions

View File

@@ -516,9 +516,9 @@ class EE_API TextDocument {
void toLowerSelection();
const std::string& getLoadingFilePath() const;
std::string getLoadingFilePath() const;
const URI& getLoadingFileURI() const;
URI getLoadingFileURI() const;
void setSelection( const TextRanges& selection );

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2024-08-18T01:27:42. -->
<!-- Written by QtCreator 14.0.1, 2024-09-16T20:13:14. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@@ -124,7 +124,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{388e5431-b31b-42b3-b9ad-9002d279d75d}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">10</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">19</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">../../make/linux</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
@@ -1219,10 +1219,10 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-empty-window-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="int" key="RunConfiguration.UseCppDebugger">1</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
<value type="int" key="RunConfiguration.UseCppDebugger">0</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
<value type="int" key="RunConfiguration.UseQmlDebugger">0</value>
<value type="int" key="RunConfiguration.UseQmlDebugger">1</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
<value type="bool" key="RunConfiguration.UseTerminal">false</value>
<value type="QString" key="RunConfiguration.WorkingDirectory">%{buildDir}../../../bin/</value>

View File

@@ -57,6 +57,17 @@ TextDocument::~TextDocument() {
mLoading = false;
Lock l( mLoadingMutex );
}
{
Lock l( mClientsMutex );
}
// Loading has been stopped
while ( mLoadingAsync ) {
mLoading = false;
Sys::sleep( Milliseconds( 0.1 ) );
}
notifyDocumentClosed();
if ( mDeleteOnClose )
FileSystem::fileRemove( mFilePath );
@@ -484,12 +495,12 @@ void TextDocument::toLowerSelection() {
}
}
const std::string& TextDocument::getLoadingFilePath() const {
std::string TextDocument::getLoadingFilePath() const {
Lock l( mLoadingFilePathMutex );
return mLoadingFilePath;
}
const URI& TextDocument::getLoadingFileURI() const {
URI TextDocument::getLoadingFileURI() const {
Lock l( mLoadingFilePathMutex );
return mLoadingFileURI;
}
@@ -534,8 +545,8 @@ bool TextDocument::loadAsyncFromFile( const std::string& path, std::shared_ptr<T
mLoadingFilePath.clear();
mLoadingFileURI = URI();
}
mLoadingAsync = false;
notifyDocumentLoaded();
mLoadingAsync = false;
} );
return true;
}
@@ -566,12 +577,13 @@ static std::string getTempPathFromURI( const URI& uri ) {
TextDocument::LoadStatus TextDocument::loadFromURL( const std::string& url,
const Http::Request::FieldTable& headers ) {
mLoading = true;
URI uri( url );
if ( uri.getScheme().empty() )
if ( uri.getScheme().empty() ) {
mLoading = false;
return LoadStatus::Failed;
mLoading = true;
}
Http::Response response =
Http::get( uri, Seconds( 10 ), nullptr, headers, "", true, Http::getEnvProxyURI() );
@@ -594,12 +606,14 @@ bool TextDocument::loadAsyncFromURL( const std::string& url,
const Http::Request::FieldTable& headers,
std::function<void( TextDocument*, bool success )> onLoaded,
const Http::Request::ProgressCallback& progressCallback ) {
mLoading = true;
URI uri( url );
if ( uri.getScheme().empty() || ( uri.getScheme() != "https" && uri.getScheme() != "http" ) )
if ( uri.getScheme().empty() || ( uri.getScheme() != "https" && uri.getScheme() != "http" ) ) {
mLoading = false;
return false;
}
mLoading = true;
mLoadingAsync = true;
Http::getAsync(
@@ -617,8 +631,8 @@ bool TextDocument::loadAsyncFromURL( const std::string& url,
onLoaded( this, false );
}
mLoading = false;
mLoadingAsync = false;
notifyDocumentLoaded();
mLoadingAsync = false;
},
uri, Seconds( 10 ), progressCallback, headers, "", true, Http::getEnvProxyURI() );
return true;