Quantcast

Fixed mac screen issues and profile loading

Steven Jackson [07-04-14 - 21:09]
Fixed mac screen issues and profile loading
Filename
Interface/AddOns/SVUI/system/alerts.lua
Interface/AddOns/SVUI/system/classes/Database.lua
Interface/AddOns/SVUI/system/installer.lua
Interface/AddOns/SVUI/system/screen.lua
Interface/AddOns/SVUI/system/system.lua
Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua
diff --git a/Interface/AddOns/SVUI/system/alerts.lua b/Interface/AddOns/SVUI/system/alerts.lua
index 367d633..1e05b5a 100644
--- a/Interface/AddOns/SVUI/system/alerts.lua
+++ b/Interface/AddOns/SVUI/system/alerts.lua
@@ -27,8 +27,11 @@ local tonumber  = _G.tonumber;
 local tinsert   = _G.tinsert;
 local string    = _G.string;
 local table     = _G.table;
+local math 		= _G.math;
 --[[ STRING METHODS ]]--
 local lower = string.lower;
+--[[ MATH METHODS ]]--
+local random = math.random;
 --[[ TABLE METHODS ]]--
 local tremove, twipe = table.remove, table.wipe;
 --[[ MUNGLUNCH's FASTER ASSERT FUNCTION ]]--
@@ -792,11 +795,84 @@ function SuperVillain:StaticPopup_Hide(which, data)
 	end
 end

+local function rng()
+	local x,y = random(10,70), random(10,70)
+	return x,y
+end
+
+local function SetConfigAlertAnim(f)
+	local x = x or 50;
+	local y = y or 150;
+	f.trans = f:CreateAnimationGroup()
+	f.trans[1] = f.trans:CreateAnimation("Translation")
+	f.trans[1]:SetOrder(1)
+	f.trans[1]:SetDuration(0.3)
+	f.trans[1]:SetOffset(x,y)
+	f.trans[1]:SetScript("OnPlay",function()f:SetScale(0.01)f:SetAlpha(1)end)
+	f.trans[1]:SetScript("OnUpdate",function(self)f:SetScale(0.1+(1*f.trans[1]:GetProgress()))end)
+	f.trans[2] = f.trans:CreateAnimation("Translation")
+	f.trans[2]:SetOrder(2)
+	f.trans[2]:SetDuration(0.7)
+	f.trans[2]:SetOffset(x*.5,y*.5)
+	f.trans[3] = f.trans:CreateAnimation("Translation")
+	f.trans[3]:SetOrder(3)
+	f.trans[3]:SetDuration(0.1)
+	f.trans[3]:SetOffset(0,0)
+	f.trans[3]:SetScript("OnStop",function()f:SetAlpha(0)end)
+	f.trans:SetScript("OnFinished",f.trans[3]:GetScript("OnStop"))
+end
+
+function SuperVillain:SavedPopup()
+	if not _G["SVUI_ConfigAlert"] then return end;
+	local alert = _G["SVUI_ConfigAlert"]
+	local x,y = rng()
+	if(alert:IsShown()) then
+		alert:Hide()
+	end
+	alert:Show()
+	alert.bg.anim:Play()
+	alert.bg.trans[1]:SetOffset(x,y)
+	alert.fg.trans[1]:SetOffset(x,y)
+	alert.bg.trans[2]:SetOffset(x*.5,y*.5)
+	alert.fg.trans[2]:SetOffset(x*.5,y*.5)
+	alert.bg.trans:Play()
+	alert.fg.trans:Play()
+
+	PlaySoundFile("Sound\\Interface\\uCharacterSheetOpen.wav")
+end
+
 local AlertButton_OnClick = function(self)
 	SysPop_Event_Click(self:GetParent(), self:GetID())
 end

 function SuperVillain:LoadSystemAlerts()
+	if not _G["SVUI_ConfigAlert"] then
+		local configAlert = CreateFrame("Frame", "SVUI_ConfigAlert", UIParent)
+		configAlert:SetFrameStrata("TOOLTIP")
+		configAlert:SetFrameLevel(979)
+		configAlert:Size(300, 300)
+		configAlert:Point("CENTER", 200, -150)
+		configAlert:Hide()
+		configAlert.bg = CreateFrame("Frame", nil, configAlert)
+		configAlert.bg:Size(300, 300)
+		configAlert.bg:Point("CENTER")
+		configAlert.bg:SetFrameStrata("TOOLTIP")
+		configAlert.bg:SetFrameLevel(979)
+		local bgtex = configAlert.bg:CreateTexture(nil, "BACKGROUND")
+		bgtex:SetAllPoints()
+		bgtex:SetTexture("Interface\\AddOns\\SVUI\\assets\\artwork\\Template\\SAVED-BG")
+		configAlert.fg = CreateFrame("Frame", nil, configAlert)
+		configAlert.fg:Size(300, 300)
+		configAlert.fg:Point("CENTER", bgtex, "CENTER")
+		configAlert.fg:SetFrameStrata("TOOLTIP")
+		configAlert.fg:SetFrameLevel(999)
+		local fgtex = configAlert.fg:CreateTexture(nil, "ARTWORK")
+		fgtex:SetAllPoints()
+		fgtex:SetTexture("Interface\\AddOns\\SVUI\\assets\\artwork\\Template\\SAVED-FG")
+		SetConfigAlertAnim(configAlert.bg, configAlert)
+		SetConfigAlertAnim(configAlert.fg, configAlert)
+		SuperVillain.Animate:Orbit(configAlert.bg, 10)
+	end;
 	for i = 1, 4 do
 		local alert = CreateFrame("Frame", "SVUI_SystemAlert"..i, SuperVillain.UIParent, "StaticPopupTemplate")
 		alert:SetID(i)
diff --git a/Interface/AddOns/SVUI/system/classes/Database.lua b/Interface/AddOns/SVUI/system/classes/Database.lua
index 268b266..ceeb506 100644
--- a/Interface/AddOns/SVUI/system/classes/Database.lua
+++ b/Interface/AddOns/SVUI/system/classes/Database.lua
@@ -53,6 +53,9 @@ GET ADDON DATA
 ]]--
 local SuperVillain, L = unpack(select(2, ...));
 local LSM = LibStub("LibSharedMedia-3.0")
+local realm = GetRealmName()
+local name = UnitName("player")
+local pkey = name .. " - " .. realm
 --[[
 ##########################################################
 DEFINE SHARED MEDIA
@@ -190,6 +193,8 @@ DB PROFILE
 ##########################################################
 ]]--
 local DatabaseDefaults = {
+	["copyKey"] = pkey,
+	["profileKey"] = pkey,
 	["framelocations"] = {},
 	["system"] = {
 		["cooldown"] = true,
@@ -3359,9 +3364,7 @@ local function tablecopy(d, s)
 			if(k ~= "SAFEDATA") then
 				if type(v) == "table" then
 					if not rawget(d, k) then rawset(d, k, {}) end
-					if type(d[k]) == "table" then
-						tablecopy(d[k], v)
-					end
+					tablecopy(d[k], v)
 				else
 					if rawget(d, k) == nil then
 						rawset(d, k, v)
@@ -3412,8 +3415,29 @@ local function getdefaults(t, key)
 	return DatabaseDefaults[key] or {}
 end

+local function removedefaults(db, src, nometa)
+	if(type(src) ~= "table") then return end
+	if(not nometa) then
+		setmetatable(db, nil)
+	end
+	for k,v in pairs(src) do
+		if(k ~= "SAFEDATA") then
+			if type(v) == "table" and type(db[k]) == "table" then
+				removedefaults(db[k], v, nometa)
+				if next(db[k]) == nil then
+					db[k] = nil
+				end
+			else
+				if db[k] == src[k] then
+					db[k] = nil
+				end
+			end
+		end
+	end
+end
+
 local function resetprofile(t)
-	local sv = _G["SVUI_Profile"]
+	local sv = rawget(t, "profile")
 	local src = DatabaseDefaults
 	for k,v in pairs(sv) do
 		if(k ~= "SAFEDATA") then
@@ -3425,61 +3449,79 @@ local function resetprofile(t)
 end

 local function listprofiles(t)
-	local globals = _G["SVUI_Global"]
-	return globals.profileKeys
+	local list = {[" SELECT ONE"] = " SELECT ONE"}
+	local globals = rawget(t, "global")
+	for key,_ in pairs(globals.profiles) do
+		list[key] = key
+	end
+	return list
 end

 local function firstprofile(t)
-	local globals = _G["SVUI_Global"]
-	for key in pairs(globals.profileKeys) do
+	local globals = rawget(t, "global")
+	for key,_ in pairs(globals.profiles) do
 		return key
 	end
 end

 local function importprofile(t, key)
-	local sv = _G["SVUI_Profile"]
-	local globals = _G["SVUI_Global"]
+	if(key == " SELECT ONE") then return end
+	local sv = rawget(t, "profile")
+	local dv = rawget(t, "defaults")
+	local globals = rawget(t, "global")
 	local src = globals.profiles[key]
 	if(not src) then return end
+	for k,v in pairs(sv) do
+		if(k ~= "SAFEDATA") then
+			sv[k] = nil
+		end
+	end
 	importdata(src, sv)
+	sv.copyKey = key
 	SuperVillain:RefreshEverything()
 end

 local function exportprofile(t, key)
-	local sv = _G["SVUI_Profile"]
-	local globals = _G["SVUI_Global"]
-	if(not globals.profiles[key]) then
-		globals.profiles[key] = {}
+	if(key == " SELECT ONE") then return end
+	local sv = rawget(t, "profile")
+	local globals = rawget(t, "global")
+	local dv = DatabaseDefaults
+	if(not globals.profiles[key]) then globals.profiles[key] = {} end
+	local saved = globals.profiles[key]
+	tablecopy(saved, sv)
+	for k,v in pairs(saved) do
+		removedefaults(saved[k], dv[k])
 	end
-	local dest = globals.profiles[key]
-	tablecopy(dest, sv)
-	globals.profileKeys[key] = key
+	SuperVillain:SavedPopup()
 end

 local function removeprofile(t, key)
-	local globals = _G["SVUI_Global"]
+	if(key == " SELECT ONE") then return end
+	local globals = rawget(t, "global")
 	if(globals.profiles[key]) then globals.profiles[key] = nil end
-	if(globals.profileKeys[key]) then globals.profileKeys[key] = nil end
+	collectgarbage("collect")
+end
+
+local function initializedata(t)
+	local sv = rawget(t, "profile")
+	local dv = DatabaseDefaults
+	for k,v in pairs(sv) do
+		if(k ~= "SAFEDATA" and dv[k]) then
+			removedefaults(sv[k], dv[k])
+		end
+	end
+	if(not sv.copyKey or (sv.copyKey and type(sv.copyKey) ~= "string")) then
+		sv.copyKey = pkey
+	end
 end

 local SanitizeDatabase = function(self, event)
 	if event == "PLAYER_LOGOUT" then
-		local sv = _G["SVUI_Profile"]
+		local db = SuperVillain.db.profile
 		local src = DatabaseDefaults
-		for k,v in pairs(sv) do
-			if(k ~= "SAFEDATA") then
-				if(rawget(src, k)) then
-					for key in pairs(sv[k]) do
-						if not next(sv[k][key]) then
-							sv[k][key] = nil
-						end
-					end
-					if not next(sv[k]) then
-						sv[k] = nil
-					end
-				else
-					sv[k] = nil
-				end
+		for k,v in pairs(db) do
+			if(k ~= "SAFEDATA" and src[k]) then
+				removedefaults(db[k], src[k])
 			end
 		end
 	end
@@ -3499,12 +3541,13 @@ local metadatabase = {
 	end
 }

-local METAPROFILE = function(sv, pkey)
+local METAPROFILE = function(sv, gv)
 	local db 		= setmetatable({}, metadatabase)

 	db.profile 		= sv
-	db.profileKey 	= pkey
+	db.global 		= gv
 	db.defaults 	= DatabaseDefaults
+	db.Init 		= initializedata
 	db.Reset 		= resetprofile
 	db.SetDefault 	= setdefaults
 	db.GetDefault 	= getdefaults
@@ -3551,14 +3594,12 @@ function SuperVillain:SetDatabaseObjects(init)
 	if(init) then
 		self.db = tcopy(DatabaseDefaults, true)
 	else
-		local realm = GetRealmName()
-		local name = UnitName("player")
-		local pkey = name .. " - " .. realm
-	    local sv = _G["SVUI_Profile"]
+		local sv = _G["SVUI_Profile"]
+		local gv = _G["SVUI_Global"]

 	    twipe(self.db)
-
-		self.db = METAPROFILE(sv, pkey)
+		self.db = METAPROFILE(sv, gv)
+		self.db:Init()
 	end
 	self:SetFilterObjects(init)
 end
\ No newline at end of file
diff --git a/Interface/AddOns/SVUI/system/installer.lua b/Interface/AddOns/SVUI/system/installer.lua
index 41d620e..6f2ee88 100644
--- a/Interface/AddOns/SVUI/system/installer.lua
+++ b/Interface/AddOns/SVUI/system/installer.lua
@@ -22,12 +22,8 @@ local unpack 	= _G.unpack;
 local select 	= _G.select;
 local type 		= _G.type;
 local string 	= _G.string;
-local math 		= _G.math;
 local table     = _G.table;
---[[ STRING METHODS ]]--
 local format = string.format;
---[[ MATH METHODS ]]--
-local random = math.random;
 local tcopy = table.copy;
 --[[
 ##########################################################
@@ -41,8 +37,7 @@ LOCAL VARS
 ##########################################################
 ]]--
 local CURRENT_PAGE, MAX_PAGE, XOFF = 0, 8, (GetScreenWidth() * 0.025)
-local okToResetMOVE=false
-local SVUI_ConfigAlert;
+local okToResetMOVE = false
 local mungs = false;
 local user_music_vol;
 local musicIsPlaying = false;
@@ -51,51 +46,6 @@ local musicIsPlaying = false;
 LOCAL FUNCTIONS
 ##########################################################
 ]]--
-local function rng()
-	local x,y = random(10,70), random(10,70)
-	return x,y
-end;
-
-local function SetConfigAlertAnim(f)
-	local x = x or 50;
-	local y = y or 150;
-	f.trans = f:CreateAnimationGroup()
-	f.trans[1] = f.trans:CreateAnimation("Translation")
-	f.trans[1]:SetOrder(1)
-	f.trans[1]:SetDuration(0.3)
-	f.trans[1]:SetOffset(x,y)
-	f.trans[1]:SetScript("OnPlay",function()f:SetScale(0.01)f:SetAlpha(1)end)
-	f.trans[1]:SetScript("OnUpdate",function(self)f:SetScale(0.1+(1*f.trans[1]:GetProgress()))end)
-	f.trans[2] = f.trans:CreateAnimation("Translation")
-	f.trans[2]:SetOrder(2)
-	f.trans[2]:SetDuration(0.7)
-	f.trans[2]:SetOffset(x*.5,y*.5)
-	f.trans[3] = f.trans:CreateAnimation("Translation")
-	f.trans[3]:SetOrder(3)
-	f.trans[3]:SetDuration(0.1)
-	f.trans[3]:SetOffset(0,0)
-	f.trans[3]:SetScript("OnStop",function()f:SetAlpha(0)end)
-	f.trans:SetScript("OnFinished",f.trans[3]:GetScript("OnStop"))
-end;
-
-local function PopAlert()
-	if not SVUI_ConfigAlert then return end;
-	local x,y = rng()
-	if(SVUI_ConfigAlert:IsShown()) then
-		SVUI_ConfigAlert:Hide()
-	end
-	SVUI_ConfigAlert:Show()
-	SVUI_ConfigAlert.bg.anim:Play()
-	SVUI_ConfigAlert.bg.trans[1]:SetOffset(x,y)
-	SVUI_ConfigAlert.fg.trans[1]:SetOffset(x,y)
-	SVUI_ConfigAlert.bg.trans[2]:SetOffset(x*.5,y*.5)
-	SVUI_ConfigAlert.fg.trans[2]:SetOffset(x*.5,y*.5)
-	SVUI_ConfigAlert.bg.trans:Play()
-	SVUI_ConfigAlert.fg.trans:Play()
-
-	PlaySoundFile("Sound\\Interface\\uCharacterSheetOpen.wav")
-end
-
 local function SetInstallButton(button)
     if(not button) then return end;
     button.Left:SetAlpha(0)
@@ -351,7 +301,7 @@ local function initChat(mungs)
 			if SVUI_Cache["Dock"].RightSuperDockFaded  == true then RightSuperDockToggleButton:Click()end;
 			if SVUI_Cache["Dock"].LeftSuperDockFaded  == true then LeftSuperDockToggleButton:Click()end
 		end
-		PopAlert()
+		SuperVillain:SavedPopup()
 	end
 end;
 --[[
@@ -421,7 +371,7 @@ function SuperVillain:SetUserScreen(rez, preserve)
 		self.Registry:Update('SVDock')
 		self.Registry:Update('SVAura')
 		self.Registry:Update('SVUnit')
-		PopAlert()
+		SuperVillain:SavedPopup()
 	end
 end;

@@ -446,7 +396,7 @@ function SuperVillain:SetColorTheme(style, preserve)
 		self.Registry:Update('SVStats')
 		self.Registry:Update('SVUnit')
 		if(not preserve) then
-			PopAlert()
+			SuperVillain:SavedPopup()
 		end
 	end
 end;
@@ -484,7 +434,7 @@ function SuperVillain:SetUnitframeLayout(style, preserve)
 		self.Registry:Update('SVStats')
 		self.Registry:Update('SVUnit')
 		if(not preserve) then
-			PopAlert()
+			SuperVillain:SavedPopup()
 		end
 	end
 end;
@@ -519,7 +469,7 @@ function SuperVillain:SetupBarLayout(style, preserve)
 		self.Registry:Update('SVStats')
 		self.Registry:Update('SVBar')
 		if(not preserve) then
-			PopAlert()
+			SuperVillain:SavedPopup()
 		end
 	end
 end;
@@ -534,7 +484,7 @@ function SuperVillain:SetupAuralayout(style, preserve)
 		self.Registry:Update('SVAura')
 		self.Registry:Update('SVUnit')
 		if(not preserve) then
-			PopAlert()
+			SuperVillain:SavedPopup()
 		end
 	end
 end;
@@ -929,33 +879,6 @@ function SuperVillain:Install(autoLoaded)
 		PlayMusic([[Interface\AddOns\SVUI\assets\sounds\SuperVillain.mp3]])
 		musicIsPlaying = true
 	end
-	if not SVUI_ConfigAlert then
-		SVUI_ConfigAlert = CreateFrame("Frame", "SVUI_ConfigAlert", UIParent)
-		SVUI_ConfigAlert:SetFrameStrata("TOOLTIP")
-		SVUI_ConfigAlert:SetFrameLevel(979)
-		SVUI_ConfigAlert:Size(300, 300)
-		SVUI_ConfigAlert:Point("CENTER", 200, -150)
-		SVUI_ConfigAlert:Hide()
-		SVUI_ConfigAlert.bg = CreateFrame("Frame", nil, SVUI_ConfigAlert)
-		SVUI_ConfigAlert.bg:Size(300, 300)
-		SVUI_ConfigAlert.bg:Point("CENTER")
-		SVUI_ConfigAlert.bg:SetFrameStrata("TOOLTIP")
-		SVUI_ConfigAlert.bg:SetFrameLevel(979)
-		local bgtex = SVUI_ConfigAlert.bg:CreateTexture(nil, "BACKGROUND")
-		bgtex:SetAllPoints()
-		bgtex:SetTexture("Interface\\AddOns\\SVUI\\assets\\artwork\\Template\\SAVED-BG")
-		SVUI_ConfigAlert.fg = CreateFrame("Frame", nil, SVUI_ConfigAlert)
-		SVUI_ConfigAlert.fg:Size(300, 300)
-		SVUI_ConfigAlert.fg:Point("CENTER", bgtex, "CENTER")
-		SVUI_ConfigAlert.fg:SetFrameStrata("TOOLTIP")
-		SVUI_ConfigAlert.fg:SetFrameLevel(999)
-		local fgtex = SVUI_ConfigAlert.fg:CreateTexture(nil, "ARTWORK")
-		fgtex:SetAllPoints()
-		fgtex:SetTexture("Interface\\AddOns\\SVUI\\assets\\artwork\\Template\\SAVED-FG")
-		SetConfigAlertAnim(SVUI_ConfigAlert.bg, SVUI_ConfigAlert)
-		SetConfigAlertAnim(SVUI_ConfigAlert.fg, SVUI_ConfigAlert)
-		SuperVillain.Animate:Orbit(SVUI_ConfigAlert.bg, 10)
-	end;
 	-- frame
 	if not SVUI_SetupHolder then
 		local frame = CreateFrame("Button", "SVUI_SetupHolder", UIParent)
diff --git a/Interface/AddOns/SVUI/system/screen.lua b/Interface/AddOns/SVUI/system/screen.lua
index 4dc92e2..d3283e6 100644
--- a/Interface/AddOns/SVUI/system/screen.lua
+++ b/Interface/AddOns/SVUI/system/screen.lua
@@ -48,8 +48,8 @@ CORE FUNCTIONS
 ]]--
 function SuperVillain:UIScale(event)
     self.ghettoMonitor = nil;
-    if IsMacClient() and self.db.screenheight and self.db.screenwidth then
-        if(SVUI_Cache and SVUI_Cache.screenheight and (self.screenheight ~= SVUI_Cache.screenheight or self.screenwidth ~= SVUI_Cache.screenwidth)) then
+    if(IsMacClient() and SVUI_Cache and SVUI_Cache.screenheight and SVUI_Cache.screenwidth) then
+        if(self.screenheight ~= SVUI_Cache.screenheight or self.screenwidth ~= SVUI_Cache.screenwidth) then
             self.screenheight = SVUI_Cache.screenheight;
             self.screenwidth = SVUI_Cache.screenwidth
         end
diff --git a/Interface/AddOns/SVUI/system/system.lua b/Interface/AddOns/SVUI/system/system.lua
index 152f100..caf7bfb 100644
--- a/Interface/AddOns/SVUI/system/system.lua
+++ b/Interface/AddOns/SVUI/system/system.lua
@@ -258,10 +258,10 @@ function SuperVillain:TableSplice(targetTable, mergeTable)
         for key,val in pairs(mergeTable) do
             if type(val) == "table" then
                 val = self:TableSplice(targetTable[key], val)
-            end;
+            end
             targetTable[key] = val
         end
-    end;
+    end
     return targetTable
 end

@@ -355,36 +355,41 @@ SVUI LOAD PROCESS
 ]]--
 local function PreLoad(self)
 	--[[ BEGIN DEPRECATED ]]--
-    if SVUI_DATA then SVUI_DATA = nil end;
-    if SVUI_SAFE_DATA then SVUI_SAFE_DATA = nil end;
-    if SVUI_TRACKER then SVUI_TRACKER = nil end;
-    if SVUI_ENEMIES then SVUI_ENEMIES = nil end;
-    if SVUI_JOURNAL then SVUI_JOURNAL = nil end;
-    if SVUI_CHARACTER_LOG then SVUI_CHARACTER_LOG = nil end;
-    if SVUI_MOVED_FRAMES then SVUI_MOVED_FRAMES = nil end;
-    if SVUI_SystemData then SVUI_SystemData = nil end;
-    if SVUI_ProfileData then SVUI_ProfileData = nil end;
+    if SVUI_DATA then SVUI_DATA = nil end
+    if SVUI_SAFE_DATA then SVUI_SAFE_DATA = nil end
+    if SVUI_TRACKER then SVUI_TRACKER = nil end
+    if SVUI_ENEMIES then SVUI_ENEMIES = nil end
+    if SVUI_JOURNAL then SVUI_JOURNAL = nil end
+    if SVUI_CHARACTER_LOG then SVUI_CHARACTER_LOG = nil end
+    if SVUI_MOVED_FRAMES then SVUI_MOVED_FRAMES = nil end
+    if SVUI_SystemData then SVUI_SystemData = nil end
+    if SVUI_ProfileData then SVUI_ProfileData = nil end
     --[[ END DEPRECATED ]]--

-	if not SVUI_Global then SVUI_Global = {} end;
-    if not SVUI_Global["profiles"] then SVUI_Global["profiles"] = {} end;
-    if not SVUI_Global["profileKeys"] then SVUI_Global["profileKeys"] = {} end;
-    if not SVUI_Global["gold"] then SVUI_Global["gold"] = 0 end;
+	if not SVUI_Global then SVUI_Global = {} end
+    if not SVUI_Global["profiles"] then SVUI_Global["profiles"] = {} end

-    if not SVUI_Profile then SVUI_Profile = {} end;
-    if not SVUI_Profile.SAFEDATA then SVUI_Profile.SAFEDATA = {} end;
+    if SVUI_Global["gold"] then SVUI_Global["gold"] = nil end
+    if SVUI_Global["profileKeys"] then SVUI_Global["profileKeys"] = nil end

-    if not SVUI_Filters then SVUI_Filters = {} end;
+    if not SVUI_Profile then SVUI_Profile = {} end
+    if not SVUI_Profile.SAFEDATA then SVUI_Profile.SAFEDATA = {} end

-    if not SVUI_Cache then SVUI_Cache = {} end;
-    if not SVUI_Cache["Dock"] then SVUI_Cache["Dock"] = {} end;
-    if not SVUI_Cache["Mentalo"] then SVUI_Cache["Mentalo"] = {} end;
-    if not SVUI_Cache["screenheight"] then SVUI_Cache["screenheight"] = {} end;
-    if not SVUI_Cache["screenwidth"] then SVUI_Cache["screenwidth"] = {} end;
+    if not SVUI_Filters then SVUI_Filters = {} end
+
+    if not SVUI_Cache then SVUI_Cache = {} end
+    if not SVUI_Cache["Dock"] then SVUI_Cache["Dock"] = {} end
+    if not SVUI_Cache["Mentalo"] then SVUI_Cache["Mentalo"] = {} end
+    if(not SVUI_Cache["screenheight"] or (SVUI_Cache["screenheight"] and type(SVUI_Cache["screenheight"]) ~= "number")) then
+    	SVUI_Cache["screenheight"] = self.screenheight
+    end
+    if(not SVUI_Cache["screenwidth"] or (SVUI_Cache["screenwidth"] and type(SVUI_Cache["screenwidth"]) ~= "number")) then
+    	SVUI_Cache["screenwidth"] = self.screenwidth
+    end

     --[[ MORE DEPRECATED ]]--
-    if SVUI_Cache["Mentalo"]["Blizzard"] then SVUI_Cache["Mentalo"]["Blizzard"] = nil end;
-    if SVUI_Cache["Mentalo"]["UI"] then SVUI_Cache["Mentalo"]["UI"] = nil end;
+    if SVUI_Cache["Mentalo"]["Blizzard"] then SVUI_Cache["Mentalo"]["Blizzard"] = nil end
+    if SVUI_Cache["Mentalo"]["UI"] then SVUI_Cache["Mentalo"]["UI"] = nil end
     --[[ END DEPRECATED ]]--

     self:SetDatabaseObjects(true)
diff --git a/Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua b/Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua
index becfd21..791f331 100644
--- a/Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua
+++ b/Interface/AddOns/SVUI_ConfigOMatic/modules/profiles.lua
@@ -74,7 +74,7 @@ SuperVillain.Options.args.profiles = {
 			desc = L["import_sub"],
 			type = "select",
 			order = 6,
-			get = function() return SuperVillain.db.profileKey end,
+			get = function() return " SELECT ONE" end,
 			set = function(key, value) SuperVillain.db:Import(value) end,
 			values = SuperVillain.db:GetAll(),
 		},
@@ -94,7 +94,7 @@ SuperVillain.Options.args.profiles = {
 			type = "select",
 			name = L["delete"],
 			desc = L["delete_sub"],
-			get = false,
+			get = function() return " SELECT ONE" end,
 			set = function(key, value) SuperVillain.db:Remove(value) end,
 			values = SuperVillain.db:GetAll(),
 			disabled = function() local t = SuperVillain.db:GetAll() return (not t) end,