From 1920b2749906b506f299d4acbda0141b064a2fd7 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 21 Jan 2023 16:43:59 +0200 Subject: [PATCH 39/39] Qt: Don't try to refer to qapp outside gui_main.cpp It's local (static) to the module. Attempt to use it by declaring it 'extern' in other modules caused linking to fail with msys2 clang64 toolchain. See osdn #46575 Signed-off-by: Marko Lindqvist --- client/gui-qt/chatline.cpp | 4 +++- client/gui-qt/citydlg.cpp | 4 ++-- client/gui-qt/diplodlg.cpp | 4 ++-- client/gui-qt/mapview.cpp | 1 - client/gui-qt/menu.cpp | 2 -- client/gui-qt/messagedlg.cpp | 8 +++----- client/gui-qt/repodlgs.cpp | 1 - client/gui-qt/themes.cpp | 3 +-- 8 files changed, 11 insertions(+), 16 deletions(-) diff --git a/client/gui-qt/chatline.cpp b/client/gui-qt/chatline.cpp index 64294a278a..d74cbf2d78 100644 --- a/client/gui-qt/chatline.cpp +++ b/client/gui-qt/chatline.cpp @@ -46,7 +46,6 @@ #include "gui_main.h" #include "qtg_cxxside.h" -extern QApplication *qapp; static bool is_plain_public_message(QString s); FC_CPP_DECLARE_LISTENER(chat_listener) @@ -738,6 +737,7 @@ void qtg_real_output_window_append(const char *astring, { QString str; QString wakeup; + QApplication *qapp; str = QString::fromUtf8(astring); gui()->set_status_bar(str); @@ -749,6 +749,8 @@ void qtg_real_output_window_append(const char *astring, wakeup = wakeup.arg(client.conn.username); } + qapp = current_app(); + if (str.contains(client.conn.username)) { qapp->alert(gui()->central_wdg); } diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index 99e9b615c6..1cc68cc0c1 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -64,9 +64,9 @@ #include "citydlg.h" #include "colors.h" #include "fc_client.h" +#include "gui_main.h" #include "hudwidget.h" -extern QApplication *qapp; static bool city_dlg_created = false; /** defines if dialog for city has been * already created. It's created only * once per client @@ -4078,7 +4078,7 @@ void city_production_delegate::paint(QPainter *painter, QPixmap pix_dec(option.rect.width(), option.rect.height()); QStyleOptionViewItem opt; color col; - QIcon icon = qapp->style()->standardIcon(QStyle::SP_DialogCancelButton); + QIcon icon = current_app()->style()->standardIcon(QStyle::SP_DialogCancelButton); bool free_sprite = false; struct unit_class *pclass; diff --git a/client/gui-qt/diplodlg.cpp b/client/gui-qt/diplodlg.cpp index cf033f4b05..8185aced7c 100644 --- a/client/gui-qt/diplodlg.cpp +++ b/client/gui-qt/diplodlg.cpp @@ -37,6 +37,7 @@ #include "colors.h" #include "diplodlg.h" #include "fc_client.h" +#include "gui_main.h" #include "sidebar.h" extern "C" { @@ -46,7 +47,6 @@ extern "C" { typedef advance *p_advance; typedef city *p_city; -extern QApplication *qapp; /************************************************************************//** Constructor for diplomacy widget @@ -1099,7 +1099,7 @@ void close_all_diplomacy_dialogs(void) diplo_dlg *dd; QWidget *w; - qapp->alert(gui()->central_wdg); + current_app()->alert(gui()->central_wdg); if (!gui()->is_repo_dlg_open("DDI")) { return; } diff --git a/client/gui-qt/mapview.cpp b/client/gui-qt/mapview.cpp index 921dab16a4..59be953441 100644 --- a/client/gui-qt/mapview.cpp +++ b/client/gui-qt/mapview.cpp @@ -54,7 +54,6 @@ const char *get_timeout_label_text(); static int mapview_frozen_level = 0; extern void destroy_city_dialog(); extern struct canvas *canvas; -extern QApplication *qapp; #define MAX_DIRTY_RECTS 20 static int num_dirty_rects = 0; diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index 7700ab13fc..22efd7e447 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -60,8 +60,6 @@ #include "menu.h" -extern QApplication *qapp; - static void enable_interface(bool enable); /**********************************************************************//** diff --git a/client/gui-qt/messagedlg.cpp b/client/gui-qt/messagedlg.cpp index 92114d58a2..365d96f7ed 100644 --- a/client/gui-qt/messagedlg.cpp +++ b/client/gui-qt/messagedlg.cpp @@ -15,7 +15,6 @@ #include #endif - // Qt #include #include @@ -29,11 +28,10 @@ // gui-qt #include "fc_client.h" +#include "gui_main.h" #include "messagedlg.h" -extern QApplication *qapp; - /**********************************************************************//** Message widget constructor **************************************************************************/ @@ -85,8 +83,8 @@ message_dlg::message_dlg() fill_data(); margins = msgtab->contentsMargins(); len = msgtab->horizontalHeader()->length() + margins.left() - + margins.right() - + qapp->style()->pixelMetric(QStyle::PM_ScrollBarExtent); + + margins.right() + + current_app()->style()->pixelMetric(QStyle::PM_ScrollBarExtent); msgtab->setFixedWidth(len); msgtab->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); but1->setFixedWidth(len / 3); diff --git a/client/gui-qt/repodlgs.cpp b/client/gui-qt/repodlgs.cpp index 1736d71e69..5e88423564 100644 --- a/client/gui-qt/repodlgs.cpp +++ b/client/gui-qt/repodlgs.cpp @@ -61,7 +61,6 @@ extern QString cut_helptext(QString text); extern QString get_tooltip_improvement(impr_type *building, struct city *pcity, bool ext); extern QString get_tooltip_unit(struct unit_type *unit, bool ext); -extern QApplication *qapp; units_reports *units_reports::m_instance = nullptr; diff --git a/client/gui-qt/themes.cpp b/client/gui-qt/themes.cpp index bb39b3e5cf..7f621e032d 100644 --- a/client/gui-qt/themes.cpp +++ b/client/gui-qt/themes.cpp @@ -32,9 +32,8 @@ // gui-qt #include "fc_client.h" +#include "gui_main.h" -extern QApplication *current_app(); -extern QApplication *qapp; extern QString current_theme; static QString def_app_style; static QString stylestring; -- 2.39.0