Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1366822 into lp:qtcreator-plugin-ubuntu

Proposed by Benjamin Zeller
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 295
Merged at revision: 296
Proposed branch: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1366822
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 210 lines (+135/-7)
5 files modified
share/qtcreator/ubuntu/devicespage/DevicePage.qml (+40/-5)
src/ubuntu/ubuntu.pro (+2/-1)
src/ubuntu/ubuntudevicesmodel.cpp (+24/-1)
src/ubuntu/ubuntudevicesmodel.h (+18/-0)
src/ubuntu/ubuntuscopefinalizer.h (+51/-0)
To merge this branch: bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/bug-1366822
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zoltan Balogh Approve
Review via email: mp+241069@code.launchpad.net

Commit message

- Fix bug lp:1366822 "When creating the emulator it does not tell me what logs to check "
- Add a scope finalizer implementation

Description of the change

- Fix bug lp:1366822 "When creating the emulator it does not tell me what logs to check "
- Add a scope finalizer implementation

To post a comment you must log in.
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

OK

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'share/qtcreator/ubuntu/devicespage/DevicePage.qml'
2--- share/qtcreator/ubuntu/devicespage/DevicePage.qml 2014-11-03 15:44:51 +0000
3+++ share/qtcreator/ubuntu/devicespage/DevicePage.qml 2014-11-07 12:06:40 +0000
4@@ -13,29 +13,64 @@
5
6 Item {
7 anchors.fill: parent
8+ anchors.topMargin: units.gu(2)
9+ anchors.bottomMargin: units.gu(2)
10+ anchors.leftMargin: units.gu(2)
11+ anchors.rightMargin: units.gu(4)
12 visible: devicesModel.busy
13+ RowLayout {
14+ //anchors.centerIn: parent
15+ id: busyIndicator
16+ anchors.left: parent.left
17+ anchors.top: parent.top
18+ anchors.right: parent.right
19
20- Column {
21- anchors.centerIn: parent
22 spacing: units.gu(1)
23+ height: childrenRect.height * 2
24
25 ActivityIndicator{
26- anchors.horizontalCenter: parent.horizontalCenter
27+ anchors.verticalCenter: parent.verticalCenter
28 running: devicesModel.busy
29 }
30 Label {
31+ Layout.fillWidth: true
32+ anchors.verticalCenter: parent.verticalCenter
33 text: i18n.tr("There is currently a process running in the background, please check the logs for details")
34 fontSize: "large"
35- anchors.left: parent.left
36 }
37 Button {
38 visible: devicesModel.cancellable
39- anchors.horizontalCenter: parent.horizontalCenter
40+ anchors.verticalCenter: parent.verticalCenter
41 color: UbuntuColors.warmGrey
42 text: "Cancel"
43 onClicked: devicesModel.cancel()
44 }
45 }
46+ Controls.TextArea {
47+ id: logArea
48+ anchors.left: parent.left
49+ anchors.top: busyIndicator.bottom
50+ anchors.right: parent.right
51+ anchors.bottom: parent.bottom
52+
53+ readOnly: true
54+ textFormat: TextEdit.AutoText
55+ Component.onCompleted: {
56+ deviceMode.appendText.connect(appendToLog);
57+ }
58+
59+ function appendToLog (txt) {
60+ append(txt);
61+ }
62+
63+ Connections{
64+ target: devicesModel
65+ onBusyChanged: {
66+ if(!devicesModel.busy)
67+ logArea.text = ""
68+ }
69+ }
70+ }
71 }
72
73 Controls.SplitView {
74
75=== modified file 'src/ubuntu/ubuntu.pro'
76--- src/ubuntu/ubuntu.pro 2014-11-03 15:44:51 +0000
77+++ src/ubuntu/ubuntu.pro 2014-11-07 12:06:40 +0000
78@@ -217,5 +217,6 @@
79 ubuntueditorfactory.h \
80 ubuntucmakecache.h \
81 ubuntutestcontrol.h \
82- ubuntupackageoutputparser.h
83+ ubuntupackageoutputparser.h \
84+ ubuntuscopefinalizer.h
85
86
87=== modified file 'src/ubuntu/ubuntudevicesmodel.cpp'
88--- src/ubuntu/ubuntudevicesmodel.cpp 2014-11-04 15:04:21 +0000
89+++ src/ubuntu/ubuntudevicesmodel.cpp 2014-11-07 12:06:40 +0000
90@@ -1,6 +1,25 @@
91+/*
92+ * Copyright 2014 Canonical Ltd.
93+ *
94+ * This program is free software; you can redistribute it and/or modify
95+ * it under the terms of the GNU Lesser General Public License as published by
96+ * the Free Software Foundation; version 2.1.
97+ *
98+ * This program is distributed in the hope that it will be useful,
99+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
100+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101+ * GNU Lesser General Public License for more details.
102+ *
103+ * You should have received a copy of the GNU Lesser General Public License
104+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
105+ *
106+ * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
107+ */
108+
109 #include "ubuntudevicesmodel.h"
110 #include "ubuntuconstants.h"
111 #include "ubuntukitmanager.h"
112+#include "ubuntuscopefinalizer.h"
113
114 #include <projectexplorer/devicesupport/devicemanager.h>
115 #include <projectexplorer/kitmanager.h>
116@@ -925,7 +944,11 @@
117 State lastState = m_state;
118 setCancellable(false);
119
120- setState(Idle);
121+ OnScopeExit {
122+ if(m_state == lastState)
123+ setState(Idle);
124+ };
125+
126 switch(lastState) {
127 case CheckEmulatorInstalled: {
128 QStringList lines = m_reply.trimmed().split(QLatin1String(Constants::LINEFEED));
129
130=== modified file 'src/ubuntu/ubuntudevicesmodel.h'
131--- src/ubuntu/ubuntudevicesmodel.h 2014-11-03 15:44:51 +0000
132+++ src/ubuntu/ubuntudevicesmodel.h 2014-11-07 12:06:40 +0000
133@@ -1,3 +1,21 @@
134+/*
135+ * Copyright 2014 Canonical Ltd.
136+ *
137+ * This program is free software; you can redistribute it and/or modify
138+ * it under the terms of the GNU Lesser General Public License as published by
139+ * the Free Software Foundation; version 2.1.
140+ *
141+ * This program is distributed in the hope that it will be useful,
142+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
143+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144+ * GNU Lesser General Public License for more details.
145+ *
146+ * You should have received a copy of the GNU Lesser General Public License
147+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
148+ *
149+ * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
150+ */
151+
152 #ifndef UBUNTUDEVICESMODEL_H
153 #define UBUNTUDEVICESMODEL_H
154
155
156=== added file 'src/ubuntu/ubuntuscopefinalizer.h'
157--- src/ubuntu/ubuntuscopefinalizer.h 1970-01-01 00:00:00 +0000
158+++ src/ubuntu/ubuntuscopefinalizer.h 2014-11-07 12:06:40 +0000
159@@ -0,0 +1,51 @@
160+/*
161+ * Copyright 2014 Canonical Ltd.
162+ *
163+ * This program is free software; you can redistribute it and/or modify
164+ * it under the terms of the GNU Lesser General Public License as published by
165+ * the Free Software Foundation; version 2.1.
166+ *
167+ * This program is distributed in the hope that it will be useful,
168+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
169+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170+ * GNU Lesser General Public License for more details.
171+ *
172+ * You should have received a copy of the GNU Lesser General Public License
173+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
174+ *
175+ * Author: Benjamin Zeller <benjamin.zeller@canonical.com>
176+ *
177+ * Based on the information found on:
178+ * http://stackoverflow.com/questions/10270328/the-simplest-and-neatest-c11-scopeguard
179+ * http://stackoverflow.com/questions/1597007/creating-c-macro-with-and-line-token-concatenation-with-positioning-macr
180+ */
181+#ifndef UBUNTUSCOPEFINALIZER_H
182+#define UBUNTUSCOPEFINALIZER_H
183+
184+#include <functional>
185+
186+/*!
187+ \class ScopeFinalizer
188+ Defines a way to clean up a scope nicely when its exited
189+ */
190+
191+template <typename CleanupFunc>
192+struct ScopeFinalizer
193+{
194+ inline ScopeFinalizer(){}
195+ inline ScopeFinalizer& operator<<(CleanupFunc &&lambda){
196+ m_lambda = std::move(lambda);
197+ return *this;
198+ }
199+ inline ~ScopeFinalizer(){
200+ m_lambda();
201+ }
202+
203+ CleanupFunc m_lambda;
204+};
205+
206+#define ScopeFinalizer_TOKENPASTE(x, y) x ## y
207+#define ScopeFinalizer_TOKENPASTE2(x, y) ScopeFinalizer_TOKENPASTE(x, y)
208+#define OnScopeExit ScopeFinalizer< std::function<void()> > ScopeFinalizer_TOKENPASTE2(OnScopeExit_,__LINE__); ScopeFinalizer_TOKENPASTE2(OnScopeExit_,__LINE__) << [&]()
209+
210+#endif // UBUNTUSCOPEFINALIZER_H

Subscribers

People subscribed via source and target branches