summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-10-04 01:33:33 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-10-04 01:33:33 +0000
commit7c5dea76bf90caad177e1dd78991b699a3f58bd5 (patch)
tree4a489dd631a512f4dde7ee0395acf08700e58d9d
parent552b36e1c08deafa5eb19fb8a51d03f63b59ca1c (diff)
downloadtdebase-7c5dea76.tar.gz
tdebase-7c5dea76.zip
Fix a potential crash in the displayconfig control center module
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1257191 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
-rw-r--r--kcontrol/displayconfig/displayconfig.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/kcontrol/displayconfig/displayconfig.cpp b/kcontrol/displayconfig/displayconfig.cpp
index ad2d31fff..b6b2b8a5e 100644
--- a/kcontrol/displayconfig/displayconfig.cpp
+++ b/kcontrol/displayconfig/displayconfig.cpp
@@ -465,13 +465,14 @@ void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id,
j=i;
}
monitors = base->monitorPhyArrange->childrenListObject();
- primary_monitor = 0;
+ primary_monitor = NULL;
if ( monitors.count() ) {
for ( i = 0; i < int(monitors.count()); ++i ) {
if (::tqqt_cast<DraggableMonitor*>(TQT_TQWIDGET(monitors.at( i )))) {
DraggableMonitor *monitor = static_cast<DraggableMonitor*>(TQT_TQWIDGET(monitors.at( i )));
- if (monitor->screen_id == j)
+ if (monitor->screen_id == j) {
primary_monitor = monitor;
+ }
}
}
}
@@ -614,16 +615,21 @@ bool KDisplayConfig::applyMonitorLayoutRules(DraggableMonitor* monitor_to_move)
void KDisplayConfig::moveMonitor(DraggableMonitor* monitor, int realx, int realy) {
int i;
int j;
+ bool primary_found;
DraggableMonitor *primary_monitor;
SingleScreenData *screendata;
// Find the primary monitor
+ primary_found = false;
for (i=0;i<numberOfScreens;i++) {
screendata = m_screenInfoArray.at(i);
- if (screendata->is_primary)
+ if (screendata->is_primary) {
j=i;
+ primary_found = true;
+ }
}
TQObjectList monitors = base->monitorPhyArrange->childrenListObject();
+ primary_monitor = NULL;
if ( monitors.count() ) {
for ( i = 0; i < int(monitors.count()); ++i ) {
if (::tqqt_cast<DraggableMonitor*>(TQT_TQWIDGET(monitors.at( i )))) {
@@ -634,13 +640,15 @@ void KDisplayConfig::moveMonitor(DraggableMonitor* monitor, int realx, int realy
}
}
- int tx = realx * base->monitorPhyArrange->resize_factor;
- int ty = realy * base->monitorPhyArrange->resize_factor;
-
- if (!monitor->isHidden())
- monitor->move((base->monitorPhyArrange->width()/2)-(primary_monitor->width()/2)+tx,(base->monitorPhyArrange->height()/2)-(primary_monitor->height()/2)+ty);
- else
- monitor->move(base->monitorPhyArrange->width(), base->monitorPhyArrange->height());
+ if (primary_found && primary_monitor) {
+ int tx = realx * base->monitorPhyArrange->resize_factor;
+ int ty = realy * base->monitorPhyArrange->resize_factor;
+
+ if (!monitor->isHidden())
+ monitor->move((base->monitorPhyArrange->width()/2)-(primary_monitor->width()/2)+tx,(base->monitorPhyArrange->height()/2)-(primary_monitor->height()/2)+ty);
+ else
+ monitor->move(base->monitorPhyArrange->width(), base->monitorPhyArrange->height());
+ }
}
// int KDisplayConfig::realResolutionSliderValue() {
@@ -1058,6 +1066,8 @@ void KDisplayConfig::updateDragDropDisplay() {
int currentScreenIndex = base->monitorDisplaySelectDD->currentItem();
+ ensureMonitorDataConsistency();
+
// Add the screens to the workspace
// Set the scaling small to start with
base->monitorPhyArrange->resize_factor = 0.0625; // This always needs to divide by a multiple of 2