Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
b0b893ac
Commit
b0b893ac
authored
Feb 10, 2010
by
Erik Verbruggen
Browse files
Fixed null-pointer deref in copy/paste.
parent
2e7ddfb9
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
View file @
b0b893ac
...
...
@@ -326,7 +326,7 @@ QList<RewriterView::Error> DesignDocumentController::loadMaster(QPlainTextEdit *
connect
(
edit
,
SIGNAL
(
modificationChanged
(
bool
)),
this
,
SIGNAL
(
dirtyStateChanged
(
bool
)));
m_d
->
textModifier
=
new
BaseTextEditModifier
(
m_d
->
textEdit
.
data
());
m_d
->
textModifier
=
new
BaseTextEditModifier
(
dynamic_cast
<
TextEditor
::
BaseTextEditor
*>
(
m_d
->
textEdit
.
data
())
)
;
m_d
->
componentTextModifier
=
0
;
...
...
src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
View file @
b0b893ac
...
...
@@ -31,6 +31,7 @@
#include
<rewriterview.h>
#include
<basetexteditmodifier.h>
#include
<metainfo.h>
#include
<plaintexteditmodifier.h>
#include
<QApplication>
#include
<QPlainTextEdit>
...
...
@@ -102,7 +103,7 @@ QString DesignDocumentControllerView::toText() const
outputModel
->
setMetaInfo
(
model
()
->
metaInfo
());
QPlainTextEdit
textEdit
;
textEdit
.
setPlainText
(
"import Qt 4.6; Item {}"
);
Base
TextEditModifier
modifier
(
&
textEdit
);
NotIndenting
TextEditModifier
modifier
(
&
textEdit
);
QScopedPointer
<
RewriterView
>
rewriterView
(
new
RewriterView
(
RewriterView
::
Amend
,
0
));
rewriterView
->
setTextModifier
(
&
modifier
);
...
...
@@ -126,7 +127,7 @@ void DesignDocumentControllerView::fromText(QString text)
QPlainTextEdit
textEdit
;
QString
imports
(
"import Qt 4.6;
\n
"
);
textEdit
.
setPlainText
(
imports
+
text
);
Base
TextEditModifier
modifier
(
&
textEdit
);
NotIndenting
TextEditModifier
modifier
(
&
textEdit
);
QScopedPointer
<
RewriterView
>
rewriterView
(
new
RewriterView
(
RewriterView
::
Amend
,
0
));
rewriterView
->
setTextModifier
(
&
modifier
);
...
...
src/plugins/qmldesigner/core/include/basetexteditmodifier.h
View file @
b0b893ac
...
...
@@ -34,12 +34,14 @@
#include
"corelib_global.h"
#include
"plaintexteditmodifier.h"
#include
<texteditor/basetexteditor.h>
namespace
QmlDesigner
{
class
CORESHARED_EXPORT
BaseTextEditModifier
:
public
PlainTextEditModifier
{
public:
BaseTextEditModifier
(
QPlain
TextEdit
*
textEdit
);
BaseTextEditModifier
(
TextEditor
::
Base
TextEdit
or
*
textEdit
);
virtual
void
indent
(
int
offset
,
int
length
);
...
...
src/plugins/qmldesigner/core/include/plaintexteditmodifier.h
View file @
b0b893ac
...
...
@@ -66,6 +66,8 @@ public:
virtual
void
move
(
const
MoveInfo
&
moveInfo
);
virtual
void
indent
(
int
offset
,
int
length
)
=
0
;
virtual
int
indentDepth
()
const
=
0
;
virtual
void
startGroup
();
virtual
void
flushGroup
();
virtual
void
commitGroup
();
...
...
@@ -91,6 +93,20 @@ private:
bool
m_ongoingTextChange
;
};
class
CORESHARED_EXPORT
NotIndentingTextEditModifier
:
public
PlainTextEditModifier
{
public:
NotIndentingTextEditModifier
(
QPlainTextEdit
*
textEdit
)
:
PlainTextEditModifier
(
textEdit
)
{}
virtual
void
indent
(
int
/*offset*/
,
int
/*length*/
)
{}
virtual
int
indentDepth
()
const
{
return
0
;
}
};
}
#endif // PLAINTEXTEDITMODIFIER_H
src/plugins/qmldesigner/core/model/basetexteditmodifier.cpp
View file @
b0b893ac
...
...
@@ -29,12 +29,11 @@
#include
"basetexteditmodifier.h"
#include
<texteditor/basetexteditor.h>
#include
<texteditor/tabsettings.h>
using
namespace
QmlDesigner
;
BaseTextEditModifier
::
BaseTextEditModifier
(
QPlain
TextEdit
*
textEdit
)
:
BaseTextEditModifier
::
BaseTextEditModifier
(
TextEditor
::
Base
TextEdit
or
*
textEdit
)
:
PlainTextEditModifier
(
textEdit
)
{
}
...
...
@@ -44,9 +43,7 @@ void BaseTextEditModifier::indent(int offset, int length)
if
(
length
==
0
||
offset
<
0
||
offset
+
length
>=
text
().
length
())
return
;
// qDebug() << "PlainTextEditModifier::indent(" << offset << "," << length << ")";
if
(
TextEditor
::
BaseTextEditor
*
bte
=
dynamic_cast
<
TextEditor
::
BaseTextEditor
*>
(
plainTextEdit
()))
{
// qDebug() << "**** Doing indentation";
// find the applicable block:
QTextDocument
*
doc
=
bte
->
document
();
QTextCursor
tc
(
doc
);
...
...
@@ -55,8 +52,6 @@ void BaseTextEditModifier::indent(int offset, int length)
tc
.
setPosition
(
offset
+
length
,
QTextCursor
::
KeepAnchor
);
bte
->
indentInsertedText
(
tc
);
tc
.
endEditBlock
();
}
else
{
// qDebug() << "**** Skipping indentation";
}
}
...
...
@@ -65,7 +60,6 @@ int BaseTextEditModifier::indentDepth() const
if
(
TextEditor
::
BaseTextEditor
*
bte
=
dynamic_cast
<
TextEditor
::
BaseTextEditor
*>
(
plainTextEdit
()))
{
return
bte
->
tabSettings
().
m_indentSize
;
}
else
{
Q_ASSERT
(
false
&&
"BaseTextEditModifier does not have a BaseTextEditor"
);
return
0
;
}
}
src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp
View file @
b0b893ac
...
...
@@ -46,6 +46,8 @@ PlainTextEditModifier::PlainTextEditModifier(QPlainTextEdit *textEdit):
m_pendingChangeSignal
(
false
),
m_ongoingTextChange
(
false
)
{
Q_ASSERT
(
textEdit
);
connect
(
m_textEdit
,
SIGNAL
(
textChanged
()),
this
,
SLOT
(
textEditChanged
()));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment