[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [PATCH] kdegames/klickety compiles and runs
From:       Dmitry Suzdalev <dimsuz () mail ! ru>
Date:       2006-04-11 22:32:33
Message-ID: 200604120232.33584.dimsuz () mail ! ru
[Download RAW message or body]

Hello, dear developers!

This patch makes kdegames/klickety compile & run.

Basicly it removes wrong uses of QVector::insert() - developer (or tool) who 
replaced old qt3 calls to at() with new QVector::insert() seemed to think 
that insert _replaces_ element in vector, but in reality it _extends_ vector 
by one element.

In one place I'm not quite sure that calling operator[]() directly is 
the best solution, maybe you can advice on this? :)

And I don't know is the BaseBoard's constructor the right place to call its  
adjustSize(), but without that call one important function is not called and 
the whole thing crashes.

It crashes because:
1. BaseBoard::adjustSize() isn't QWidget's adjustSize() - its reimplemented 
from FixedCanvasView, which is child of Q3CanvasView.
Oh, and it turns out that the Q3CanvasView hasn't adjustSize() - so it's first 
introduced by FixedCanvasView. So that's not Qt's one, and I better figure 
out by myself from where it is supposed to be called... If someone knows it, 
please tell me ;).
2. Call to BaseBoard::adjustSize() sets up some important pointers (to some 
QPixmap's) used later. So nocall=crash ;).

Maybe adjustSize() was supposed to be called automatically but that doesn't 
happen in KDE4's trunk for some reason.

Also the patch contains my first attempt do dive into KDE's CMake.
Espesially I'm not sure what to put in VERSION and SOVERSION for 
'libksirtetbase' library - just copied corresponding macros call from some 
other lib CMakeLists.txt.

Well, I'm only starting to learn KDE :). I know Qt3 quite well, but 
Qt4-beginner :).

I'm looking forward to do some more KDE4 porting on kdegames...

With best wishes,
Dmitry.

PS. Sorry for my not very good English.

["kdegames-klickety-run.patch" (text/x-diff)]

Index: libkdegames/highscore/kexthighscore_internal.cpp
===================================================================
--- libkdegames/highscore/kexthighscore_internal.cpp	(revision 528095)
+++ libkdegames/highscore/kexthighscore_internal.cpp	(working copy)
@@ -152,11 +153,10 @@
 {
     if ( findIndex(name)!=-1 )
         kError(11002) << "item already exists \"" << name << "\"" << endl;
-    uint i = size();
-    resize(i+1);
-	insert(i, new ItemContainer);
+
+    append(new ItemContainer);
     //at(i) = new ItemContainer;
-    _setItem(i, name, item, stored, canHaveSubGroup);
+    _setItem(size()-1, name, item, stored, canHaveSubGroup);
 }
 
 void ItemArray::_setItem(uint i, const QString &name, Item *item,
Index: libksirtet/base/main.cpp
===================================================================
--- libksirtet/base/main.cpp	(revision 528095)
+++ libksirtet/base/main.cpp	(working copy)
@@ -95,7 +95,7 @@
 
 void BaseMainWindow::configureKeys()
 {
-    KKeyDialog d(true, this);
+    KKeyDialog d(KKeyChooser::AllActions, KKeyChooser::LetterShortcutsAllowed, \
this);  addKeys(d);
     d.insert(actionCollection());
     d.configure(false);
Index: libksirtet/base/piece.cpp
===================================================================
--- libksirtet/base/piece.cpp	(revision 528095)
+++ libksirtet/base/piece.cpp	(working copy)
@@ -96,7 +97,9 @@
                 }
             }
         if ( at(i)==0 ) {
-            insert(i, new Q3CanvasPixmapArray(pixmaps, points));
+            // call to QVector::insert here would modify this vector during \
iteration over it! +            // QVector::at(i) in Qt4 returns _const_ reference, \
so we can't use it here +            operator[](i) = new Q3CanvasPixmapArray(pixmaps, \
points);  pixmaps.clear();
             points.clear();
         }
Index: libksirtet/base/board.cpp
===================================================================
--- libksirtet/base/board.cpp	(revision 528095)
+++ libksirtet/base/board.cpp	(working copy)
@@ -61,6 +61,7 @@
         
         Piece::info().loadColors();
         KZoomMainWindow::addWidget(this);
+        adjustSize();
     }
 }
 
Index: libksirtet/base/CMakeLists.txt
===================================================================
--- libksirtet/base/CMakeLists.txt	(revision 528095)
+++ libksirtet/base/CMakeLists.txt	(working copy)
@@ -2,13 +2,35 @@
 
 include_directories( ${CMAKE_SOURCE_DIR}/libkdegames \
${CMAKE_SOURCE_DIR}/libkdegames/highscore ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} \
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}  )  
+
+########### next target ###############
+set ( libksirtetbase_LIB_SRCS
+    kzoommainwindow.cpp
+    main.cpp
+    field.cpp
+    piece.cpp
+    highscores.cpp
+    factory.cpp
+    gtetris.cpp
+    board.cpp
+    settings.cpp
+    inter.cpp
+    )
+
+kde4_automoc(${libksirtetbase_LIB_SRCS})
+
 set( libksirtetbase_KCFG_SRCS baseprefs.kcfgc)
 
 kde4_add_kcfg_files(libksirtetbase_SRCS ${libksirtetbase_KCFG_SRCS})
 
-########### next target ###############
+kde4_add_library( ksirtetbase SHARED ${libksirtetbase_SRCS} )
 
+target_link_libraries( ksirtetbase ${KDE4_KDEUI_LIBS} kdegames )
 
+set_target_properties( ksirtetbase PROPERTIES VERSION 1.2.0 SOVERSION 1 )
+
+install_targets( ${LIB_INSTALL_DIR} ksirtetbase )
+
 ########### install files ###############
 
 



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic