Skip to content

Commit

Permalink
don't open two windows for one pal (#375)
Browse files Browse the repository at this point in the history
* 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
lidaobing authored Mar 17, 2021
1 parent f3b2325 commit 9838464
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/iptux/DialogPeer.cpp
Original file line number Diff line number Diff line change
@@ -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;//请不要这样做,此类将会在窗口被摧毁后自动释放 */
}

/**
4 changes: 4 additions & 0 deletions src/iptux/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -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);
1 change: 0 additions & 1 deletion src/iptux/UiCoreThread.cpp
Original file line number Diff line number Diff line change
@@ -292,7 +292,6 @@ void UiCoreThread::AttachPalToList(shared_ptr<PalInfo> 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);

0 comments on commit 9838464

Please sign in to comment.