Skip to content
GitLab
Menu
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
f40dbe19
Commit
f40dbe19
authored
Jan 12, 2011
by
Marco Bubke
Browse files
QmlDesigner.NodeInstances: Extra process for state previews
Much faster.
parent
ffc241b7
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp
View file @
f40dbe19
...
...
@@ -38,10 +38,15 @@ namespace QmlDesigner {
NodeInstanceClientProxy
::
NodeInstanceClientProxy
(
QObject
*
parent
)
:
QObject
(
parent
),
m_nodeInstanceServer
(
new
NodeInstanceServer
(
this
)),
m_stateNodeInstancePreview
(
new
PreviewNodeInstanceServer
(
this
)),
m_nodeInstanceServer
(
0
),
m_blockSize
(
0
)
{
if
(
QCoreApplication
::
arguments
().
at
(
2
)
==
QLatin1String
(
"previewmode"
))
{
m_nodeInstanceServer
=
new
PreviewNodeInstanceServer
(
this
);
}
else
if
(
QCoreApplication
::
arguments
().
at
(
2
)
==
QLatin1String
(
"editormode"
))
{
m_nodeInstanceServer
=
new
NodeInstanceServer
(
this
);
}
m_socket
=
new
QLocalSocket
(
this
);
connect
(
m_socket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readDataStream
()));
connect
(
m_socket
,
SIGNAL
(
error
(
QLocalSocket
::
LocalSocketError
)),
QCoreApplication
::
instance
(),
SLOT
(
quit
()));
...
...
@@ -132,11 +137,6 @@ void NodeInstanceClientProxy::readDataStream()
}
}
NodeInstanceServerInterface
*
NodeInstanceClientProxy
::
stateNodeInstancePreview
()
const
{
return
m_stateNodeInstancePreview
;
}
NodeInstanceServerInterface
*
NodeInstanceClientProxy
::
nodeInstanceServer
()
const
{
return
m_nodeInstanceServer
;
...
...
@@ -145,61 +145,51 @@ NodeInstanceServerInterface *NodeInstanceClientProxy::nodeInstanceServer() const
void
NodeInstanceClientProxy
::
createInstances
(
const
CreateInstancesCommand
&
command
)
{
nodeInstanceServer
()
->
createInstances
(
command
);
stateNodeInstancePreview
()
->
createInstances
(
command
);
}
void
NodeInstanceClientProxy
::
changeFileUrl
(
const
ChangeFileUrlCommand
&
command
)
{
nodeInstanceServer
()
->
changeFileUrl
(
command
);
stateNodeInstancePreview
()
->
changeFileUrl
(
command
);
}
void
NodeInstanceClientProxy
::
createScene
(
const
CreateSceneCommand
&
command
)
{
nodeInstanceServer
()
->
createScene
(
command
);
stateNodeInstancePreview
()
->
createScene
(
command
);
}
void
NodeInstanceClientProxy
::
clearScene
(
const
ClearSceneCommand
&
command
)
{
nodeInstanceServer
()
->
clearScene
(
command
);
stateNodeInstancePreview
()
->
clearScene
(
command
);
}
void
NodeInstanceClientProxy
::
removeInstances
(
const
RemoveInstancesCommand
&
command
)
{
nodeInstanceServer
()
->
removeInstances
(
command
);
stateNodeInstancePreview
()
->
removeInstances
(
command
);
}
void
NodeInstanceClientProxy
::
removeProperties
(
const
RemovePropertiesCommand
&
command
)
{
nodeInstanceServer
()
->
removeProperties
(
command
);
stateNodeInstancePreview
()
->
removeProperties
(
command
);
}
void
NodeInstanceClientProxy
::
changePropertyBindings
(
const
ChangeBindingsCommand
&
command
)
{
nodeInstanceServer
()
->
changePropertyBindings
(
command
);
stateNodeInstancePreview
()
->
changePropertyBindings
(
command
);
}
void
NodeInstanceClientProxy
::
changePropertyValues
(
const
ChangeValuesCommand
&
command
)
{
nodeInstanceServer
()
->
changePropertyValues
(
command
);
stateNodeInstancePreview
()
->
changePropertyValues
(
command
);
}
void
NodeInstanceClientProxy
::
reparentInstances
(
const
ReparentInstancesCommand
&
command
)
{
nodeInstanceServer
()
->
reparentInstances
(
command
);
stateNodeInstancePreview
()
->
reparentInstances
(
command
);
}
void
NodeInstanceClientProxy
::
changeIds
(
const
ChangeIdsCommand
&
command
)
{
nodeInstanceServer
()
->
changeIds
(
command
);
stateNodeInstancePreview
()
->
changeIds
(
command
);
}
void
NodeInstanceClientProxy
::
changeState
(
const
ChangeStateCommand
&
command
)
...
...
@@ -210,13 +200,11 @@ void NodeInstanceClientProxy::changeState(const ChangeStateCommand &command)
void
NodeInstanceClientProxy
::
addImport
(
const
AddImportCommand
&
command
)
{
nodeInstanceServer
()
->
addImport
(
command
);
stateNodeInstancePreview
()
->
addImport
(
command
);
}
void
NodeInstanceClientProxy
::
completeComponent
(
const
CompleteComponentCommand
&
command
)
{
nodeInstanceServer
()
->
completeComponent
(
command
);
stateNodeInstancePreview
()
->
completeComponent
(
command
);
}
void
NodeInstanceClientProxy
::
dispatchCommand
(
const
QVariant
&
command
)
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h
View file @
f40dbe19
...
...
@@ -49,7 +49,6 @@ protected:
void
writeCommand
(
const
QVariant
&
command
);
void
dispatchCommand
(
const
QVariant
&
command
);
NodeInstanceServerInterface
*
nodeInstanceServer
()
const
;
NodeInstanceServerInterface
*
stateNodeInstancePreview
()
const
;
void
createInstances
(
const
CreateInstancesCommand
&
command
);
void
changeFileUrl
(
const
ChangeFileUrlCommand
&
command
);
...
...
@@ -71,7 +70,6 @@ private slots:
private:
QLocalSocket
*
m_socket
;
NodeInstanceServerInterface
*
m_nodeInstanceServer
;
NodeInstanceServerInterface
*
m_stateNodeInstancePreview
;
quint32
m_blockSize
;
};
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
View file @
f40dbe19
...
...
@@ -41,38 +41,65 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
:
NodeInstanceServerInterface
(
nodeInstanceView
),
m_localServer
(
new
QLocalServer
(
this
)),
m_nodeInstanceView
(
nodeInstanceView
),
m_blockSize
(
0
)
m_firstBlockSize
(
0
),
m_secondBlockSize
(
0
)
{
QString
socketToken
(
QUuid
::
createUuid
().
toString
());
m_localServer
->
listen
(
socketToken
);
m_localServer
->
setMaxPendingConnections
(
1
);
m_localServer
->
setMaxPendingConnections
(
2
);
m_qmlPuppetEditorProcess
=
new
QProcess
(
QCoreApplication
::
instance
());
connect
(
m_qmlPuppetEditorProcess
.
data
(),
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
processFinished
(
int
,
QProcess
::
ExitStatus
)));
m_qmlPuppetEditorProcess
->
setProcessChannelMode
(
QProcess
::
ForwardedChannels
);
m_qmlPuppetEditorProcess
->
start
(
QString
(
"%1/%2"
).
arg
(
QCoreApplication
::
applicationDirPath
()).
arg
(
"qmlpuppet"
),
QStringList
()
<<
socketToken
<<
"editormode"
<<
"-graphicssystem raster"
);
m_qmlPuppetPreviewProcess
=
new
QProcess
(
QCoreApplication
::
instance
());
connect
(
m_qmlPuppetPreviewProcess
.
data
(),
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
processFinished
(
int
,
QProcess
::
ExitStatus
)));
m_qmlPuppetPreviewProcess
->
setProcessChannelMode
(
QProcess
::
ForwardedChannels
);
m_qmlPuppetPreviewProcess
->
start
(
QString
(
"%1/%2"
).
arg
(
QCoreApplication
::
applicationDirPath
()).
arg
(
"qmlpuppet"
),
QStringList
()
<<
socketToken
<<
"previewmode"
<<
"-graphicssystem raster"
);
m_qmlPuppetProcess
=
new
QProcess
(
QCoreApplication
::
instance
());
connect
(
m_qmlPuppetProcess
.
data
(),
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
processFinished
(
int
,
QProcess
::
ExitStatus
)));
m_qmlPuppetProcess
->
setProcessChannelMode
(
QProcess
::
ForwardedChannels
);
m_qmlPuppetProcess
->
start
(
QString
(
"%1/%2"
).
arg
(
QCoreApplication
::
applicationDirPath
()).
arg
(
"qmlpuppet"
),
QStringList
()
<<
socketToken
<<
"-graphicssystem raster"
);
connect
(
QCoreApplication
::
instance
(),
SIGNAL
(
aboutToQuit
()),
this
,
SLOT
(
deleteLater
()));
m_qmlPuppetProcess
->
waitForStarted
();
Q_ASSERT
(
m_qmlPuppetProcess
->
state
()
==
QProcess
::
Running
);
m_qmlPuppetPreviewProcess
->
waitForStarted
();
m_qmlPuppetEditorProcess
->
waitForStarted
();
Q_ASSERT
(
m_qmlPuppetEditorProcess
->
state
()
==
QProcess
::
Running
);
Q_ASSERT
(
m_qmlPuppetPreviewProcess
->
state
()
==
QProcess
::
Running
);
if
(
!
m_localServer
->
hasPendingConnections
())
m_localServer
->
waitForNewConnection
(
-
1
);
m_firstSocket
=
m_localServer
->
nextPendingConnection
();
Q_ASSERT
(
m_firstSocket
);
connect
(
m_firstSocket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readFirstDataStream
()));
if
(
!
m_localServer
->
hasPendingConnections
())
m_localServer
->
waitForNewConnection
(
-
1
);
m_socket
=
m_localServer
->
nextPendingConnection
();
Q_ASSERT
(
m_socket
);
connect
(
m_socket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readDataStream
()));
m_secondSocket
=
m_localServer
->
nextPendingConnection
();
Q_ASSERT
(
m_secondSocket
);
connect
(
m_secondSocket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readSecondDataStream
()));
m_localServer
->
close
();
}
NodeInstanceServerProxy
::~
NodeInstanceServerProxy
()
{
if
(
m_socket
)
m_socket
->
close
();
if
(
m_firstSocket
)
m_firstSocket
->
close
();
if
(
m_secondSocket
)
m_secondSocket
->
close
();
if
(
m_qmlPuppetProcess
)
{
m_qmlPuppetProcess
->
blockSignals
(
true
);
m_qmlPuppetProcess
->
kill
();
if
(
m_qmlPuppetEditorProcess
)
{
m_qmlPuppetEditorProcess
->
blockSignals
(
true
);
m_qmlPuppetEditorProcess
->
kill
();
}
if
(
m_qmlPuppetPreviewProcess
)
{
m_qmlPuppetPreviewProcess
->
blockSignals
(
true
);
m_qmlPuppetPreviewProcess
->
kill
();
}
}
...
...
@@ -106,9 +133,9 @@ NodeInstanceClientInterface *NodeInstanceServerProxy::nodeInstanceClient() const
return
m_nodeInstanceView
.
data
();
}
void
NodeInstanceServerProxy
::
writeCommand
(
const
QVariant
&
command
)
static
void
writeCommand
ToSocket
(
const
QVariant
&
command
,
QLocalSocket
*
socket
)
{
Q_ASSERT
(
m_
socket
.
data
()
);
Q_ASSERT
(
socket
);
QByteArray
block
;
QDataStream
out
(
&
block
,
QIODevice
::
WriteOnly
);
...
...
@@ -117,36 +144,74 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command)
out
.
device
()
->
seek
(
0
);
out
<<
quint32
(
block
.
size
()
-
sizeof
(
quint32
));
m_socket
->
write
(
block
);
socket
->
write
(
block
);
}
void
NodeInstanceServerProxy
::
writeCommand
(
const
QVariant
&
command
)
{
writeCommandToSocket
(
command
,
m_firstSocket
.
data
());
writeCommandToSocket
(
command
,
m_secondSocket
.
data
());
}
void
NodeInstanceServerProxy
::
processFinished
(
int
/*exitCode*/
,
QProcess
::
ExitStatus
/* exitStatus */
)
{
m_socket
->
close
();
m_firstSocket
->
close
();
m_secondSocket
->
close
();
emit
processCrashed
();
}
void
NodeInstanceServerProxy
::
readDataStream
()
void
NodeInstanceServerProxy
::
readFirstDataStream
()
{
QList
<
QVariant
>
commandList
;
while
(
!
m_firstSocket
->
atEnd
())
{
if
(
m_firstSocket
->
bytesAvailable
()
<
int
(
sizeof
(
quint32
)))
break
;
QDataStream
in
(
m_firstSocket
.
data
());
if
(
m_firstBlockSize
==
0
)
{
in
>>
m_firstBlockSize
;
}
if
(
m_firstSocket
->
bytesAvailable
()
<
m_firstBlockSize
)
break
;
QVariant
command
;
in
>>
command
;
m_firstBlockSize
=
0
;
Q_ASSERT
(
in
.
status
()
==
QDataStream
::
Ok
);
commandList
.
append
(
command
);
}
foreach
(
const
QVariant
&
command
,
commandList
)
{
dispatchCommand
(
command
);
}
}
void
NodeInstanceServerProxy
::
readSecondDataStream
()
{
QList
<
QVariant
>
commandList
;
while
(
!
m_socket
->
atEnd
())
{
if
(
m_socket
->
bytesAvailable
()
<
int
(
sizeof
(
quint32
)))
while
(
!
m_s
econdS
ocket
->
atEnd
())
{
if
(
m_s
econdS
ocket
->
bytesAvailable
()
<
int
(
sizeof
(
quint32
)))
break
;
QDataStream
in
(
m_socket
.
data
());
QDataStream
in
(
m_s
econdS
ocket
.
data
());
if
(
m_
b
lockSize
==
0
)
{
in
>>
m_
b
lockSize
;
if
(
m_
secondB
lockSize
==
0
)
{
in
>>
m_
secondB
lockSize
;
}
if
(
m_socket
->
bytesAvailable
()
<
m_
b
lockSize
)
if
(
m_s
econdS
ocket
->
bytesAvailable
()
<
m_
secondB
lockSize
)
break
;
QVariant
command
;
in
>>
command
;
m_
b
lockSize
=
0
;
m_
secondB
lockSize
=
0
;
Q_ASSERT
(
in
.
status
()
==
QDataStream
::
Ok
);
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
View file @
f40dbe19
...
...
@@ -49,14 +49,18 @@ signals:
private
slots
:
void
processFinished
(
int
exitCode
,
QProcess
::
ExitStatus
exitStatus
);
void
readDataStream
();
void
readFirstDataStream
();
void
readSecondDataStream
();
private:
QWeakPointer
<
QLocalServer
>
m_localServer
;
QWeakPointer
<
QLocalSocket
>
m_socket
;
QWeakPointer
<
QLocalSocket
>
m_firstSocket
;
QWeakPointer
<
QLocalSocket
>
m_secondSocket
;
QWeakPointer
<
NodeInstanceView
>
m_nodeInstanceView
;
QWeakPointer
<
QProcess
>
m_qmlPuppetProcess
;
quint32
m_blockSize
;
QWeakPointer
<
QProcess
>
m_qmlPuppetEditorProcess
;
QWeakPointer
<
QProcess
>
m_qmlPuppetPreviewProcess
;
quint32
m_firstBlockSize
;
quint32
m_secondBlockSize
;
};
}
// namespace QmlDesigner
...
...
src/tools/qmlpuppet/main.cpp
View file @
f40dbe19
...
...
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
{
QApplication
application
(
argc
,
argv
);
if
(
application
.
arguments
().
count
()
!=
3
)
if
(
application
.
arguments
().
count
()
!=
4
)
return
-
1
;
QCoreApplication
::
setOrganizationName
(
"Nokia"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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