Commit f97672f519e544f0e17f8548ea381f826c8621fc
1 parent
8a2c6871f9
Exists in
master
and in
2 other branches
현재 자식 창이 환경 설정 창이 아닐 경우만 삭제하는 메소드 추가
- 오류 발생 시 호출 - 기존 메소드는 자식이 항상 있을 거라 가정했고, 이 메소드는 자식이 없을 수도 있기에 관련 구조 변경 있음
Showing
2 changed files
with
28 additions
and
8 deletions
Show diff stats
app/gui/oven_control/mainwindow.cpp
| @@ -43,15 +43,19 @@ void MainWindow::jump(QMainWindow *newChild) | @@ -43,15 +43,19 @@ void MainWindow::jump(QMainWindow *newChild) | ||
| 43 | if (instance->child) | 43 | if (instance->child) |
| 44 | instance->child->deleteLater(); | 44 | instance->child->deleteLater(); |
| 45 | 45 | ||
| 46 | - instance->child = newChild; | 46 | + instance->newChild(newChild); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | void MainWindow::killChild() | 49 | void MainWindow::killChild() |
| 50 | { | 50 | { |
| 51 | if (instance->child) | 51 | if (instance->child) |
| 52 | instance->child->deleteLater(); | 52 | instance->child->deleteLater(); |
| 53 | +} | ||
| 53 | 54 | ||
| 54 | - instance->child = NULL; | 55 | +void MainWindow::killChildCook() |
| 56 | +{ | ||
| 57 | + if (instance->child && !instance->child->inherits("ConfigWindow")) | ||
| 58 | + instance->child->deleteLater(); | ||
| 55 | } | 59 | } |
| 56 | 60 | ||
| 57 | void MainWindow::keyPressEvent(QKeyEvent *event) | 61 | void MainWindow::keyPressEvent(QKeyEvent *event) |
| @@ -113,7 +117,7 @@ void MainWindow::showManualCookWindow(Define::Mode mode) | @@ -113,7 +117,7 @@ void MainWindow::showManualCookWindow(Define::Mode mode) | ||
| 113 | w->showFullScreen(); | 117 | w->showFullScreen(); |
| 114 | w->raise(); | 118 | w->raise(); |
| 115 | 119 | ||
| 116 | - child = w; | 120 | + newChild(w); |
| 117 | } | 121 | } |
| 118 | 122 | ||
| 119 | void MainWindow::showAutoCookSelectionWindow(Define::CookType type) | 123 | void MainWindow::showAutoCookSelectionWindow(Define::CookType type) |
| @@ -123,7 +127,19 @@ void MainWindow::showAutoCookSelectionWindow(Define::CookType type) | @@ -123,7 +127,19 @@ void MainWindow::showAutoCookSelectionWindow(Define::CookType type) | ||
| 123 | w->showFullScreen(); | 127 | w->showFullScreen(); |
| 124 | w->raise(); | 128 | w->raise(); |
| 125 | 129 | ||
| 126 | - child = w; | 130 | + newChild(w); |
| 131 | +} | ||
| 132 | + | ||
| 133 | +void MainWindow::newChild(QMainWindow *newChild) | ||
| 134 | +{ | ||
| 135 | + child = newChild; | ||
| 136 | + connect(newChild, SIGNAL(destroyed(QObject*)), this, SLOT(onChildDestroyed(QObject*))); | ||
| 137 | +} | ||
| 138 | + | ||
| 139 | +void MainWindow::onChildDestroyed(QObject *destroyed) | ||
| 140 | +{ | ||
| 141 | + if (destroyed == child) | ||
| 142 | + child = NULL; | ||
| 127 | } | 143 | } |
| 128 | 144 | ||
| 129 | void MainWindow::on_steamButton_clicked() | 145 | void MainWindow::on_steamButton_clicked() |
| @@ -183,7 +199,7 @@ void MainWindow::on_primeButton_clicked() | @@ -183,7 +199,7 @@ void MainWindow::on_primeButton_clicked() | ||
| 183 | w->showFullScreen(); | 199 | w->showFullScreen(); |
| 184 | w->raise(); | 200 | w->raise(); |
| 185 | 201 | ||
| 186 | - child = w; | 202 | + newChild(w); |
| 187 | } | 203 | } |
| 188 | 204 | ||
| 189 | void MainWindow::on_multiButton_clicked() | 205 | void MainWindow::on_multiButton_clicked() |
| @@ -198,7 +214,7 @@ void MainWindow::on_programmingButton_clicked() | @@ -198,7 +214,7 @@ void MainWindow::on_programmingButton_clicked() | ||
| 198 | w->showFullScreen(); | 214 | w->showFullScreen(); |
| 199 | w->raise(); | 215 | w->raise(); |
| 200 | 216 | ||
| 201 | - child = w; | 217 | + newChild(w); |
| 202 | } | 218 | } |
| 203 | 219 | ||
| 204 | void MainWindow::on_washButton_clicked() | 220 | void MainWindow::on_washButton_clicked() |
| @@ -208,7 +224,7 @@ void MainWindow::on_washButton_clicked() | @@ -208,7 +224,7 @@ void MainWindow::on_washButton_clicked() | ||
| 208 | w->showFullScreen(); | 224 | w->showFullScreen(); |
| 209 | w->raise(); | 225 | w->raise(); |
| 210 | 226 | ||
| 211 | - child = w; | 227 | + newChild(w); |
| 212 | } | 228 | } |
| 213 | 229 | ||
| 214 | void MainWindow::on_configButton_clicked() | 230 | void MainWindow::on_configButton_clicked() |
| @@ -218,7 +234,7 @@ void MainWindow::on_configButton_clicked() | @@ -218,7 +234,7 @@ void MainWindow::on_configButton_clicked() | ||
| 218 | w->showFullScreen(); | 234 | w->showFullScreen(); |
| 219 | w->raise(); | 235 | w->raise(); |
| 220 | 236 | ||
| 221 | - child = w; | 237 | + newChild(w); |
| 222 | } | 238 | } |
| 223 | 239 | ||
| 224 | void MainWindow::on_helpButton_clicked() | 240 | void MainWindow::on_helpButton_clicked() |
app/gui/oven_control/mainwindow.h
| @@ -22,6 +22,7 @@ public: | @@ -22,6 +22,7 @@ public: | ||
| 22 | static MainWindow *getInstance() { return instance; } | 22 | static MainWindow *getInstance() { return instance; } |
| 23 | static void jump(QMainWindow *newChild); | 23 | static void jump(QMainWindow *newChild); |
| 24 | static void killChild(); | 24 | static void killChild(); |
| 25 | + static void killChildCook(); | ||
| 25 | 26 | ||
| 26 | protected: | 27 | protected: |
| 27 | void keyPressEvent(QKeyEvent *event); | 28 | void keyPressEvent(QKeyEvent *event); |
| @@ -40,6 +41,9 @@ private slots: | @@ -40,6 +41,9 @@ private slots: | ||
| 40 | void showManualCookWindow(Define::Mode mode); | 41 | void showManualCookWindow(Define::Mode mode); |
| 41 | void showAutoCookSelectionWindow(Define::CookType type); | 42 | void showAutoCookSelectionWindow(Define::CookType type); |
| 42 | 43 | ||
| 44 | + void newChild(QMainWindow *newChild); | ||
| 45 | + void onChildDestroyed(QObject *destroyed); | ||
| 46 | + | ||
| 43 | void on_steamButton_clicked(); | 47 | void on_steamButton_clicked(); |
| 44 | void on_combiButton_clicked(); | 48 | void on_combiButton_clicked(); |
| 45 | void on_dryheatButton_clicked(); | 49 | void on_dryheatButton_clicked(); |