fix: can't correctly create project in release mode
This commit is contained in:
parent
6ec3cfbfca
commit
2915a862ff
|
@ -63,8 +63,7 @@ PSearchResultTreeItem CppRefacter::findOccurenceInFile(
|
|||
editor.lines()->setContents(buffer);
|
||||
} else {
|
||||
QByteArray encoding;
|
||||
QFile file(filename);
|
||||
editor.lines()->LoadFromFile(file,ENCODING_AUTO_DETECT,encoding);
|
||||
editor.lines()->LoadFromFile(filename,ENCODING_AUTO_DETECT,encoding);
|
||||
}
|
||||
editor.setHighlighter(HighlighterManager().getCppHighlighter());
|
||||
int posY = 0;
|
||||
|
|
|
@ -152,11 +152,9 @@ Editor::~Editor() {
|
|||
|
||||
void Editor::loadFile(const QString& filename) {
|
||||
if (filename.isEmpty()) {
|
||||
QFile file(mFilename);
|
||||
this->lines()->LoadFromFile(file,mEncodingOption,mFileEncoding);
|
||||
this->lines()->LoadFromFile(mFilename,mEncodingOption,mFileEncoding);
|
||||
} else {
|
||||
QFile file(filename);
|
||||
this->lines()->LoadFromFile(file,mEncodingOption,mFileEncoding);
|
||||
this->lines()->LoadFromFile(filename,mEncodingOption,mFileEncoding);
|
||||
}
|
||||
//this->setModified(false);
|
||||
updateCaption();
|
||||
|
@ -300,7 +298,6 @@ bool Editor::saveAs(const QString &name, bool fromProject){
|
|||
mUseCppSyntax = pSettings->editor().defaultFileCpp();
|
||||
}
|
||||
|
||||
|
||||
//update (reassign highlighter)
|
||||
PSynHighlighter newHighlighter = HighlighterManager().getHighlighter(mFilename);
|
||||
if (newHighlighter) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
#include <QMessageBox>
|
||||
#include "settings.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -644,6 +645,7 @@ bool Project::assignTemplate(const std::shared_ptr<ProjectTemplate> aTemplate)
|
|||
s = templateUnit->CText;
|
||||
unit = newUnit(mNode,templateUnit->CName);
|
||||
}
|
||||
|
||||
Editor * editor = pMainWindow->editorList()->newEditor(
|
||||
QDir(directory()).absoluteFilePath(unit->fileName()),
|
||||
unit->encoding(),
|
||||
|
@ -651,7 +653,7 @@ bool Project::assignTemplate(const std::shared_ptr<ProjectTemplate> aTemplate)
|
|||
true);
|
||||
|
||||
QString s2 = QDir(pSettings->dirs().templateDir()).absoluteFilePath(s);
|
||||
if (QFile(s2).exists()) {
|
||||
if (fileExists(s2)) {
|
||||
editor->loadFile(s2);
|
||||
} else {
|
||||
s.replace("#13#10","\r\n");
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <QPaintEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QStyleHints>
|
||||
#include <QMessageBox>
|
||||
|
||||
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||
{
|
||||
|
@ -454,7 +455,7 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint)
|
|||
// search for the matching bracket (that is until NumBrackets = 0)
|
||||
NumBrackets = 1;
|
||||
if (i%2==1) {
|
||||
do {
|
||||
while (true) {
|
||||
// search until start of line
|
||||
while (PosX > 1) {
|
||||
PosX--;
|
||||
|
@ -486,9 +487,9 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint)
|
|||
PosY--;
|
||||
Line = mLines->getString(PosY - 1);
|
||||
PosX = Line.length() + 1;
|
||||
} while (true);
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
while (true) {
|
||||
// search until end of line
|
||||
Len = Line.length();
|
||||
while (PosX < Len) {
|
||||
|
@ -521,7 +522,7 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint)
|
|||
PosY++;
|
||||
Line = mLines->getString(PosY - 1);
|
||||
PosX = 0;
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
// don't test the other brackets, we're done
|
||||
break;
|
||||
|
@ -2810,6 +2811,8 @@ int SynEdit::scanFrom(int Index, int canStopIndex)
|
|||
Result ++ ;
|
||||
} while (Result < mLines->count());
|
||||
Result--;
|
||||
if (mUseCodeFolding)
|
||||
rescan();
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
@ -2825,6 +2828,8 @@ void SynEdit::scanRanges()
|
|||
mHighlighter->getRightBraces());
|
||||
}
|
||||
}
|
||||
if (mUseCodeFolding)
|
||||
rescan();
|
||||
}
|
||||
|
||||
void SynEdit::uncollapse(PSynEditFoldRange FoldRange)
|
||||
|
@ -2914,6 +2919,7 @@ void SynEdit::rescanForFoldRanges()
|
|||
|
||||
// Did we leave any collapsed folds and are we viewing a code file?
|
||||
if (mAllFoldRanges.count() > 0) {
|
||||
|
||||
// Add folds to a separate list
|
||||
PSynEditFoldRanges TemporaryAllFoldRanges = std::make_shared<SynEditFoldRanges>();
|
||||
scanForFoldRanges(TemporaryAllFoldRanges);
|
||||
|
@ -2932,6 +2938,7 @@ void SynEdit::rescanForFoldRanges()
|
|||
}
|
||||
|
||||
} else {
|
||||
|
||||
// We ended up with no folds after deleting, just pass standard data...
|
||||
PSynEditFoldRanges temp(&mAllFoldRanges, null_deleter);
|
||||
scanForFoldRanges(temp);
|
||||
|
@ -2982,11 +2989,11 @@ void SynEdit::findSubFoldRange(PSynEditFoldRanges TopFoldRanges, int FoldIndex,P
|
|||
PSynEditFoldRange CollapsedFold;
|
||||
int Line = 0;
|
||||
QString CurLine;
|
||||
if (!mHighlighter)
|
||||
return;
|
||||
bool useBraces = ( mCodeFolding.foldRegions.get(FoldIndex)->openSymbol == "{"
|
||||
&& mCodeFolding.foldRegions.get(FoldIndex)->closeSymbol == "}");
|
||||
|
||||
if (!mHighlighter)
|
||||
return;
|
||||
while (Line < mLines->count()) { // index is valid for LinesToScan and fLines
|
||||
// If there is a collapsed fold over here, skip it
|
||||
CollapsedFold = collapsedFoldStartAtLine(Line + 1); // only collapsed folds remain
|
||||
|
@ -4075,7 +4082,6 @@ void SynEdit::setUseCodeFolding(bool value)
|
|||
{
|
||||
if (mUseCodeFolding!=value) {
|
||||
mUseCodeFolding = value;
|
||||
rescan();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5659,8 +5665,6 @@ void SynEdit::onLinesChanged()
|
|||
{
|
||||
SynSelectionMode vOldMode;
|
||||
mStateFlags.setFlag(SynStateFlag::sfLinesChanging, false);
|
||||
if (mUseCodeFolding)
|
||||
rescan();
|
||||
|
||||
updateScrollbars();
|
||||
vOldMode = mActiveSelectionMode;
|
||||
|
@ -5671,7 +5675,6 @@ void SynEdit::onLinesChanged()
|
|||
else
|
||||
invalidateRect(mInvalidateRect);
|
||||
mInvalidateRect = {0,0,0,0};
|
||||
|
||||
if (mGutter.showLineNumbers() && (mGutter.autoSize()))
|
||||
mGutter.autoSizeDigitCount(mLines->count());
|
||||
//if (!mOptions.testFlag(SynEditorOption::eoScrollPastEof))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "SynEdit.h"
|
||||
#include "../utils.h"
|
||||
#include "../platform.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
SynEditStringList::SynEditStringList(SynEdit *pEdit, QObject *parent):
|
||||
QObject(parent),
|
||||
|
@ -477,15 +478,15 @@ void SynEditStringList::InsertText(int Index, const QString &NewText)
|
|||
InsertStrings(Index,lines);
|
||||
}
|
||||
|
||||
void SynEditStringList::LoadFromFile(QFile &file, const QByteArray& encoding, QByteArray& realEncoding)
|
||||
void SynEditStringList::LoadFromFile(const QString& filename, const QByteArray& encoding, QByteArray& realEncoding)
|
||||
{
|
||||
QFile file(filename);
|
||||
if (!file.open(QFile::ReadOnly ))
|
||||
throw FileError(tr("Can't open file '%1' for read!").arg(file.fileName()));
|
||||
beginUpdate();
|
||||
auto action = finally([this]{
|
||||
endUpdate();
|
||||
});
|
||||
|
||||
//test for utf8 / utf 8 bom
|
||||
if (encoding == ENCODING_AUTO_DETECT) {
|
||||
if (file.atEnd()) {
|
||||
|
@ -514,7 +515,7 @@ void SynEditStringList::LoadFromFile(QFile &file, const QByteArray& encoding, QB
|
|||
mFileEndingType = FileEndingType::Mac;
|
||||
}
|
||||
clear();
|
||||
do {
|
||||
while (true) {
|
||||
if (allAscii) {
|
||||
allAscii = isTextAllAscii(line);
|
||||
}
|
||||
|
@ -532,7 +533,8 @@ void SynEditStringList::LoadFromFile(QFile &file, const QByteArray& encoding, QB
|
|||
break;
|
||||
}
|
||||
line = file.readLine();
|
||||
} while (true);
|
||||
}
|
||||
emit inserted(0,mList.count());
|
||||
if (!needReread) {
|
||||
if (allAscii)
|
||||
realEncoding = ENCODING_ASCII;
|
||||
|
@ -545,15 +547,6 @@ void SynEditStringList::LoadFromFile(QFile &file, const QByteArray& encoding, QB
|
|||
|
||||
if (realEncoding == ENCODING_SYSTEM_DEFAULT) {
|
||||
realEncoding = getDefaultSystemEncoding();
|
||||
QFile file("f:\\test.txt");
|
||||
if (file.open(QFile::WriteOnly|QFile::Truncate)) {
|
||||
file.write("----test----\n");
|
||||
for (QByteArray a:QTextCodec::codecForLocale()->aliases()) {
|
||||
file.write(a);
|
||||
file.write("\n");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.reset();
|
||||
QTextStream textStream(&file);
|
||||
|
@ -569,6 +562,7 @@ void SynEditStringList::LoadFromFile(QFile &file, const QByteArray& encoding, QB
|
|||
while (textStream.readLineInto(&line)) {
|
||||
addItem(TrimRight(line));
|
||||
}
|
||||
emit inserted(0,mList.count());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
void InsertLines(int Index, int NumLines);
|
||||
void InsertStrings(int Index, const QStringList& NewStrings);
|
||||
void InsertText(int Index,const QString& NewText);
|
||||
void LoadFromFile(QFile& file, const QByteArray& encoding, QByteArray& realEncoding);
|
||||
void LoadFromFile(const QString& filename, const QByteArray& encoding, QByteArray& realEncoding);
|
||||
void SaveToFile(QFile& file, const QByteArray& encoding, QByteArray& realEncoding);
|
||||
|
||||
bool getAppendNewLineAtEOF() const;
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#error "Only support windows and linux now!"
|
||||
#endif
|
||||
|
||||
#define DEVCPP_VERSION "0.1.0"
|
||||
#define DEVCPP_VERSION "0.2.0"
|
||||
|
||||
class SystemConsts
|
||||
{
|
||||
|
|
|
@ -66,6 +66,15 @@ const QByteArray GuessTextEncoding(const QByteArray& text){
|
|||
return ENCODING_UTF8;
|
||||
}
|
||||
|
||||
bool isTextAllAscii(const QByteArray& text) {
|
||||
for (char c:text) {
|
||||
if (c<0 || c>127) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isTextAllAscii(const QString& text) {
|
||||
for (QChar c:text) {
|
||||
if (c.unicode()>127) {
|
||||
|
|
|
@ -114,6 +114,7 @@ bool isGreenEdition();
|
|||
|
||||
const QByteArray GuessTextEncoding(const QByteArray& text);
|
||||
|
||||
bool isTextAllAscii(const QByteArray& text);
|
||||
bool isTextAllAscii(const QString& text);
|
||||
|
||||
QByteArray runAndGetOutput(const QString& cmd, const QString& workingDir, const QStringList& arguments,
|
||||
|
|
Loading…
Reference in New Issue