Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix saving style error and code scanning alert #330

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ const wxString FRConfig::getSysTemplateFileName(const wxString& templateName)

wxString FRConfig::getXmlStylesPath() const
{
if (wxDirExists(getUserLocalDataDir() + wxFileName::GetPathSeparator() + "xml-styles"))
return getUserLocalDataDir() + wxFileName::GetPathSeparator()
+ "xml-styles" + wxFileName::GetPathSeparator();

return getHomePath() + "xml-styles"
+ wxFileName::GetPathSeparator();
}
Expand Down
21 changes: 21 additions & 0 deletions src/gui/PreferencesDialogSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,27 @@ bool PrefDlgThemeSetting::parseProperty(wxXmlNode* xmln)
bool PrefDlgThemeSetting::saveToTargetConfig(Config& config)
{
config.setValue(keyM, fileComboBoxM->GetValue());
wxString userStyleFolder = config.getUserLocalDataDir() + wxFileName::GetPathSeparator() + "xml-styles" + wxFileName::GetPathSeparator();
if (!wxDirExists(userStyleFolder))
{
wxFileName mFile = getStyleManager()->getfileName();
mFile.SetPath(userStyleFolder);

wxString sourceDirName = config.getHomePath() + "xml-styles" + wxFileName::GetPathSeparator();

wxString fileSpec = _T("*.xml");
wxArrayString files;
if (wxDir::GetAllFiles(sourceDirName, &files, fileSpec, wxDIR_FILES) > 0) {
wxMkdir(userStyleFolder);
wxString name, ext;
for (size_t i = 0; i < files.GetCount(); i++) {
wxFileName::SplitPath(files[i], NULL, &name, &ext);
wxCopyFile(files[i], userStyleFolder + name + "." + ext);
}
}
getStyleManager()->setfileName(mFile);
}

getStyleManager()->saveStyle();

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/sql/StatementBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void StatementBuilder::addNewLine()
{
completedLinesM += currentLineM;
completedLinesM += wxTextBuffer::GetEOL();
currentLineM = wxString(wxChar(' '), indentLevelM * indentCharsM);
currentLineM = wxString(wxChar(' '), static_cast<unsigned long>(indentLevelM) * static_cast<unsigned long>(indentCharsM));
}

void StatementBuilder::reset()
Expand Down
Loading