Skip to content

Commit 500d466

Browse files
authored
Merge pull request #2406 from SCIInstitute/issues-zzz
Fixes #2405
2 parents a486c61 + c80769f commit 500d466

File tree

2 files changed

+57
-29
lines changed

2 files changed

+57
-29
lines changed

src/Interface/Application/SCIRunMainWindow.cc

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <Core/Logging/Log.h>
5252
#include <Dataflow/Serialization/Network/NetworkDescriptionSerialization.h>
5353
#include <Dataflow/Serialization/Network/Importer/NetworkIO.h>
54+
#include <chrono>
5455

5556
#ifdef BUILD_WITH_PYTHON
5657
#include <Interface/Application/PythonConsoleWidget.h>
@@ -398,12 +399,45 @@ QString SCIRunMainWindow::strippedName(const QString& fullFileName)
398399
return info.fileName();
399400
}
400401

402+
namespace
403+
{
404+
bool fileExistCheck(const std::string& filename)
405+
{
406+
bool fileExists;
407+
//TODO: boost upgrade to 1.80 should remove the need for the try/catch--see issue #2407
408+
try
409+
{
410+
fileExists = boost::filesystem::exists(filename);
411+
}
412+
catch (...)
413+
{
414+
fileExists = false;
415+
}
416+
return fileExists;
417+
}
418+
419+
bool superFileExistCheck(const std::string& filename)
420+
{
421+
auto check = std::async([filename]() { return fileExistCheck(filename); });
422+
auto status = check.wait_for(std::chrono::seconds(1));
423+
if (status == std::future_status::ready)
424+
return check.get();
425+
return false;
426+
}
427+
}
428+
401429
void SCIRunMainWindow::updateRecentFileActions()
402430
{
403431
QMutableStringListIterator i(recentFiles_);
404-
while (i.hasNext()) {
405-
if (!QFile::exists(i.next()))
432+
while (i.hasNext())
433+
{
434+
const auto file = i.next().toStdString();
435+
436+
if (!superFileExistCheck(file))
437+
{
438+
logWarning("Network file {} not found, removing entry from recent list.", file);
406439
i.remove();
440+
}
407441
}
408442

409443
for (int j = 0; j < MaxRecentFiles; ++j)

src/Modules/Legacy/String/PrintStringIntoString.cc

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,32 @@ PrintStringIntoString::execute()
7272
std::string str;
7373

7474
std::vector<char> buffer(256);
75-
bool lastport = false;
76-
77-
78-
auto stringH = getOptionalInput(Format);
79-
75+
bool lastport = false;
76+
auto stringH = getOptionalInput(Format);
8077
auto state = get_state();
8178

8279
// check for port input and in none use gui input
8380
if (stringH && *stringH)
8481
{
85-
state -> setValue(FormatString, (*stringH) -> value());
82+
state->setValue(FormatString, (*stringH)->value());
8683
}
87-
format = state -> getValue(FormatString).toString();
88-
84+
format = state->getValue(FormatString).toString();
8985

90-
// Get the dynamic handles
9186
auto stringsH = getOptionalDynamicInputs(Input);
9287

9388

9489
if (needToExecute())
9590
{
9691
size_t i = 0;
97-
while(i < format.size())
92+
while (i < format.size())
9893
{
9994
if (format[i] == '%')
10095
{
10196
if (i == format.size()-1)
10297
{
10398
error("Improper format string '%' is last character");
10499
return;
105-
}
100+
}
106101

107102
if (format[i+1] == '%')
108103
{
@@ -125,34 +120,33 @@ PrintStringIntoString::execute()
125120

126121
std::string fstr = format.substr(i,j-i+1);
127122

123+
if ((format[j] == 's')||(format[j] == 'S')||(format[j] == 'c')||(format[j] == 'C'))
128124
{
129-
str = "";
130-
if (lastport == false)
131125
{
132-
if (inputport == stringsH.size())
133-
{
134-
lastport = true;
135-
}
136-
else
126+
str = "";
127+
if (!lastport)
137128
{
138-
if (stringsH.size() == static_cast<size_t>(inputport))
129+
if (inputport == stringsH.size())
139130
{
140131
lastport = true;
141132
}
142133
else
143134
{
144-
currentstring = stringsH[inputport]; inputport++;
145-
if (currentstring)
135+
if (stringsH.size() == static_cast<size_t>(inputport))
136+
{
137+
lastport = true;
138+
}
139+
else
146140
{
147-
str = currentstring->value();
141+
currentstring = stringsH[inputport++];
142+
if (currentstring)
143+
{
144+
str = currentstring->value();
145+
}
148146
}
149147
}
150148
}
151149
}
152-
}
153-
154-
if ((format[j] == 's')||(format[j] == 'S')||(format[j] == 'c')||(format[j] == 'C'))
155-
{
156150
// We put the %s %S back in the string so it can be filled out lateron
157151
// By a different module
158152

@@ -209,7 +203,7 @@ PrintStringIntoString::execute()
209203
output += format[i++];
210204
}
211205
}
212-
206+
213207
StringHandle handle(new String(output));
214208
sendOutput(Output, handle);
215209
}

0 commit comments

Comments
 (0)