Bug 240711 - Crash when adding auto-join channels
Summary: Crash when adding auto-join channels
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: 1.2.3
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Konversation Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-04 13:01 UTC by Kebap
Modified: 2010-07-01 16:20 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
New crash information added by DrKonqi (7.82 KB, text/plain)
2010-06-04 13:04 UTC, Kebap
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kebap 2010-06-04 13:01:18 UTC
Application: konversation (1.2.3)
KDE Platform Version: 4.4.2 (KDE 4.4.2)
Qt Version: 4.6.2
Operating System: Linux 2.6.32-22-generic i686
Distribution: Ubuntu 10.04 LTS

-- Information about the crash:
I was adding some channels to join when connecting to a network. Then I clicked the green "up" arrow, which caused Konversation to crash.

 -- Backtrace:
Application: Konversation (konversation), signal: Segmentation fault
[KCrash Handler]
#6  QString (this=0xbf9ec080, settings=...) at /usr/include/qt4/QtCore/qstring.h:714
#7  Konversation::ChannelSettings::name (this=0xbf9ec080, settings=...) at ../../src/irc/servergroupsettings.h:37
#8  ChannelSettings (this=0xbf9ec080, settings=...) at ../../src/irc/servergroupsettings.cpp:194
#9  0x081620b0 in Konversation::ServerGroupDialog::moveChannelDown (this=0x9944928) at ../../src/irc/servergroupdialog.cpp:349
#10 0x08164e33 in Konversation::ServerGroupDialog::qt_metacall (this=0x9944928, _c=QMetaObject::InvokeMetaMethod, _id=86, _a=0xbf9ec1e8) at ./servergroupdialog.moc:106
#11 0x07405c9a in QMetaObject::metacall (object=0x9944928, cl=QMetaObject::InvokeMetaMethod, idx=86, argv=0xbf9ec1e8) at kernel/qmetaobject.cpp:237
#12 0x074143d5 in QMetaObject::activate (sender=0xa3f6bc0, m=0x1d7c8c4, local_signal_index=2, argv=0xbf9ec1e8) at kernel/qobject.cpp:3293
#13 0x01b6c479 in QAbstractButton::clicked (this=0xa3f6bc0, _t1=false) at .moc/release-shared/moc_qabstractbutton.cpp:206
#14 0x0184bea9 in QAbstractButtonPrivate::emitClicked (this=0xa7038f8) at widgets/qabstractbutton.cpp:546
#15 0x0184ccf4 in QAbstractButtonPrivate::click (this=0xa7038f8) at widgets/qabstractbutton.cpp:539
#16 0x0184cfae in QAbstractButton::mouseReleaseEvent (this=0xa3f6bc0, e=0xbf9ec930) at widgets/qabstractbutton.cpp:1121
#17 0x0193009c in QToolButton::mouseReleaseEvent (this=0xa3f6bc0, e=0xbf9ec930) at widgets/qtoolbutton.cpp:721
#18 0x0149f7f8 in QWidget::event (this=0xa3f6bc0, event=0xbf9ec930) at kernel/qwidget.cpp:7998
#19 0x0184bd4e in QAbstractButton::event (this=0xa3f6bc0, e=0x3) at widgets/qabstractbutton.cpp:1080
#20 0x01932bca in QToolButton::event (this=0xa3f6bc0, event=0xbf9ec930) at widgets/qtoolbutton.cpp:1163
#21 0x014414dc in QApplicationPrivate::notify_helper (this=0x8609620, receiver=0xa3f6bc0, e=0xbf9ec930) at kernel/qapplication.cpp:4300
#22 0x014489f7 in QApplication::notify (this=0xbf9ee354, receiver=0xa3f6bc0, e=0xbf9ec930) at kernel/qapplication.cpp:3865
#23 0x01134f2a in KApplication::notify (this=0xbf9ee354, receiver=0xa3f6bc0, event=0xbf9ec930) at ../../kdeui/kernel/kapplication.cpp:302
#24 0x07400a3b in QCoreApplication::notifyInternal (this=0xbf9ee354, receiver=0xa3f6bc0, event=0xbf9ec930) at kernel/qcoreapplication.cpp:704
#25 0x01447952 in QCoreApplication::sendEvent (receiver=0xa3f6bc0, event=0xbf9ec930, alienWidget=0xa3f6bc0, nativeWidget=0x8b28058, buttonDown=0x1d85058, lastMouseReceiver=..., spontaneous=true)
    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215
#26 QApplicationPrivate::sendMouseEvent (receiver=0xa3f6bc0, event=0xbf9ec930, alienWidget=0xa3f6bc0, nativeWidget=0x8b28058, buttonDown=0x1d85058, lastMouseReceiver=..., spontaneous=true)
    at kernel/qapplication.cpp:2965
#27 0x014d3088 in QETWidget::translateMouseEvent (this=0x8b28058, event=0xbf9ece4c) at kernel/qapplication_x11.cpp:4368
#28 0x014d2511 in QApplication::x11ProcessEvent (this=0xbf9ee354, event=0xbf9ece4c) at kernel/qapplication_x11.cpp:3379
#29 0x0150160a in x11EventSourceDispatch (s=0x85f8fb0, callback=0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#30 0x047ae5e5 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#31 0x047b22d8 in ?? () from /lib/libglib-2.0.so.0
#32 0x047b24b8 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#33 0x0742c5d5 in QEventDispatcherGlib::processEvents (this=0x85d5a60, flags=...) at kernel/qeventdispatcher_glib.cpp:412
#34 0x01501135 in QGuiEventDispatcherGlib::processEvents (this=0x85d5a60, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#35 0x073ff059 in QEventLoop::processEvents (this=0xbf9ed140, flags=) at kernel/qeventloop.cpp:149
#36 0x073ff4aa in QEventLoop::exec (this=0xbf9ed140, flags=...) at kernel/qeventloop.cpp:201
#37 0x019804f3 in QDialog::exec (this=0x9944928) at dialogs/qdialog.cpp:546
#38 0x0816d80b in Konversation::ServerListDialog::slotEdit (this=0x8f20c90) at ../../src/irc/serverlistdialog.cpp:187
#39 0x0816fea3 in Konversation::ServerListDialog::qt_metacall (this=0x8f20c90, _c=QMetaObject::InvokeMetaMethod, _id=81, _a=0xbf9ed368) at ./serverlistdialog.moc:110
#40 0x07405c9a in QMetaObject::metacall (object=0x8f20c90, cl=QMetaObject::InvokeMetaMethod, idx=81, argv=0xbf9ed368) at kernel/qmetaobject.cpp:237
#41 0x074143d5 in QMetaObject::activate (sender=0x901bd50, m=0x1d7c8c4, local_signal_index=2, argv=0xbf9ed368) at kernel/qobject.cpp:3293
#42 0x01b6c479 in QAbstractButton::clicked (this=0x901bd50, _t1=false) at .moc/release-shared/moc_qabstractbutton.cpp:206
#43 0x0184bea9 in QAbstractButtonPrivate::emitClicked (this=0x901bd68) at widgets/qabstractbutton.cpp:546
#44 0x0184ccf4 in QAbstractButtonPrivate::click (this=0x901bd68) at widgets/qabstractbutton.cpp:539
#45 0x0184cfae in QAbstractButton::mouseReleaseEvent (this=0x901bd50, e=0xbf9edaa0) at widgets/qabstractbutton.cpp:1121
#46 0x0149f7f8 in QWidget::event (this=0x901bd50, event=0xbf9edaa0) at kernel/qwidget.cpp:7998
#47 0x0184bd4e in QAbstractButton::event (this=0x901bd50, e=0x3) at widgets/qabstractbutton.cpp:1080
#48 0x018f61f2 in QPushButton::event (this=0x901bd50, e=0xbf9edaa0) at widgets/qpushbutton.cpp:679
#49 0x014414dc in QApplicationPrivate::notify_helper (this=0x8609620, receiver=0x901bd50, e=0xbf9edaa0) at kernel/qapplication.cpp:4300
#50 0x014489f7 in QApplication::notify (this=0xbf9ee354, receiver=0x901bd50, e=0xbf9edaa0) at kernel/qapplication.cpp:3865
#51 0x01134f2a in KApplication::notify (this=0xbf9ee354, receiver=0x901bd50, event=0xbf9edaa0) at ../../kdeui/kernel/kapplication.cpp:302
#52 0x07400a3b in QCoreApplication::notifyInternal (this=0xbf9ee354, receiver=0x901bd50, event=0xbf9edaa0) at kernel/qcoreapplication.cpp:704
#53 0x01447952 in QCoreApplication::sendEvent (receiver=0x901bd50, event=0xbf9edaa0, alienWidget=0x901bd50, nativeWidget=0x90861d8, buttonDown=0x1d85058, lastMouseReceiver=..., spontaneous=true)
    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215
#54 QApplicationPrivate::sendMouseEvent (receiver=0x901bd50, event=0xbf9edaa0, alienWidget=0x901bd50, nativeWidget=0x90861d8, buttonDown=0x1d85058, lastMouseReceiver=..., spontaneous=true)
    at kernel/qapplication.cpp:2965
#55 0x014d3088 in QETWidget::translateMouseEvent (this=0x90861d8, event=0xbf9edfbc) at kernel/qapplication_x11.cpp:4368
#56 0x014d2511 in QApplication::x11ProcessEvent (this=0xbf9ee354, event=0xbf9edfbc) at kernel/qapplication_x11.cpp:3379
#57 0x0150160a in x11EventSourceDispatch (s=0x85f8fb0, callback=0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#58 0x047ae5e5 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#59 0x047b22d8 in ?? () from /lib/libglib-2.0.so.0
#60 0x047b24b8 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#61 0x0742c5d5 in QEventDispatcherGlib::processEvents (this=0x85d5a60, flags=...) at kernel/qeventdispatcher_glib.cpp:412
#62 0x01501135 in QGuiEventDispatcherGlib::processEvents (this=0x85d5a60, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#63 0x073ff059 in QEventLoop::processEvents (this=0xbf9ee2b4, flags=) at kernel/qeventloop.cpp:149
#64 0x073ff4aa in QEventLoop::exec (this=0xbf9ee2b4, flags=...) at kernel/qeventloop.cpp:201
#65 0x0740369f in QCoreApplication::exec () at kernel/qcoreapplication.cpp:981
#66 0x01441577 in QApplication::exec () at kernel/qapplication.cpp:3579
#67 0x080a7148 in main (argc=5, argv=0xbf9ee784) at ../../src/main.cpp:100

Reported using DrKonqi
Comment 1 Kebap 2010-06-04 13:04:50 UTC
Created attachment 47667 [details]
New crash information added by DrKonqi

Happened again. Actually, it was the green "down" button. This is what I did: Open up a connection details, add 3 channels to the list, click the button, see it crash.
Comment 2 Eike Hein 2010-06-04 16:51:10 UTC
commit 9e28e6e1f5144f087b6b1b97b3f3a689b350244f
Author: Eike Hein <hein@kde.org>
Date:   Fri Jun 4 16:46:23 2010 +0200

    Fix button state update code to operate on selection instead of current item.
    
    BUG:240711
    
    Also select the item after adding a new one.

diff --git a/ChangeLog b/ChangeLog
index 3565ccf..73f2a91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Changes since 1.3-beta1:
+* When opening an "Edit Network" dialog and adding a new item to one of
+  the server or channel lists, provided they already contain at least one
+  item and no selection is made before clicking "Add...", the "Move Down"
+  button would be enabled afterwards despite no item being selected.
+  Clicking the button at this point would crash the application. This has
+  been fixed along with other potential problems in the code that updates
+  the state of the list control buttons.
+* After adding a new item to one of the server or channel lists in "Edit
+  Network" dialogs, that item will now be selected.
+
+
 Changes from 1.2.3 to 1.3-beta1:
 Konversation 1.3-beta1 debuts a major new feature in the area of Direct
 Client-to-Client (DCC) support: An implementation of the DCC Whiteboard
diff --git a/src/irc/servergroupdialog.cpp b/src/irc/servergroupdialog.cpp
index 751c08d..f49fb4d 100644
--- a/src/irc/servergroupdialog.cpp
+++ b/src/irc/servergroupdialog.cpp
@@ -58,7 +58,7 @@ namespace Konversation
         connect(m_mainWidget->m_addServerButton, SIGNAL(clicked()), this, SLOT(addServer()));
         connect(m_mainWidget->m_changeServerButton, SIGNAL(clicked()), this, SLOT(editServer()));
         connect(m_mainWidget->m_removeServerButton, SIGNAL(clicked()), this, SLOT(deleteServer()));
-        connect(m_mainWidget->m_serverLBox, SIGNAL(currentRowChanged(int)), this, SLOT(updateServerArrows()));
+        connect(m_mainWidget->m_serverLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateServerArrows()));
         connect(m_mainWidget->m_upServerBtn, SIGNAL(clicked()), this, SLOT(moveServerUp()));
         connect(m_mainWidget->m_downServerBtn, SIGNAL(clicked()), this, SLOT(moveServerDown()));
 
@@ -69,7 +69,7 @@ namespace Konversation
         connect(m_mainWidget->m_addChannelButton, SIGNAL(clicked()), this, SLOT(addChannel()));
         connect(m_mainWidget->m_changeChannelButton, SIGNAL(clicked()), this, SLOT(editChannel()));
         connect(m_mainWidget->m_removeChannelButton, SIGNAL(clicked()), this, SLOT(deleteChannel()));
-        connect(m_mainWidget->m_channelLBox, SIGNAL(currentRowChanged(int)), this, SLOT(updateChannelArrows()));
+        connect(m_mainWidget->m_channelLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateChannelArrows()));
         connect(m_mainWidget->m_upChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelUp()));
         connect(m_mainWidget->m_downChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelDown()));
 
@@ -164,8 +164,8 @@ namespace Konversation
         {
             ServerSettings server = dlg->serverSettings();
             m_mainWidget->m_serverLBox->addItem(server.host());
+            m_mainWidget->m_serverLBox->item(m_mainWidget->m_serverLBox->count() - 1)->setSelected(true);
             m_serverList.append(server);
-            updateServerArrows();
         }
         delete dlg;
     }
@@ -219,13 +219,24 @@ namespace Konversation
 
     void ServerGroupDialog::updateServerArrows()
     {
-        m_mainWidget->m_upServerBtn->setEnabled( m_mainWidget->m_serverLBox->count()>1 && m_mainWidget->m_serverLBox->currentRow()>0 );
+        QList<QListWidgetItem*> serverBoxSelection = m_mainWidget->m_serverLBox->selectedItems();
 
-        m_mainWidget->m_downServerBtn->setEnabled( m_mainWidget->m_serverLBox->count()>1 &&
-            m_mainWidget->m_serverLBox->currentRow()<m_mainWidget->m_serverLBox->count()-1 );
-        bool enabled = m_mainWidget->m_serverLBox->currentRow() >= 0;
-        m_mainWidget->m_removeServerButton->setEnabled(enabled);
-        m_mainWidget->m_changeServerButton->setEnabled(enabled);
+        if (m_mainWidget->m_serverLBox->count() && serverBoxSelection.count())
+        {
+            QListWidgetItem* selectedServer = serverBoxSelection.first();
+            int selectedServerRow = m_mainWidget->m_serverLBox->row(selectedServer);
+
+            m_mainWidget->m_upServerBtn->setEnabled(selectedServerRow > 0);
+            m_mainWidget->m_downServerBtn->setEnabled(selectedServerRow < m_mainWidget->m_serverLBox->count() - 1);
+        }
+        else
+        {
+            m_mainWidget->m_upServerBtn->setEnabled(false);
+            m_mainWidget->m_downServerBtn->setEnabled(false);
+        }
+
+        m_mainWidget->m_removeServerButton->setEnabled(serverBoxSelection.count());
+        m_mainWidget->m_changeServerButton->setEnabled(serverBoxSelection.count());
     }
 
     void ServerGroupDialog::moveServerUp()
@@ -276,8 +287,8 @@ namespace Konversation
         {
             ChannelSettings channel = dlg->channelSettings();
             m_mainWidget->m_channelLBox->addItem(channel.name());
+            m_mainWidget->m_channelLBox->item(m_mainWidget->m_channelLBox->count() - 1)->setSelected(true);
             m_channelList.append(channel);
-            updateChannelArrows();
         }
         delete dlg;
     }
@@ -315,13 +326,24 @@ namespace Konversation
 
     void ServerGroupDialog::updateChannelArrows()
     {
-        m_mainWidget->m_upChannelBtn->setEnabled( m_mainWidget->m_channelLBox->count()>1 && m_mainWidget->m_channelLBox->currentRow()>0 );
+        QList<QListWidgetItem*> channelBoxSelection = m_mainWidget->m_channelLBox->selectedItems();
+
+        if (m_mainWidget->m_channelLBox->count() && channelBoxSelection.count())
+        {
+            QListWidgetItem* selectedChannel = channelBoxSelection.first();
+            int selectedChannelRow = m_mainWidget->m_channelLBox->row(selectedChannel);
+
+            m_mainWidget->m_upChannelBtn->setEnabled(selectedChannelRow > 0);
+            m_mainWidget->m_downChannelBtn->setEnabled(selectedChannelRow < m_mainWidget->m_channelLBox->count() - 1);
+        }
+        else
+        {
+            m_mainWidget->m_upChannelBtn->setEnabled(false);
+            m_mainWidget->m_downChannelBtn->setEnabled(false);
+        }
 
-        m_mainWidget->m_downChannelBtn->setEnabled( m_mainWidget->m_channelLBox->count()>1 &&
-            m_mainWidget->m_channelLBox->currentRow()<m_mainWidget->m_channelLBox->count()-1 );
-        bool selected = m_mainWidget->m_channelLBox->currentRow() >= 0;
-        m_mainWidget->m_removeChannelButton->setEnabled(selected);
-        m_mainWidget->m_changeChannelButton->setEnabled(selected);
+        m_mainWidget->m_removeChannelButton->setEnabled(channelBoxSelection.count());
+        m_mainWidget->m_changeChannelButton->setEnabled(channelBoxSelection.count());   
     }
 
     void ServerGroupDialog::moveChannelUp()
Comment 3 Eike Hein 2010-07-01 16:20:04 UTC
commit 9e28e6e1f5144f087b6b1b97b3f3a689b350244f
Author: Eike Hein <hein@kde.org>
Date:   Fri Jun 4 16:46:23 2010 +0200

    Fix button state update code to operate on selection instead of current item.
    
    BUG:240711
    
    Also select the item after adding a new one.

diff --git a/ChangeLog b/ChangeLog
index 3565ccf..73f2a91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Changes since 1.3-beta1:
+* When opening an "Edit Network" dialog and adding a new item to one of
+  the server or channel lists, provided they already contain at least one
+  item and no selection is made before clicking "Add...", the "Move Down"
+  button would be enabled afterwards despite no item being selected.
+  Clicking the button at this point would crash the application. This has
+  been fixed along with other potential problems in the code that updates
+  the state of the list control buttons.
+* After adding a new item to one of the server or channel lists in "Edit
+  Network" dialogs, that item will now be selected.
+
+
 Changes from 1.2.3 to 1.3-beta1:
 Konversation 1.3-beta1 debuts a major new feature in the area of Direct
 Client-to-Client (DCC) support: An implementation of the DCC Whiteboard
diff --git a/src/irc/servergroupdialog.cpp b/src/irc/servergroupdialog.cpp
index 751c08d..f49fb4d 100644
--- a/src/irc/servergroupdialog.cpp
+++ b/src/irc/servergroupdialog.cpp
@@ -58,7 +58,7 @@ namespace Konversation
         connect(m_mainWidget->m_addServerButton, SIGNAL(clicked()), this, SLOT(addServer()));
         connect(m_mainWidget->m_changeServerButton, SIGNAL(clicked()), this, SLOT(editServer()));
         connect(m_mainWidget->m_removeServerButton, SIGNAL(clicked()), this, SLOT(deleteServer()));
-        connect(m_mainWidget->m_serverLBox, SIGNAL(currentRowChanged(int)), this, SLOT(updateServerArrows()));
+        connect(m_mainWidget->m_serverLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateServerArrows()));
         connect(m_mainWidget->m_upServerBtn, SIGNAL(clicked()), this, SLOT(moveServerUp()));
         connect(m_mainWidget->m_downServerBtn, SIGNAL(clicked()), this, SLOT(moveServerDown()));
 
@@ -69,7 +69,7 @@ namespace Konversation
         connect(m_mainWidget->m_addChannelButton, SIGNAL(clicked()), this, SLOT(addChannel()));
         connect(m_mainWidget->m_changeChannelButton, SIGNAL(clicked()), this, SLOT(editChannel()));
         connect(m_mainWidget->m_removeChannelButton, SIGNAL(clicked()), this, SLOT(deleteChannel()));
-        connect(m_mainWidget->m_channelLBox, SIGNAL(currentRowChanged(int)), this, SLOT(updateChannelArrows()));
+        connect(m_mainWidget->m_channelLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateChannelArrows()));
         connect(m_mainWidget->m_upChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelUp()));
         connect(m_mainWidget->m_downChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelDown()));
 
@@ -164,8 +164,8 @@ namespace Konversation
         {
             ServerSettings server = dlg->serverSettings();
             m_mainWidget->m_serverLBox->addItem(server.host());
+            m_mainWidget->m_serverLBox->item(m_mainWidget->m_serverLBox->count() - 1)->setSelected(true);
             m_serverList.append(server);
-            updateServerArrows();
         }
         delete dlg;
     }
@@ -219,13 +219,24 @@ namespace Konversation
 
     void ServerGroupDialog::updateServerArrows()
     {
-        m_mainWidget->m_upServerBtn->setEnabled( m_mainWidget->m_serverLBox->count()>1 && m_mainWidget->m_serverLBox->currentRow()>0 );
+        QList<QListWidgetItem*> serverBoxSelection = m_mainWidget->m_serverLBox->selectedItems();
 
-        m_mainWidget->m_downServerBtn->setEnabled( m_mainWidget->m_serverLBox->count()>1 &&
-            m_mainWidget->m_serverLBox->currentRow()<m_mainWidget->m_serverLBox->count()-1 );
-        bool enabled = m_mainWidget->m_serverLBox->currentRow() >= 0;
-        m_mainWidget->m_removeServerButton->setEnabled(enabled);
-        m_mainWidget->m_changeServerButton->setEnabled(enabled);
+        if (m_mainWidget->m_serverLBox->count() && serverBoxSelection.count())
+        {
+            QListWidgetItem* selectedServer = serverBoxSelection.first();
+            int selectedServerRow = m_mainWidget->m_serverLBox->row(selectedServer);
+
+            m_mainWidget->m_upServerBtn->setEnabled(selectedServerRow > 0);
+            m_mainWidget->m_downServerBtn->setEnabled(selectedServerRow < m_mainWidget->m_serverLBox->count() - 1);
+        }
+        else
+        {
+            m_mainWidget->m_upServerBtn->setEnabled(false);
+            m_mainWidget->m_downServerBtn->setEnabled(false);
+        }
+
+        m_mainWidget->m_removeServerButton->setEnabled(serverBoxSelection.count());
+        m_mainWidget->m_changeServerButton->setEnabled(serverBoxSelection.count());
     }
 
     void ServerGroupDialog::moveServerUp()
@@ -276,8 +287,8 @@ namespace Konversation
         {
             ChannelSettings channel = dlg->channelSettings();
             m_mainWidget->m_channelLBox->addItem(channel.name());
+            m_mainWidget->m_channelLBox->item(m_mainWidget->m_channelLBox->count() - 1)->setSelected(true);
             m_channelList.append(channel);
-            updateChannelArrows();
         }
         delete dlg;
     }
@@ -315,13 +326,24 @@ namespace Konversation
 
     void ServerGroupDialog::updateChannelArrows()
     {
-        m_mainWidget->m_upChannelBtn->setEnabled( m_mainWidget->m_channelLBox->count()>1 && m_mainWidget->m_channelLBox->currentRow()>0 );
+        QList<QListWidgetItem*> channelBoxSelection = m_mainWidget->m_channelLBox->selectedItems();
+
+        if (m_mainWidget->m_channelLBox->count() && channelBoxSelection.count())
+        {
+            QListWidgetItem* selectedChannel = channelBoxSelection.first();
+            int selectedChannelRow = m_mainWidget->m_channelLBox->row(selectedChannel);
+
+            m_mainWidget->m_upChannelBtn->setEnabled(selectedChannelRow > 0);
+            m_mainWidget->m_downChannelBtn->setEnabled(selectedChannelRow < m_mainWidget->m_channelLBox->count() - 1);
+        }
+        else
+        {
+            m_mainWidget->m_upChannelBtn->setEnabled(false);
+            m_mainWidget->m_downChannelBtn->setEnabled(false);
+        }
 
-        m_mainWidget->m_downChannelBtn->setEnabled( m_mainWidget->m_channelLBox->count()>1 &&
-            m_mainWidget->m_channelLBox->currentRow()<m_mainWidget->m_channelLBox->count()-1 );
-        bool selected = m_mainWidget->m_channelLBox->currentRow() >= 0;
-        m_mainWidget->m_removeChannelButton->setEnabled(selected);
-        m_mainWidget->m_changeChannelButton->setEnabled(selected);
+        m_mainWidget->m_removeChannelButton->setEnabled(channelBoxSelection.count());
+        m_mainWidget->m_changeChannelButton->setEnabled(channelBoxSelection.count());   
     }
 
     void ServerGroupDialog::moveChannelUp()