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
Marco Bubke
flatpak-qt-creator
Commits
930cf34d
Commit
930cf34d
authored
Jan 18, 2011
by
Marco Bubke
Browse files
QmlDesigner.NodeInstances: Add synchronizing to instances
parent
f5636f88
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/designercore/designercore.pri
View file @
930cf34d
...
...
@@ -93,6 +93,7 @@ SOURCES += $$PWD/model/abstractview.cpp \
$$PWD/instances/changebindingscommand.cpp \
$$PWD/instances/changeidscommand.cpp \
$$PWD/instances/idcontainer.cpp \
$$PWD/instances/synchronizecommand.cpp \
$$PWD/instances/removeinstancescommand.cpp \
$$PWD/instances/removepropertiescommand.cpp \
$$PWD/instances/valueschangedcommand.cpp \
...
...
@@ -194,6 +195,7 @@ HEADERS += $$PWD/include/corelib_global.h \
$$PWD/instances/clearscenecommand.h \
$$PWD/instances/reparentcontainer.h \
$$PWD/instances/reparentinstancescommand.h \
$$PWD/instances/synchronizecommand.h \
$$PWD/instances/changevaluescommand.h \
$$PWD/instances/changebindingscommand.h \
$$PWD/instances/changeidscommand.h \
...
...
src/plugins/qmldesigner/designercore/include/nodeinstanceclientinterface.h
View file @
930cf34d
...
...
@@ -23,6 +23,7 @@ public:
virtual
void
componentCompleted
(
const
ComponentCompletedCommand
&
command
)
=
0
;
virtual
void
flush
()
{};
virtual
void
synchronizeWithClientProcess
()
{}
virtual
qint64
bytesToWrite
()
const
{
return
0
;}
};
...
...
src/plugins/qmldesigner/designercore/instances/instances.pri
View file @
930cf34d
...
...
@@ -3,6 +3,7 @@ INCLUDEPATH += $$PWD/../include
HEADERS += $$PWD/behaviornodeinstance.h
HEADERS += $$PWD/synchronizecommand.h
HEADERS += $$PWD/addimportcontainer.h
HEADERS += $$PWD/previewnodeinstanceserver.h
HEADERS += $$PWD/componentcompletedcommand.h
...
...
@@ -49,6 +50,7 @@ HEADERS += $$PWD/../include/nodeinstanceserverinterface.h
SOURCES += $$PWD/behaviornodeinstance.cpp
SOURCES += $$PWD/synchronizecommand.cpp
SOURCES += $$PWD/addimportcontainer.cpp
SOURCES += $$PWD/previewnodeinstanceserver.cpp
SOURCES += $$PWD/componentcompletedcommand.cpp
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp
View file @
930cf34d
...
...
@@ -25,6 +25,7 @@
#include
"changestatecommand.h"
#include
"addimportcommand.h"
#include
"completecomponentcommand.h"
#include
"synchronizecommand.h"
#include
"informationchangedcommand.h"
#include
"pixmapchangedcommand.h"
...
...
@@ -39,7 +40,8 @@ namespace QmlDesigner {
NodeInstanceClientProxy
::
NodeInstanceClientProxy
(
QObject
*
parent
)
:
QObject
(
parent
),
m_nodeInstanceServer
(
0
),
m_blockSize
(
0
)
m_blockSize
(
0
),
m_synchronizeId
(
-
1
)
{
if
(
QCoreApplication
::
arguments
().
at
(
2
)
==
QLatin1String
(
"previewmode"
))
{
m_nodeInstanceServer
=
new
PreviewNodeInstanceServer
(
this
);
...
...
@@ -101,6 +103,14 @@ void NodeInstanceClientProxy::flush()
{
}
void
NodeInstanceClientProxy
::
synchronizeWithClientProcess
()
{
if
(
m_synchronizeId
>=
0
)
{
SynchronizeCommand
synchronizeCommand
(
m_synchronizeId
);
writeCommand
(
QVariant
::
fromValue
(
synchronizeCommand
));
}
}
qint64
NodeInstanceClientProxy
::
bytesToWrite
()
const
{
return
m_socket
->
bytesToWrite
();
...
...
@@ -222,6 +232,7 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
static
const
int
changeStateCommandType
=
QMetaType
::
type
(
"ChangeStateCommand"
);
static
const
int
addImportCommandType
=
QMetaType
::
type
(
"AddImportCommand"
);
static
const
int
completeComponentCommandType
=
QMetaType
::
type
(
"CompleteComponentCommand"
);
static
const
int
synchronizeCommandType
=
QMetaType
::
type
(
"SynchronizeCommand"
);
if
(
command
.
userType
()
==
createInstancesCommandType
)
{
createInstances
(
command
.
value
<
CreateInstancesCommand
>
());
...
...
@@ -249,7 +260,10 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
addImport
(
command
.
value
<
AddImportCommand
>
());
else
if
(
command
.
userType
()
==
completeComponentCommandType
)
completeComponent
(
command
.
value
<
CompleteComponentCommand
>
());
else
else
if
(
command
.
userType
()
==
synchronizeCommandType
)
{
SynchronizeCommand
synchronizeCommand
=
command
.
value
<
SynchronizeCommand
>
();
m_synchronizeId
=
synchronizeCommand
.
synchronizeId
();
}
else
Q_ASSERT
(
false
);
}
}
// namespace QmlDesigner
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h
View file @
930cf34d
...
...
@@ -43,6 +43,7 @@ public:
void
componentCompleted
(
const
ComponentCompletedCommand
&
command
);
void
flush
();
void
synchronizeWithClientProcess
();
qint64
bytesToWrite
()
const
;
protected:
...
...
@@ -71,6 +72,7 @@ private:
QLocalSocket
*
m_socket
;
NodeInstanceServerInterface
*
m_nodeInstanceServer
;
quint32
m_blockSize
;
int
m_synchronizeId
;
};
}
// namespace QmlDesigner
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserver.cpp
View file @
930cf34d
...
...
@@ -958,6 +958,7 @@ void NodeInstanceServer::findItemChangesAndSendChangeCommands()
slowDownRenderTimer
();
nodeInstanceClient
()
->
flush
();
nodeInstanceClient
()
->
synchronizeWithClientProcess
();
}
inFunction
=
false
;
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverinterface.cpp
View file @
930cf34d
...
...
@@ -27,6 +27,7 @@
#include
"imagecontainer.h"
#include
"statepreviewimagechangedcommand.h"
#include
"componentcompletedcommand.h"
#include
"synchronizecommand.h"
namespace
QmlDesigner
{
...
...
@@ -129,6 +130,9 @@ void NodeInstanceServerInterface::registerCommands()
qRegisterMetaType
<
AddImportContainer
>
(
"AddImportContainer"
);
qRegisterMetaTypeStreamOperators
<
AddImportContainer
>
(
"AddImportContainer"
);
qRegisterMetaType
<
SynchronizeCommand
>
(
"SynchronizeCommand"
);
qRegisterMetaTypeStreamOperators
<
SynchronizeCommand
>
(
"SynchronizeCommand"
);
}
}
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
View file @
930cf34d
...
...
@@ -32,17 +32,21 @@
#include
"statepreviewimagechangedcommand.h"
#include
"componentcompletedcommand.h"
#include
"synchronizecommand.h"
#include
"nodeinstanceview.h"
#include
"nodeinstanceclientproxy.h"
namespace
QmlDesigner
{
NodeInstanceServerProxy
::
NodeInstanceServerProxy
(
NodeInstanceView
*
nodeInstanceView
)
NodeInstanceServerProxy
::
NodeInstanceServerProxy
(
NodeInstanceView
*
nodeInstanceView
,
RunModus
runModus
)
:
NodeInstanceServerInterface
(
nodeInstanceView
),
m_localServer
(
new
QLocalServer
(
this
)),
m_nodeInstanceView
(
nodeInstanceView
),
m_firstBlockSize
(
0
),
m_secondBlockSize
(
0
)
m_secondBlockSize
(
0
),
m_runModus
(
runModus
),
m_synchronizeId
(
-
1
)
{
QString
socketToken
(
QUuid
::
createUuid
().
toString
());
...
...
@@ -60,17 +64,22 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_qmlPuppetEditorProcess
->
setProcessChannelMode
(
QProcess
::
ForwardedChannels
);
m_qmlPuppetEditorProcess
->
start
(
applicationPath
,
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
(
applicationPath
,
QStringList
()
<<
socketToken
<<
"previewmode"
<<
"-graphicssystem raster"
);
if
(
runModus
==
NormalModus
)
{
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
(
applicationPath
,
QStringList
()
<<
socketToken
<<
"previewmode"
<<
"-graphicssystem raster"
);
}
connect
(
QCoreApplication
::
instance
(),
SIGNAL
(
aboutToQuit
()),
this
,
SLOT
(
deleteLater
()));
m_qmlPuppetPreviewProcess
->
waitForStarted
();
m_qmlPuppetEditorProcess
->
waitForStarted
();
Q_ASSERT
(
m_qmlPuppetEditorProcess
->
state
()
==
QProcess
::
Running
);
Q_ASSERT
(
m_qmlPuppetPreviewProcess
->
state
()
==
QProcess
::
Running
);
if
(
runModus
==
NormalModus
)
{
m_qmlPuppetPreviewProcess
->
waitForStarted
();
Q_ASSERT
(
m_qmlPuppetPreviewProcess
->
state
()
==
QProcess
::
Running
);
}
if
(
!
m_localServer
->
hasPendingConnections
())
m_localServer
->
waitForNewConnection
(
-
1
);
...
...
@@ -79,12 +88,14 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
Q_ASSERT
(
m_firstSocket
);
connect
(
m_firstSocket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readFirstDataStream
()));
if
(
!
m_localServer
->
hasPendingConnections
())
m_localServer
->
waitForNewConnection
(
-
1
);
if
(
runModus
==
NormalModus
)
{
if
(
!
m_localServer
->
hasPendingConnections
())
m_localServer
->
waitForNewConnection
(
-
1
);
m_secondSocket
=
m_localServer
->
nextPendingConnection
();
Q_ASSERT
(
m_secondSocket
);
connect
(
m_secondSocket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readSecondDataStream
()));
m_secondSocket
=
m_localServer
->
nextPendingConnection
();
Q_ASSERT
(
m_secondSocket
);
connect
(
m_secondSocket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readSecondDataStream
()));
}
m_localServer
->
close
();
}
...
...
@@ -117,6 +128,7 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
static
const
int
childrenChangedCommandType
=
QMetaType
::
type
(
"ChildrenChangedCommand"
);
static
const
int
statePreviewImageChangedCommandType
=
QMetaType
::
type
(
"StatePreviewImageChangedCommand"
);
static
const
int
componentCompletedCommandType
=
QMetaType
::
type
(
"ComponentCompletedCommand"
);
static
const
int
synchronizeCommandType
=
QMetaType
::
type
(
"SynchronizeCommand"
);
if
(
command
.
userType
()
==
informationChangedCommandType
)
nodeInstanceClient
()
->
informationChanged
(
command
.
value
<
InformationChangedCommand
>
());
...
...
@@ -130,7 +142,10 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
nodeInstanceClient
()
->
statePreviewImagesChanged
(
command
.
value
<
StatePreviewImageChangedCommand
>
());
else
if
(
command
.
userType
()
==
componentCompletedCommandType
)
nodeInstanceClient
()
->
componentCompleted
(
command
.
value
<
ComponentCompletedCommand
>
());
else
else
if
(
command
.
userType
()
==
synchronizeCommandType
)
{
SynchronizeCommand
synchronizeCommand
=
command
.
value
<
SynchronizeCommand
>
();
m_synchronizeId
=
synchronizeCommand
.
synchronizeId
();
}
else
Q_ASSERT
(
false
);
}
...
...
@@ -141,28 +156,44 @@ NodeInstanceClientInterface *NodeInstanceServerProxy::nodeInstanceClient() const
static
void
writeCommandToSocket
(
const
QVariant
&
command
,
QLocalSocket
*
socket
)
{
Q_ASSERT
(
socket
)
;
Q
ByteArray
block
;
QDataStream
out
(
&
block
,
QIODevice
::
WriteOnly
);
out
<<
quint32
(
0
)
;
out
<<
command
;
out
.
device
()
->
seek
(
0
);
out
<<
quint32
(
block
.
size
()
-
sizeof
(
quint32
));
socket
->
write
(
block
);
if
(
socket
)
{
QByteArray
block
;
Q
DataStream
out
(
&
block
,
QIODevice
::
WriteOnly
)
;
out
<<
quint32
(
0
);
out
<<
command
;
out
.
device
()
->
seek
(
0
)
;
out
<<
quint32
(
block
.
size
()
-
sizeof
(
quint32
)
);
socket
->
write
(
block
);
}
}
void
NodeInstanceServerProxy
::
writeCommand
(
const
QVariant
&
command
)
{
writeCommandToSocket
(
command
,
m_firstSocket
.
data
());
writeCommandToSocket
(
command
,
m_secondSocket
.
data
());
if
(
m_runModus
==
TestModus
)
{
static
int
synchronizeId
=
0
;
synchronizeId
++
;
SynchronizeCommand
synchronizeCommand
(
synchronizeId
);
writeCommandToSocket
(
QVariant
::
fromValue
(
synchronizeCommand
),
m_firstSocket
.
data
());
while
(
m_firstSocket
->
waitForReadyRead
())
{
readFirstDataStream
();
if
(
m_synchronizeId
==
synchronizeId
)
return
;
}
}
}
void
NodeInstanceServerProxy
::
processFinished
(
int
/*exitCode*/
,
QProcess
::
ExitStatus
exitStatus
)
{
m_firstSocket
->
close
();
m_secondSocket
->
close
();
if
(
m_firstSocket
)
m_firstSocket
->
close
();
if
(
m_secondSocket
)
m_secondSocket
->
close
();
if
(
exitStatus
==
QProcess
::
CrashExit
)
emit
processCrashed
();
}
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
View file @
930cf34d
...
...
@@ -23,7 +23,13 @@ class NodeInstanceServerProxy : public NodeInstanceServerInterface
{
Q_OBJECT
public:
explicit
NodeInstanceServerProxy
(
NodeInstanceView
*
nodeInstanceView
);
enum
RunModus
{
NormalModus
,
TestModus
// No preview images and synchronized
};
explicit
NodeInstanceServerProxy
(
NodeInstanceView
*
nodeInstanceView
,
RunModus
runModus
=
NormalModus
);
~
NodeInstanceServerProxy
();
void
createInstances
(
const
CreateInstancesCommand
&
command
);
void
changeFileUrl
(
const
ChangeFileUrlCommand
&
command
);
...
...
@@ -61,6 +67,8 @@ private:
QWeakPointer
<
QProcess
>
m_qmlPuppetPreviewProcess
;
quint32
m_firstBlockSize
;
quint32
m_secondBlockSize
;
RunModus
m_runModus
;
int
m_synchronizeId
;
};
}
// namespace QmlDesigner
...
...
src/plugins/qmldesigner/designercore/instances/synchronizecommand.cpp
0 → 100644
View file @
930cf34d
#include
"synchronizecommand.h"
namespace
QmlDesigner
{
SynchronizeCommand
::
SynchronizeCommand
()
:
m_synchronizeId
(
-
1
)
{
}
SynchronizeCommand
::
SynchronizeCommand
(
int
synchronizeId
)
:
m_synchronizeId
(
synchronizeId
)
{
}
int
SynchronizeCommand
::
synchronizeId
()
const
{
return
m_synchronizeId
;
}
QDataStream
&
operator
<<
(
QDataStream
&
out
,
const
SynchronizeCommand
&
command
)
{
out
<<
command
.
synchronizeId
();
return
out
;
}
QDataStream
&
operator
>>
(
QDataStream
&
in
,
SynchronizeCommand
&
command
)
{
in
>>
command
.
m_synchronizeId
;
return
in
;
}
}
// namespace QmlDesigner
src/plugins/qmldesigner/designercore/instances/synchronizecommand.h
0 → 100644
View file @
930cf34d
#ifndef SYNCHRONIZECOMMAND_H
#define SYNCHRONIZECOMMAND_H
#include
<QMetaType>
#include
<QVector>
#include
"propertyvaluecontainer.h"
namespace
QmlDesigner
{
class
SynchronizeCommand
{
friend
QDataStream
&
operator
>>
(
QDataStream
&
in
,
SynchronizeCommand
&
command
);
public:
SynchronizeCommand
();
SynchronizeCommand
(
int
synchronizeId
);
int
synchronizeId
()
const
;
private:
int
m_synchronizeId
;
};
QDataStream
&
operator
<<
(
QDataStream
&
out
,
const
SynchronizeCommand
&
command
);
QDataStream
&
operator
>>
(
QDataStream
&
in
,
SynchronizeCommand
&
command
);
}
// namespace QmlDesigner
Q_DECLARE_METATYPE
(
QmlDesigner
::
SynchronizeCommand
)
#endif // SYNCHRONIZECOMMAND_H
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