Index: xmlparse.cpp
===================================================================
--- xmlparse.cpp	(revision 17354)
+++ xmlparse.cpp	(working copy)
@@ -291,7 +291,7 @@
     if (baseFont && !haveSize)
         size = baseFont->face.pointSize();
     else    
-        size = GetMythMainWindow()->NormalizeFontSize(size);
+        size = gContext->NormalizeFontSize(size);
     
     // If we don't have to, don't load the font.
     if (!haveFace && baseFont)
Index: mythdbcon.h
===================================================================
--- mythdbcon.h	(revision 17354)
+++ mythdbcon.h	(working copy)
@@ -116,13 +116,14 @@
     /// \brief Wrap QSqlQuery::exec(const QString &query) so we can display SQL
     bool exec(const QString &query);
 
-    /// \brief QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2
     bool prepare(const QString &query);
 
     /// \brief Wrap QSqlQuery::bindValue so we can convert null QStrings to empty QStrings
-    void bindValue ( const QString & placeholder, const QVariant & val, QSql::ParamType paramType = QSql::In );
+    void bindValue ( const QString & placeholder, const QVariant & val,
+                     QSql::ParamType paramType = QSql::In );
     /// \brief Wrap QSqlQuery::bindValue so we can convert null QStrings to empty QStrings
-    void bindValue ( int pos, const QVariant & val, QSql::ParamType paramType = QSql::In );
+    void bindValue ( int pos,
+                     const QVariant & val, QSql::ParamType paramType = QSql::In );
 
     /// \brief Add all the bindings in the passed in bindings
     void bindValues(MSqlBindings &bindings);
Index: mythcontext.cpp
===================================================================
--- mythcontext.cpp	(revision 17354)
+++ mythcontext.cpp	(working copy)
@@ -221,7 +221,7 @@
     Settings *m_settings;          ///< connection stuff, theme, button style
     Settings *m_qtThemeSettings;   ///< everything else theme-related
 
-    QString   m_installprefix;     ///< Compile-time PREFIX, or generated
+    QString   m_installprefix;     ///< Compile-time RUNPREFIX, or generated
                                    ///< from enviroment ($MYTHTVDIR or $cwd)
     QString   m_installlibdir;     ///< Compile-time LIBDIR, or generated
 
@@ -314,7 +314,7 @@
 MythContextPrivate::MythContextPrivate(MythContext *lparent)
     : parent(lparent),
       m_settings(new Settings()), m_qtThemeSettings(new Settings()),
-      m_installprefix(PREFIX), m_installlibdir(LIBDIR),
+      m_installprefix(RUNPREFIX), m_installlibdir(LIBDIR),
       m_gui(false), m_backend(false), m_themeloaded(false),
       m_menuthemepathname(QString::null), m_themepathname(QString::null),
       m_backgroundimage(NULL),
@@ -368,15 +368,6 @@
             m_installlibdir = prefixDir.canonicalPath();
         }
     }
-    else if (prefixDir.path().contains(".app/Contents/MacOS"))
-    {
-        prefixDir.cd("../Resources");
-        if (QDir(prefixDir.canonicalPath() + "/bin").exists() ||
-            QDir(prefixDir.canonicalPath() + "/share").exists())
-            m_installprefix = prefixDir.canonicalPath();
-        if (QDir(prefixDir.canonicalPath() + "/lib").exists())
-            m_installlibdir = prefixDir.canonicalPath() + "/lib";
-    }
 
     VERBOSE(VB_IMPORTANT, QString("Using runtime prefix = %1, libdir = %2")
                           .arg(m_installprefix).arg(m_installlibdir));
Index: mythdbcon.cpp
===================================================================
--- mythdbcon.cpp	(revision 17354)
+++ mythdbcon.cpp	(working copy)
@@ -134,7 +134,11 @@
     // mdz, 2003/08/11
 
 
-    if (m_db.hostName().isEmpty())  // Bootstrapping without a database?
+#if 0
+    if (m_db.hostName().isEmpty()    // Bootstrapping without a database?
+        || m_db.isOpenError())       // Database invalid?
+#endif
+    if (m_db.hostName().isEmpty())   // Bootstrapping without a database?
     {                                // Pretend we kicked, to reduce errors
         m_lastDBKick = QDateTime::currentDateTime();
         return true;
@@ -326,7 +330,7 @@
             qi.db = db;
             qi.qsqldb = db->db();
 
-            db->KickDatabase();
+            //db->KickDatabase();
         } 
     }
     else
@@ -351,7 +355,7 @@
             qi.db = db;
             qi.qsqldb = db->db(); 
 
-            db->KickDatabase();
+            //db->KickDatabase();
         } 
     }
     else
@@ -376,7 +380,7 @@
             qi.db = db;
             qi.qsqldb = db->db(); 
 
-            db->KickDatabase();
+            //db->KickDatabase();
         } 
     }
     else
Index: libmyth.pro
===================================================================
--- libmyth.pro	(revision 17354)
+++ libmyth.pro	(working copy)
@@ -1,9 +1,9 @@
 include ( ../../config.mak )
 include ( ../../settings.pro )
- 
+
 TEMPLATE = lib
 TARGET = myth-$$LIBVERSION
-CONFIG += thread dll
+CONFIG += thread dll debug
 target.path = $${LIBDIR}
 INSTALLS = target
 
@@ -56,8 +56,8 @@
 
 LIBS += -L../libmythsamplerate   -lmythsamplerate-$${LIBVERSION}
 LIBS += -L../libmythsoundtouch   -lmythsoundtouch-$${LIBVERSION}
-LIBS += -L../libmythui           -lmythui-$${LIBVERSION}
-LIBS += -L../libmythupnp         -lmythupnp-$${LIBVERSION}
+!combine-libmyth: LIBS += -L../libmythui           -lmythui-$${LIBVERSION}
+!combine-libmyth: LIBS += -L../libmythupnp         -lmythupnp-$${LIBVERSION}
 LIBS += -L../libmythfreesurround -lmythfreesurround-$${LIBVERSION}
 LIBS += -L../libavcodec          -lmythavcodec-$${LIBVERSION}
 LIBS += -L../libavutil           -lmythavutil-$${LIBVERSION}
@@ -113,7 +113,8 @@
 
     # For easier debugging:
     target.path = $${PREFIX}/bin
-
+ 
+  !combine-libmyth {
     LIBS -= -lmythui-$$LIBVERSION  -lmythupnp-$$LIBVERSION 
     LIBS += -L. -lmythui-bootstrap -lmythupnp-bootstrap
     POST_TARGETDEPS += libmythui-bootstrap.a libmythupnp-bootstrap.a
@@ -128,6 +129,7 @@
                        --dllname libmythupnp-$${LIBVERSION}.dll \
                        --output-lib $$implib2.target  -k
     QMAKE_EXTRA_WIN_TARGETS += implib implib2
+  }
 }
 
 macx {
@@ -248,3 +250,134 @@
 
 #The following line was inserted by qt3to4
 QT += network xml opengl sql qt3support
+
+
+combine-libmyth {
+    # ../libmythupnp/libmythupnp.pro
+
+    include (../../version.pro)
+
+    setting.path = $${PREFIX}/share/mythtv/
+    setting.files += CDS_scpd.xml CMGR_scpd.xml MSRR_scpd.xml MXML_scpd.xml
+
+    INSTALLS += setting
+
+    HEADERS3 += httprequest.h upnp.h ssdp.h taskqueue.h  
+    HEADERS3 += upnpdevice.h upnptasknotify.h upnptasksearch.h threadpool.h upnputil.h
+    HEADERS3 += httpserver.h upnpcds.h upnpcdsobjects.h bufferedsocketdevice.h upnpmsrr.h
+    HEADERS3 += eventing.h upnpcmgr.h upnptaskevent.h upnptaskcache.h ssdpcache.h
+    HEADERS3 += upnpimpl.h multicast.h broadcast.h configuration.h
+    HEADERS3 += soapclient.h mythxmlclient.h
+
+    SOURCES3 += httprequest.cpp upnp.cpp ssdp.cpp taskqueue.cpp upnputil.cpp
+    SOURCES3 += upnpdevice.cpp upnptasknotify.cpp upnptasksearch.cpp threadpool.cpp
+    SOURCES3 += httpserver.cpp upnpcds.cpp upnpcdsobjects.cpp bufferedsocketdevice.cpp
+    SOURCES3 += eventing.cpp upnpcmgr.cpp upnpmsrr.cpp upnptaskevent.cpp ssdpcache.cpp
+    SOURCES3 += configuration.cpp soapclient.cpp mythxmlclient.cpp
+
+    LIBS += $$EXTRA_LIBS
+
+    mingw {
+        HEADERS3 += darwin-sendfile.h
+        SOURCES3 += darwin-sendfile.c
+
+        LIBS += -lws2_32
+    }
+
+    inc3.path = $${PREFIX}/include/mythtv/upnp/
+
+    inc3.files  = httprequest.h upnp.h ssdp.h taskqueue.h bufferedsocketdevice.h
+    inc3.files += upnpdevice.h upnptasknotify.h upnptasksearch.h threadpool.h upnputil.h
+    inc3.files += httpserver.h httpstatus.h upnpcds.h upnpcdsobjects.h
+    inc3.files += eventing.h upnpcmgr.h upnptaskevent.h upnptaskcache.h ssdpcache.h
+    inc3.files += upnpimpl.h multicast.h broadcast.h configuration.h
+    inc3.files += soapclient.h mythxmlclient.h
+
+    INSTALLS += inc3
+
+    cygwin:HEADERS3 += darwin-sendfile.h
+    cygwin:SOURCES3 += darwin-sendfile.c
+
+    freebsd:HEADERS3 += darwin-sendfile.h 
+    freebsd:SOURCES3 += darwin-sendfile.c 
+
+    macx {
+        HEADERS3 += darwin-sendfile.h
+        SOURCES3 += darwin-sendfile.c
+
+        QMAKE_LFLAGS_SHLIB += -flat_namespace
+    }
+
+
+
+
+    # ../libmythui/libmythui.pro
+
+    HEADERS4  = mythmainwindow.h mythpainter.h mythimage.h myththemebase.h
+    HEADERS4 += mythpainter_qt.h mythmainwindow_internal.h
+    HEADERS4 += mythscreenstack.h mythscreentype.h mythuitype.h mythuiimage.h 
+    HEADERS4 += mythuitext.h mythuistatetype.h mythgesture.h xmlparsebase.h
+    HEADERS4 += mythuibutton.h mythlistbutton.h myththemedmenu.h mythdialogbox.h
+    HEADERS4 += mythuiclock.h mythuitextedit.h mythprogressdialog.h mythuispinbox.h
+
+    SOURCES4  = mythmainwindow.cpp mythpainter.cpp mythimage.cpp myththemebase.cpp
+    SOURCES4 += mythpainter_qt.cpp xmlparsebase.cpp
+    SOURCES4 += mythscreenstack.cpp mythscreentype.cpp mythgesture.cpp
+    SOURCES4 += mythuitype.cpp mythuiimage.cpp mythuitext.cpp
+    SOURCES4 += mythuistatetype.cpp mythlistbutton.cpp mythfontproperties.cpp
+    SOURCES4 += mythuibutton.cpp myththemedmenu.cpp mythdialogbox.cpp
+    SOURCES4 += mythuiclock.cpp mythuitextedit.cpp mythprogressdialog.cpp
+    SOURCES4 += mythuispinbox.cpp
+
+    inc4.path = $${PREFIX}/include/mythtv/libmythui/
+
+    inc4.files  = mythmainwindow.h mythpainter.h mythimage.h myththemebase.h
+    inc4.files += mythpainter_qt.h mythuistatetype.h
+    inc4.files += mythscreenstack.h mythscreentype.h mythuitype.h mythuiimage.h 
+    inc4.files += mythuitext.h mythuibutton.h mythlistbutton.h xmlparsebase.h
+    inc4.files += myththemedmenu.h mythdialogbox.h mythfontproperties.h
+    inc4.files += mythuiclock.h mythgesture.h mythuitextedit.h mythprogressdialog.h
+    inc4.files += mythuispinbox.h
+
+    INSTALLS += inc4
+
+    using_x11:using_opengl {
+        DEFINES += USE_OPENGL_PAINTER
+        SOURCES4 += mythpainter_ogl.cpp
+        HEADERS4 += mythpainter_ogl.h
+        inc4.files += mythpainter_ogl.h
+        LIBS += $$EXTRA_LIBS
+    }
+
+    macx {
+        QMAKE_CXXFLAGS += -F/System/Library/Frameworks/Carbon.framework/Frameworks
+        LIBS           += -framework Carbon -framework OpenGL
+
+        QMAKE_LFLAGS_SHLIB += -flat_namespace
+    }
+
+    using_joystick_menu {
+        DEFINES += USE_JOYSTICK_MENU
+    }
+
+    using_lirc {
+        DEFINES += USE_LIRC
+    }
+
+    cygwin:DEFINES += _WIN32
+
+    mingw {
+        using_opengl {
+            LIBS += -lopengl32
+            DEFINES += USE_OPENGL_PAINTER
+            SOURCES4 += mythpainter_ogl.cpp
+            HEADERS4 += mythpainter_ogl.h
+            inc4.files += mythpainter_ogl.h
+        }
+    }
+
+    HEADERS += $$join(HEADERS3, ' ', '../libmythupnp/')
+    HEADERS += $$join(HEADERS4, ' ', '../libmythui/')
+    SOURCES += $$join(SOURCES3, ' ', '../libmythupnp/')
+    SOURCES += $$join(SOURCES4, ' ', '../libmythui/')
+}
