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
Marco Bubke
flatpak-qt-creator
Commits
62d66fcd
Commit
62d66fcd
authored
Jan 06, 2011
by
Marco Bubke
Browse files
QmlDesigner.NodeInstances: Remove slow socket
The two socket approach don't worked under windows and mac.
parent
8b86085a
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp
View file @
62d66fcd
...
...
@@ -42,19 +42,15 @@ NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent)
m_baseStateNodeInstancePreview
(
new
PreviewNodeInstanceServer
(
this
)),
m_blockSize
(
0
)
{
m_slowSocket
=
new
QLocalSocket
(
this
);
m_slowSocket
->
connectToServer
(
QCoreApplication
::
arguments
().
at
(
1
),
QIODevice
::
ReadWrite
|
QIODevice
::
Unbuffered
);
m_slowSocket
->
waitForConnected
(
-
1
);
m_fastSocket
=
new
QLocalSocket
(
this
);
connect
(
m_fastSocket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readDataStream
()));
connect
(
m_fastSocket
,
SIGNAL
(
error
(
QLocalSocket
::
LocalSocketError
)),
QCoreApplication
::
instance
(),
SLOT
(
quit
()));
connect
(
m_fastSocket
,
SIGNAL
(
disconnected
()),
QCoreApplication
::
instance
(),
SLOT
(
quit
()));
m_fastSocket
->
connectToServer
(
QCoreApplication
::
arguments
().
at
(
1
),
QIODevice
::
ReadWrite
|
QIODevice
::
Unbuffered
);
m_fastSocket
->
waitForConnected
(
-
1
);
m_socket
=
new
QLocalSocket
(
this
);
connect
(
m_socket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readDataStream
()));
connect
(
m_socket
,
SIGNAL
(
error
(
QLocalSocket
::
LocalSocketError
)),
QCoreApplication
::
instance
(),
SLOT
(
quit
()));
connect
(
m_socket
,
SIGNAL
(
disconnected
()),
QCoreApplication
::
instance
(),
SLOT
(
quit
()));
m_socket
->
connectToServer
(
QCoreApplication
::
arguments
().
at
(
1
),
QIODevice
::
ReadWrite
|
QIODevice
::
Unbuffered
);
m_socket
->
waitForConnected
(
-
1
);
}
void
NodeInstanceClientProxy
::
write
Slow
Command
(
const
QVariant
&
command
)
void
NodeInstanceClientProxy
::
writeCommand
(
const
QVariant
&
command
)
{
QByteArray
block
;
QDataStream
out
(
&
block
,
QIODevice
::
WriteOnly
);
...
...
@@ -63,49 +59,37 @@ void NodeInstanceClientProxy::writeSlowCommand(const QVariant &command)
out
.
device
()
->
seek
(
0
);
out
<<
quint32
(
block
.
size
()
-
sizeof
(
quint32
));
m_slowSocket
->
write
(
block
);
}
void
NodeInstanceClientProxy
::
writeFastCommand
(
const
QVariant
&
command
)
{
QByteArray
block
;
QDataStream
out
(
&
block
,
QIODevice
::
WriteOnly
);
out
<<
quint32
(
0
);
out
<<
command
;
out
.
device
()
->
seek
(
0
);
out
<<
quint32
(
block
.
size
()
-
sizeof
(
quint32
));
m_fastSocket
->
write
(
block
);
m_socket
->
write
(
block
);
}
void
NodeInstanceClientProxy
::
informationChanged
(
const
InformationChangedCommand
&
command
)
{
write
Fast
Command
(
QVariant
::
fromValue
(
command
));
writeCommand
(
QVariant
::
fromValue
(
command
));
}
void
NodeInstanceClientProxy
::
valuesChanged
(
const
ValuesChangedCommand
&
command
)
{
write
Fast
Command
(
QVariant
::
fromValue
(
command
));
writeCommand
(
QVariant
::
fromValue
(
command
));
}
void
NodeInstanceClientProxy
::
pixmapChanged
(
const
PixmapChangedCommand
&
command
)
{
write
Slow
Command
(
QVariant
::
fromValue
(
command
));
writeCommand
(
QVariant
::
fromValue
(
command
));
}
void
NodeInstanceClientProxy
::
childrenChanged
(
const
ChildrenChangedCommand
&
command
)
{
write
Fast
Command
(
QVariant
::
fromValue
(
command
));
writeCommand
(
QVariant
::
fromValue
(
command
));
}
void
NodeInstanceClientProxy
::
statePreviewImagesChanged
(
const
StatePreviewImageChangedCommand
&
command
)
{
write
Slow
Command
(
QVariant
::
fromValue
(
command
));
writeCommand
(
QVariant
::
fromValue
(
command
));
}
void
NodeInstanceClientProxy
::
componentCompleted
(
const
ComponentCompletedCommand
&
command
)
{
write
Fast
Command
(
QVariant
::
fromValue
(
command
));
writeCommand
(
QVariant
::
fromValue
(
command
));
}
void
NodeInstanceClientProxy
::
flush
()
...
...
@@ -114,24 +98,24 @@ void NodeInstanceClientProxy::flush()
qint64
NodeInstanceClientProxy
::
bytesToWrite
()
const
{
return
m_s
lowS
ocket
->
bytesToWrite
();
return
m_socket
->
bytesToWrite
();
}
void
NodeInstanceClientProxy
::
readDataStream
()
{
QList
<
QVariant
>
commandList
;
while
(
!
m_
fastS
ocket
->
atEnd
())
{
if
(
m_
fastS
ocket
->
bytesAvailable
()
<
int
(
sizeof
(
quint32
)))
while
(
!
m_
s
ocket
->
atEnd
())
{
if
(
m_
s
ocket
->
bytesAvailable
()
<
int
(
sizeof
(
quint32
)))
break
;
QDataStream
in
(
m_
fastS
ocket
);
QDataStream
in
(
m_
s
ocket
);
if
(
m_blockSize
==
0
)
{
in
>>
m_blockSize
;
}
if
(
m_
fastS
ocket
->
bytesAvailable
()
<
m_blockSize
)
if
(
m_
s
ocket
->
bytesAvailable
()
<
m_blockSize
)
break
;
QVariant
command
;
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h
View file @
62d66fcd
...
...
@@ -46,10 +46,10 @@ public:
qint64
bytesToWrite
()
const
;
protected:
void
writeSlowCommand
(
const
QVariant
&
command
);
void
writeFastCommand
(
const
QVariant
&
command
);
void
writeCommand
(
const
QVariant
&
command
);
void
dispatchCommand
(
const
QVariant
&
command
);
NodeInstanceServerInterface
*
nodeInstanceServer
()
const
;
NodeInstanceServerInterface
*
baseStateNodeInstancePreview
()
const
;
void
createInstances
(
const
CreateInstancesCommand
&
command
);
void
changeFileUrl
(
const
ChangeFileUrlCommand
&
command
);
...
...
@@ -69,8 +69,7 @@ private slots:
void
readDataStream
();
private:
QLocalSocket
*
m_slowSocket
;
QLocalSocket
*
m_fastSocket
;
QLocalSocket
*
m_socket
;
NodeInstanceServerInterface
*
m_nodeInstanceServer
;
NodeInstanceServerInterface
*
m_baseStateNodeInstancePreview
;
QHash
<
qint32
,
QWeakPointer
<
NodeInstanceServerInterface
>
>
m_nodeInstancePreviewVector
;
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
View file @
62d66fcd
...
...
@@ -41,8 +41,7 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
:
NodeInstanceServerInterface
(
nodeInstanceView
),
m_localServer
(
new
QLocalServer
(
this
)),
m_nodeInstanceView
(
nodeInstanceView
),
m_slowBlockSize
(
0
),
m_fastBlockSize
(
0
)
m_blockSize
(
0
)
{
QString
socketToken
(
QUuid
::
createUuid
().
toString
());
...
...
@@ -60,16 +59,9 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
if
(
!
m_localServer
->
hasPendingConnections
())
m_localServer
->
waitForNewConnection
(
-
1
);
m_slowSocket
=
m_localServer
->
nextPendingConnection
();
Q_ASSERT
(
m_slowSocket
);
connect
(
m_slowSocket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readSlowDataStream
()));
if
(
!
m_localServer
->
hasPendingConnections
())
m_localServer
->
waitForNewConnection
(
-
1
);
m_fastSocket
=
m_localServer
->
nextPendingConnection
();
Q_ASSERT
(
m_fastSocket
);
connect
(
m_fastSocket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readFastDataStream
()));
m_socket
=
m_localServer
->
nextPendingConnection
();
Q_ASSERT
(
m_socket
);
connect
(
m_socket
.
data
(),
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readDataStream
()));
m_localServer
->
close
();
}
...
...
@@ -113,12 +105,12 @@ NodeInstanceClientInterface *NodeInstanceServerProxy::nodeInstanceClient() const
void
NodeInstanceServerProxy
::
setBlockUpdates
(
bool
block
)
{
m_s
lowS
ocket
->
blockSignals
(
block
);
m_socket
->
blockSignals
(
block
);
}
void
NodeInstanceServerProxy
::
writeCommand
(
const
QVariant
&
command
)
{
Q_ASSERT
(
m_
fastS
ocket
.
data
());
Q_ASSERT
(
m_
s
ocket
.
data
());
QByteArray
block
;
QDataStream
out
(
&
block
,
QIODevice
::
WriteOnly
);
...
...
@@ -127,67 +119,36 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command)
out
.
device
()
->
seek
(
0
);
out
<<
quint32
(
block
.
size
()
-
sizeof
(
quint32
));
m_
fastS
ocket
->
write
(
block
);
m_
s
ocket
->
write
(
block
);
}
void
NodeInstanceServerProxy
::
processFinished
(
int
/*exitCode*/
,
QProcess
::
ExitStatus
/* exitStatus */
)
{
m_s
lowS
ocket
->
close
();
m_socket
->
close
();
emit
processCrashed
();
}
void
NodeInstanceServerProxy
::
readFastDataStream
()
{
QList
<
QVariant
>
commandList
;
while
(
!
m_fastSocket
->
atEnd
())
{
if
(
m_fastSocket
->
bytesAvailable
()
<
int
(
sizeof
(
quint32
)))
break
;
QDataStream
in
(
m_fastSocket
.
data
());
if
(
m_fastBlockSize
==
0
)
{
in
>>
m_fastBlockSize
;
}
if
(
m_fastSocket
->
bytesAvailable
()
<
m_fastBlockSize
)
break
;
QVariant
command
;
in
>>
command
;
m_fastBlockSize
=
0
;
Q_ASSERT
(
in
.
status
()
==
QDataStream
::
Ok
);
commandList
.
append
(
command
);
}
foreach
(
const
QVariant
&
command
,
commandList
)
{
dispatchCommand
(
command
);
}
}
void
NodeInstanceServerProxy
::
readSlowDataStream
()
void
NodeInstanceServerProxy
::
readDataStream
()
{
QList
<
QVariant
>
commandList
;
while
(
!
m_s
lowS
ocket
->
atEnd
())
{
if
(
m_s
lowS
ocket
->
bytesAvailable
()
<
int
(
sizeof
(
quint32
)))
while
(
!
m_socket
->
atEnd
())
{
if
(
m_socket
->
bytesAvailable
()
<
int
(
sizeof
(
quint32
)))
break
;
QDataStream
in
(
m_s
lowS
ocket
.
data
());
QDataStream
in
(
m_socket
.
data
());
if
(
m_
slowB
lockSize
==
0
)
{
in
>>
m_
slowB
lockSize
;
if
(
m_
b
lockSize
==
0
)
{
in
>>
m_
b
lockSize
;
}
if
(
m_s
lowS
ocket
->
bytesAvailable
()
<
m_
slowB
lockSize
)
if
(
m_socket
->
bytesAvailable
()
<
m_
b
lockSize
)
break
;
QVariant
command
;
in
>>
command
;
m_
slowB
lockSize
=
0
;
m_
b
lockSize
=
0
;
Q_ASSERT
(
in
.
status
()
==
QDataStream
::
Ok
);
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
View file @
62d66fcd
...
...
@@ -51,17 +51,14 @@ signals:
private
slots
:
void
processFinished
(
int
exitCode
,
QProcess
::
ExitStatus
exitStatus
);
void
readFastDataStream
();
void
readSlowDataStream
();
void
readDataStream
();
private:
QWeakPointer
<
QLocalServer
>
m_localServer
;
QWeakPointer
<
QLocalSocket
>
m_slowSocket
;
QWeakPointer
<
QLocalSocket
>
m_fastSocket
;
QWeakPointer
<
QLocalSocket
>
m_socket
;
QWeakPointer
<
NodeInstanceView
>
m_nodeInstanceView
;
QWeakPointer
<
QProcess
>
m_qmlPuppetProcess
;
quint32
m_slowBlockSize
;
quint32
m_fastBlockSize
;
quint32
m_blockSize
;
};
}
// namespace QmlDesigner
...
...
Write
Preview
Markdown
is supported
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