From 98384644950ac865bb097038ee203595f13314b0 Mon Sep 17 00:00:00 2001 From: LI Daobing Date: Wed, 17 Mar 2021 20:09:59 +0800 Subject: [PATCH] don't open two windows for one pal (#375) * auto open received dialog * fix crash on remove selected * Update UiModels.h * disconnect when dialog destroyed * fix window show twice * don't attach on regular * Update DialogPeer.cpp --- src/iptux/DialogPeer.cpp | 5 +++-- src/iptux/MainWindow.cpp | 4 ++++ src/iptux/UiCoreThread.cpp | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/iptux/DialogPeer.cpp b/src/iptux/DialogPeer.cpp index 6330e6d1..fe3bc683 100644 --- a/src/iptux/DialogPeer.cpp +++ b/src/iptux/DialogPeer.cpp @@ -69,11 +69,14 @@ DialogPeer::~DialogPeer() { * @param grpinf 好友群组信息 */ void DialogPeer::PeerDialogEntry(Application* app, GroupInfo *grpinf) { + if(grpinf->dialog) return; + DialogPeer *dlgpr; GtkWidget *window, *widget; dlgpr = new DialogPeer(app, grpinf); window = GTK_WIDGET(dlgpr->CreateMainWindow()); + grpinf->dialog = window; gtk_container_add(GTK_CONTAINER(window), dlgpr->CreateAllArea()); gtk_widget_show_all(window); @@ -90,8 +93,6 @@ void DialogPeer::PeerDialogEntry(Application* app, GroupInfo *grpinf) { g_cthrd->PopItemFromMsgline(grpinf); } g_cthrd->Unlock(); - - /* delete dlgpr;//请不要这样做,此类将会在窗口被摧毁后自动释放 */ } /** diff --git a/src/iptux/MainWindow.cpp b/src/iptux/MainWindow.cpp index 2abcabc9..e30b243a 100644 --- a/src/iptux/MainWindow.cpp +++ b/src/iptux/MainWindow.cpp @@ -1469,6 +1469,10 @@ void MainWindow::onPalChangeInfo(void*, void*, MainWindow&self) { void MainWindow::onPalSendMessage(void*, void*, MainWindow&self) { GroupInfo* groupInfo = CHECK_NOTNULL(self.currentGroupInfo); + if(groupInfo->dialog) { + gtk_window_present(GTK_WINDOW(groupInfo->dialog)); + return; + } switch(groupInfo->getType()) { case GROUP_BELONG_TYPE_REGULAR: DialogPeer::PeerDialogEntry(self.app, groupInfo); diff --git a/src/iptux/UiCoreThread.cpp b/src/iptux/UiCoreThread.cpp index 8724d6ca..1be84cb0 100644 --- a/src/iptux/UiCoreThread.cpp +++ b/src/iptux/UiCoreThread.cpp @@ -292,7 +292,6 @@ void UiCoreThread::AttachPalToList(shared_ptr pal2) { /* 将好友加入到相应的群组 */ if (!(grpinf = GetPalRegularItem(pal))) grpinf = AttachPalRegularItem(pal2); - AttachPalToGroupInfoItem(grpinf, pal2); if (!(grpinf = GetPalSegmentItem(pal))) grpinf = AttachPalSegmentItem(pal2); AttachPalToGroupInfoItem(grpinf, pal2); if (!(grpinf = GetPalGroupItem(pal))) grpinf = AttachPalGroupItem(pal2);