Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/Interface/Application/SCIRunMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include <Core/Logging/Log.h>
#include <Dataflow/Serialization/Network/NetworkDescriptionSerialization.h>
#include <Dataflow/Serialization/Network/Importer/NetworkIO.h>
#include <chrono>

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

namespace
{
bool fileExistCheck(const std::string& filename)
{
bool fileExists;
//TODO: boost upgrade to 1.80 should remove the need for the try/catch--see issue #2407
try
{
fileExists = boost::filesystem::exists(filename);
}
catch (...)
{
fileExists = false;
}
return fileExists;
}

bool superFileExistCheck(const std::string& filename)
{
auto check = std::async([filename]() { return fileExistCheck(filename); });
auto status = check.wait_for(std::chrono::seconds(1));
if (status == std::future_status::ready)
return check.get();
return false;
}
}

void SCIRunMainWindow::updateRecentFileActions()
{
QMutableStringListIterator i(recentFiles_);
while (i.hasNext()) {
if (!QFile::exists(i.next()))
while (i.hasNext())
{
const auto file = i.next().toStdString();

if (!superFileExistCheck(file))
{
logWarning("Network file {} not found, removing entry from recent list.", file);
i.remove();
}
}

for (int j = 0; j < MaxRecentFiles; ++j)
Expand Down
48 changes: 21 additions & 27 deletions src/Modules/Legacy/String/PrintStringIntoString.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,32 @@ PrintStringIntoString::execute()
std::string str;

std::vector<char> buffer(256);
bool lastport = false;


auto stringH = getOptionalInput(Format);

bool lastport = false;
auto stringH = getOptionalInput(Format);
auto state = get_state();

// check for port input and in none use gui input
if (stringH && *stringH)
{
state -> setValue(FormatString, (*stringH) -> value());
state->setValue(FormatString, (*stringH)->value());
}
format = state -> getValue(FormatString).toString();

format = state->getValue(FormatString).toString();

// Get the dynamic handles
auto stringsH = getOptionalDynamicInputs(Input);


if (needToExecute())
{
size_t i = 0;
while(i < format.size())
while (i < format.size())
{
if (format[i] == '%')
{
if (i == format.size()-1)
{
error("Improper format string '%' is last character");
return;
}
}

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

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

if ((format[j] == 's')||(format[j] == 'S')||(format[j] == 'c')||(format[j] == 'C'))
{
str = "";
if (lastport == false)
{
if (inputport == stringsH.size())
{
lastport = true;
}
else
str = "";
if (!lastport)
{
if (stringsH.size() == static_cast<size_t>(inputport))
if (inputport == stringsH.size())
{
lastport = true;
}
else
{
currentstring = stringsH[inputport]; inputport++;
if (currentstring)
if (stringsH.size() == static_cast<size_t>(inputport))
{
lastport = true;
}
else
{
str = currentstring->value();
currentstring = stringsH[inputport]; inputport++;
if (currentstring)
{
str = currentstring->value();
}
}
}
}
}
}

if ((format[j] == 's')||(format[j] == 'S')||(format[j] == 'c')||(format[j] == 'C'))
{
// We put the %s %S back in the string so it can be filled out lateron
// By a different module

Expand Down Expand Up @@ -209,7 +203,7 @@ PrintStringIntoString::execute()
output += format[i++];
}
}

StringHandle handle(new String(output));
sendOutput(Output, handle);
}
Expand Down